Questions tagged [y86]

Y86 is an academic simplification of the 80x86 CPU architecture. The language and architecture are often used for teaching CPU instruction encoding and decoding.

The x86 instruction set has too many complications and distractions to be effective in focused academic study of CPU architecture, instruction decoding etc. So the essence of the 80x86 is crafted into a new architecture:

  • All operands are 16 bits
  • Only four registers: AX, BX, CX, and DX
  • 16-bit address space
  • 20 instructions: MOV (two forms), ADD, SUB, CMP, AND, OR, NOT, JE, JNE, JB, JBE, JA, JAE, JMP, BRK, IRET, HALT, GET, and PUT.
  • Opcode is encoded as a single byte, operands are encoded as a two byte displacement/offset.

More details can be found here.

85 questions
1
vote
1 answer

Y86 bubble sort program not sorting properly

I am trying to convert a bubble sort program from assembly to Y86. I started with this C code and then converted it to assembly: void bubbleSort2(long arr[], long len) { long i; // inner loop index long tmp; // temp for…
chronkilo
  • 23
  • 3
1
vote
0 answers

Convert C function to Y86 function

first question here, please let me know if I did anything wrong. Essentially, I'm having a bit of trouble converting C function to Y86 function. I don't know how to put the C function parameters in registers of Y86 (don't know if I described this…
Haymend
  • 19
  • 3
1
vote
0 answers

Why is this Y86-64 code segment failing to execute the expected jg branch?

Here is the Y86 code for reference .pos 0 irmovq stack, %rsp # initialize stack pointer call main halt .align 8 input_array: .quad 6 .quad 4 .quad 5 .quad 2 .quad 3 .quad 1 count: .quad 6 main: irmovq input_array, %rdi irmovq count,…
mooglin
  • 500
  • 5
  • 17
1
vote
3 answers

Y86 code doesn't handle ret instruction as expected

The following is a homework problem for an assembly language class. We're to create Y86 code by reading X86 code generated from C in gdb. The purpose of the function is to sum the elements of a linked list. As the function currently stands, it…
malenkylizards
  • 223
  • 1
  • 4
  • 13
1
vote
1 answer

Unrolling y86 loop

I am trying to unroll a loop in y86 code but I been getting 2 different values when I try to run a test program. The reg. code is: xorq %rax,%rax # count = 0; andq %rdx,%rdx # len <= 0? jle Done # if so, goto…
Nukodi
  • 335
  • 1
  • 9
  • 24
1
vote
1 answer

Getting an ADR error in a y86 program, have no idea why. Stack appears to be set up well

I have the following y86-64 program from CMU's Architecture lab that's supposed to sum up the values of a linked list. # Adam Cooper ac251190 init: .pos 0x0 irmovq Stack, %rsp # set up stack pointer irmovq Stack, %rbp …
AdumbCopper
  • 23
  • 1
  • 4
1
vote
1 answer

The most efficient way of counting positive, negative and zero number using loop unrolling

Say I have the following instruction, simply checks if a number is positive or not (negative or zero) and if it was positive add 1 to our counter (and we don't care if the numbers is negative or zero). I can do this with a simple loop…
Yar
  • 7,020
  • 11
  • 49
  • 69
1
vote
1 answer

Y86 assembly global variables

I am struggling to get global variables to work correctly for my Y86 assignment. Unfortunately the only examples we were provided with are in IA-32 assembly. I have searched for the last few hours but to no avail. This is very basic I know but I…
noviceCdr
  • 21
  • 1
  • 4
1
vote
1 answer

Basic Assembly Labels and Jumping

So I'm working on some assembly and I'm testing some things out before I jump right into anything intermediate. What I'm trying to do: The user inputs a number 0 or 1. The output is the number and whatever character the number starts with (O for one…
Dan Snacks
  • 31
  • 1
  • 6
1
vote
1 answer

Y86 Sum program confusion

I'm confused about this example program from my computer architecture textbook. Here's the C code... And here's the generated Y86 code... My question is with 0x046 mrmovl 8(%ebp), %ecx Why exactly is it setting Start to 8 bytes in front of the…
Weston
  • 1,291
  • 3
  • 12
  • 25
1
vote
1 answer

How to convert instruction from IA32 to Y86

I have this IA32 assembly code that I'm trying to convert into Y86 assembly code: bubble_a: pushl %ebp movl %esp, %ebp pushl %edi pushl %esi pushl %ebx movl 8(%ebp), %edx movl 12(%ebp), %edi subl …
user3009956
  • 11
  • 1
  • 2
1
vote
3 answers

IA32 to Y86 Assembly Code Conversion

I've been tasked with converting IA32 code to Y86. The original program was written in C and is intended to take an array of integers in which the even positioned values call one of three functions and the odd positioned values are operated on…
Matt Koz
  • 67
  • 3
  • 10
1
vote
1 answer

IA32 assembly code to Y86 assembly code: leal instruction

I am studying how to convert IA32 assembly code to Y86 assembly code, and I am stuck in the following instruction which is in IA32 code: leal(%edx, %eax), %eax I cannot find the equivalent instructions for the Y86 code. I have though of two…
FranXh
  • 4,481
  • 20
  • 59
  • 78
1
vote
2 answers

Do I understand the stack properly in this Y86 Assembly code?

I've created this simple and pointless assembly (Y86) code to see if I understand everything that's happening in the stack when the instructions call, pushl, popl and ret are used. Like I said, this code is pointless, it's just for testing/learning…
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
0
votes
3 answers

counting positive items in an array without using any conditional jump

How can I do this ? I think I should do something like calculating checksum but this should give number of positive integers in final bits. edit: what if we can't use 'shift', either edit2: ISA is Y86
bfaskiplar
  • 865
  • 1
  • 7
  • 23