Slide Deck A-5 Flashcards
What do the 4 data movement instructions rrmovq, irmovq, rmmovq and mrmovq do in Y86?
rrmovq: copies a value between registers
irmovq: used to place 8 byte immediate (constant) value (address of labels or numeric literal constants) into a register
rmmovq: stores a word in memory
mrmovq: loads a word from memory
rmmovq and mrmovq are the only instructions that access memory
Is a source operand read, written, or both in Y86?
Only read
Is a destination operand read, written or both in Y86?
For ALU instructions, both read and written; for other types of instructions, only written.
What is an immediate operand in Y86?
A constant value; always stored as part of the encoded bit string for the instruction.
Be sure you understand address expressions for memory operands in Y86: DISP(BASE), where DISP is an optional constant displacement of the base address, and BASE is a named register (one of the 15 Y86 registers).
- The address expression DISP(BASE) is used to compute the effective memory address for a memory operand
- The effective address is calculated by adding the value of the base register (BASE) to the displacement (DISP)
- The result is the memory address where the operand is stored or fetched
Be sure you understand how the 4 ALU instructions in Y86 work?
They all use two register operands: addq, subq, andq, xorq.
addq: R[rB] + R[rA]
subq: R[rB] - R[rA]
andq: R[rB] & R[rA]
xorq: R[rB] ^ R[rA]
Be sure you understand how Y86 ALU instructions set the 3 flags (And that other types of instructions besides ALU instructions in Y86 do not affect the flags).
ZF: Set if the result of the last ALU operation is 0.
SF: Set if the result of the last ALU operation has an msb of 1.
OF: set if the result of the last ALU resulted in signed overflow (where the last 2 carries are different)
ONLY ALU instruction write/change the flags. Data movement and control flow of instructions NEVER change the flags
Be sure you understand the unconditional jump instruction in Y86: jmp.
jmp is an unconditional jump instruction, meaning it jumps regardless of flag settings
Be sure you understand the conditional jump instructions in Y86, and how the flags must be set for the jump to be taken to the target address for each type of unconditional jump: je, jne, jl, jle, jg, jge.
je: ZF=1 (dest if last result is 0)
jne: ZF = 0 (dest if last result is not 0)
jl: SF =1 AND ZF = 0 (dest if last result < 0)
jle: SF=1 OR ZF=1 (dest if last result <= 0)
jg: SF = 0 AND ZF =0 (dest if last result > 0)
jge: SF =0 OR ZF =1 (dest if last result >=0)
if the last result is not what is specified, then the jump is NOT taken; in that case, the next sequential instruction is executed (PC= PC + jump instruction size)
What does it mean to say a jump (or branch) is taken in Y86?
The next instruction is the instruction at the address of the target label.
What does it mean to say that a jump (or branch) is not taken?
The next instruction executed will be the instruction immediately after the jump (or branch) instruction
What are labels in Y86?
Strings that mark addresses in memory. The assembler converts the label to the corresponding address, so the CPU does not see the label; it only sees addresses
What two things does the call instruction in Y86 do (Be sure to pay attention to the order in which these two things are done)? Be sure you can say, after a call instruction is executed, what address will be in the PC. Also be sure you can say what return address was pushed onto the stack by the call instruction.
1) push the return address (the address of next instruction after the call instruction) on the stack and
2) write the address of the Dest label to the PC, so the Dest function’s code will execute next
What two things does the ret instruction in Y86 do (Be sure to pay attention to the order in which these two things are done)
1) pop the return address from the stack
2) writes it to the PC
What is the portion of the stack that each subroutine (function/procedure/method) is given to use called?
A frame