CMPS-2240 Quiz-9 discussion ----------------- The average score on the quiz was 56% The high score was 85% Five students skipped the quiz. Two quizzes had no name. Only 7 students scored a C or above. You may try to improve your score by reading below and answering the questions you think you missed. If you do this, save answers in a file named: 2240/9/quiz9a.txt Due before class Monday. Most difficult questions: 8, 10, 2, 5 Easiest questions: 4, 1, 3, 6 Each question explained... 1. ------------------------------------------------------------------------- Write two statements only. Writing more than two statements shows that you found the answer online along with some other code, and you do not know which part of the code is the answer. 2. ------------------------------------------------------------------------- Remember that parts of the RAX, EAX, AX, AH, AL registers overlap. Placing a value in one register can change another register. 3. ------------------------------------------------------------------------- x86 registers have the same size across platforms and CPUs. 4. ------------------------------------------------------------------------- Only one student missed this question, by not answering. 5. ------------------------------------------------------------------------- The pop function gets a value from the stack and changes the stack pointer. 6. ------------------------------------------------------------------------- A few careless errors here. Look at our documentation links. 7. ------------------------------------------------------------------------- This is well documented. 7/10 students answered correctly. 8. ------------------------------------------------------------------------- This was the most difficult question. We reviewed this instruction in lecture. It is a special instruction that you must read about. There is no instruction like this in MIPS. Here are some sources: What's the purpose of the LEA instruction? What is the difference between MOV and LEA? WikiBooks Load Effective Address calculates its src operand in the same way as the mov instruction does, but rather than loading the contents of that address into the dest operand, it loads the address itself. The lea instruction assumes the source operand is an address. An address can be any number from 0 to 232-1 or 248-1 . It's just a number. The lea instruction says, "give me that number." The lea instruction does not say, "go to that address in memory and get me the value." The code below was placed in my own lab9.asm program. Try it. section .rodata lea_test db "Result of lea. Should be 123. %ld",10,0 mov rbx, 123 ; put a value in rbx lea rcx, [rbx] ; move rbx to rcx mov rdi, dword lea_test ; printf 1st argument, format string mov rsi, rcx ; printf 2nd argument, value stored in rcx xor rax, rax ; required zero of rax call printf ; print 9. ------------------------------------------------------------------------- These instructions are in the .data segment. .rodata means read only data. There is no executable code here. 10. ------------------------------------------------------------------------- This was the second hardest question. Not sure why. It's an add instruction. add <destination>, <source> What is it adding the source number to? What is being used to determine the destination? Is an address being used? Where is the destination?