90 likes | 278 Views
Sample exam questions. ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides4-1Quiz.ppt Modification date: March 20, 2014. 1. Write a suitable assembly language/machine instruction sequence to implement the high level code sequence: do { a = a + b; b++;
E N D
Sample exam questions ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides4-1Quiz.ppt Modification date: March 20, 2014
1. Write a suitable assembly language/machine instruction sequence to implement the high level code sequence: do { a = a + b; b++; } while (b < 100); assuming a load/store architecture. Variables aand bare declared as integers and are held in processor registers R1, andR2, respectively. Use any hypothetical but reasonable assembly language. Provide comments.
2. A processor uses a condition code register approach for branch instructions. Write an assembly language sequence for the C/Java code: do { a = a - 2; } while ((a < b) || (a > 0)); assuming that the variables aandbare assigned to registersR1and R2respectively. Provide comments. Use any reasonable hypothetical instructions. (Note || is the symbol for the logical OR operation.)
3. Write a suitable assembly language sequence to implement the high level code sequence: if (x > 10) a[x] = a[x + 1]; assuming a load/store architecture with only two instructions to access memory, load a register from memory (LD) and store a register into memory (ST) and both using register indirect addressing plus offset. There are 32 registers R0 - R31. Register R0 holds zero permanently. The array a is declared as a character array and stored in memory starting at location 100, and x is held in register R2. Make any necessary assumptions but state them. Use any reasonable assembly language and provide comments.
4. Write a suitable assembly language sequence to implement the C/Java code sequence: for (i = 0; i < 10; i++) a[x] = b[x]; assuming a load/store architecture -- Load (LD, LB), and store (ST, SB) to access memory using register indirect addressing plus offset. There are 32 registers R0 - R31. Register R0 holds zero permanently. Arrays a and b are declared as character arrays and stored in memory starting at memory addresses 100 and 200 respectively. The variable i is held in register R1, and the variable x is held in register R2. Make any necessary assumptions but state them. Use any reasonable assembly language and provide comments.