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
6
votes
2 answers

List of y86 commands?

I am looking for a way to convert some code into it's y86 equivalent. The problem is I am having trouble finding a good list of y86 functions. I can find some functions but not a good list of the main functions available. Does anyone know where I…
Eman
  • 6,383
  • 4
  • 23
  • 29
4
votes
2 answers

How to perform right shift in Y86-64 (or other toy ISAs with ADD + AND but no native right shift)

I'm trying to perform a right shift on Y86-64 To do a left shift I know that I need to multiply by 2^n where n is the number of bit shift we want for example if we want to shift by 4 it's 2^4 = 16 and do a loop of additions to perform…
kidran
  • 41
  • 2
4
votes
1 answer

"can't find label" error in Y86 compiler

I'm writing up a program in Y86, but I keep getting an error "can't find label" for my code lines setting up the stack and base pointer. My code is: .pos 0 init: irmovl Stack, %esp //Set up stack pointer irmovl Stack, %ebp //Set up base…
user2785277
  • 345
  • 4
  • 19
4
votes
1 answer

Assembly: Y86 Stack and call, pushl/popl and ret instructions

Unless I copied it wrong, the code above was written in the blackboard in a class by a student with the help/corrections of the teacher: int array[100], sum, i; void ini() { for(i = 0; i < 100; i++) array[i] = i; } int main() { ini(); …
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
3
votes
1 answer

Does pushl %esp update ESP before or after storing?

The pushl Y86 instruction both decrements the stack pointer by 4 and writes a register value to memory. So it's not clear what the processor should do when it executes the instruction pushl %esp, since the register being pushed is being changed by…
velkoon
  • 871
  • 3
  • 15
  • 35
3
votes
0 answers

Y86 Assembly - Summing a Linked List

I was wondering if anyone could help me better understand both why this code that I have written does not work, and help me also to fix it. The following is the Y86 I've written which should sum the array which I've defined within it, however, all I…
3
votes
2 answers

Confused about memory locations of this Y86 assembly code

We had a piece of code in C in one class where we needed to convert it to Y86 and this was written on the board by some guy with the teacher's correction of course. However, I'm confusing the memory locations and .pos directives on the initial part…
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
2
votes
2 answers

Fail to build y86-64 simulator from sources

I am attempting to compile a simulator for Y86-64 code on Linux.I have already rewritten the makefile but it turned out like below.It said "undefined reference for 'matherr'".(Looks like it connects with gcc when linking) (cd pipe; make all…
gcc17
  • 91
  • 1
  • 9
2
votes
1 answer

How to determine the program counter when decoding from assembly to machine code (Y86)?

Im having trouble understanding how the address location is determined when decoding from assembly to Y86. In the example, 0x030 0x030: 6300 # xorq %rax , %rax 0x032: 50030001000000000000 # mrmovq 0x100(%rax ) ,…
2
votes
2 answers

Failed to install the y86 simulator (csapp)

I am attempting to compile a simulator for Y86 code on archlinux, here is my configuration. (I'm really sorry about the format.) GUIMODE=-DHAS_GUI TKLIBS=-L/usr/lib -ltk -ltcl TKINC=-isystem /usr/include But when I run the makefile, things…
jkjkjk
  • 111
  • 8
2
votes
0 answers

Trouble with y86 bubble sort program

So 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: #include void bubble(int *, int); int main(){ int count = 5; int data[5]= {3, 2, 6, 1, 9,}; bubble(data,…
JSolo714
  • 35
  • 1
  • 7
2
votes
1 answer

How to convert IA32 'cmp' instruction to Y86?

IA32 to Y86 ATT Assembly I have the following IA32 assembly code: Bubble: .LFB0: pushl %esi pushl %ebx movl 16(%esp), %esi movl 12(%esp), %edx subl $1, %esi andl %esi, %esi jle .L1 .L7: xorl %eax,…
amorimluc
  • 1,661
  • 5
  • 22
  • 32
2
votes
2 answers

Translate C code to assembly code?

I have to translate this C code to assembly code: #include int main(){ int a, b,c; scanf("%d",&a); scanf("%d",&b); if (a == b){ b++; } if (a > b){ c = a; a = b; b = c; } printf("%d\n",b-a); return 0; } My…
user1261445
  • 291
  • 1
  • 6
  • 15
2
votes
2 answers

y86 assembly labels not doing what they should be

posted below is the code I have for a simple y86 assembly program. Given two integers, it should print out the larger of the two. To the right of each line I have an equivalent C translation. # I ask about the need for a first line comment…
Stout Joe
  • 324
  • 2
  • 4
  • 14
1
vote
1 answer

Not getting output in first Y86 program

I'm trying to learn Y86, so I made a very simple program. It has an array of three long integers, and each block is filled by asking the user for an input through rdint. The compiled(?) program asks for three inputs, but is not able to print them…
Chul Kwon
  • 167
  • 1
  • 3
  • 11
1
2 3 4 5 6