Lecture Practice Quiz 3 Be prepared to answer questions similar to the following; Assuming that execution begins at address 000, what value will the accumulator (acc) contain when each of the machine language programs executes a HALT instruction. (If the answers are not obvious, execute the programs with the "sim1.c" simulator.) 1. In machine language, instructions can be used as data (usually a bad idea). 000 1000 001 3001 002 0000 000 2. The SIM memory words have no place for a + or - sign. However, numbers between 5000 and 9999 can be interpreted as negative numbers. If we were using the signed interpretation, how should the number 9999 be interpreted? 000 1003 001 4004 002 0000 003 0050 004 0051 000 3. Program 3. 000 5002 001 2012 002 1012 003 3012 004 2012 005 1012 006 3012 007 2012 008 1012 009 3012 010 2012 000 4. Even short programs can be very confusing. 000 5002 001 3000 002 4002 003 2004 004 0000 005 0000 000 5. As program 2 illustrated, the number 9999 can play the role of -1 in the SIM1 machine language. The ADD instruction is implemented with the following code. 10 case ADD: acc = acc + memory[digit234]; if (acc > WORDLIMIT) /* wrap if acc > 9999 */ acc = acc - (WORDLIMIT + 1); /* by subtracting 10,000 */ break; As a result: 1 + 9999 = 0 2 + 9999 = 1 20 + 9999 = 19 500 + 9999 = 499 a. What number would play the role of -10 (so that adding this number to, for example, 50 would yield 40). (Hint - if you drove a new car backwards for a mile, the odometer (if it is mechanical) would go backwards from 000000 to 999999. What would happen if you went backwards for 10 miles?). b. Can you give a simple formula for taking the negative of any SIM1 number between 1 and 4999. c. What happens if you apply the same formula to numbers between 5001 and 9999? 6. Write assembly language programs equivalent to four machine language programs above.