1. (70 points) Translate the high-level language code below into assembly instru
ID: 3748271 • Letter: 1
Question
1. (70 points) Translate the high-level language code below into assembly instructions. The variables A, B, C, D, E and F are located in the memory and can be accessed by their label (e.g., LOAD R1, A wil load A from the memory into R1). Minimize the number of instructions in the assembly code that you write F (A-C)*C/(E-D) -B Accumulator-All operations occur between a single register and a memory location * Memorv-memorv-All instruction addresses reference only memorv locations. Stack All operations occur on top of the stack. Push and pop are the only instructions that access memorv: all others remove their operands from the stack and replace them with the result. The implementation uses a hardwired stack for only the top two stack entries, which keeps the processor circuit very small and low cost. Additional stack positions are kept in memory locations, and accesses to these stack positions require memory references. Load-store All operations occur in registers, and register-to-register instructions have three register names per instruction. a) Write the code for an accumulator architecture b) Write the code for a stack architecture. Assume that the division (subtraction) operation divides (subtracts) the topmost value in the stack by the second topmost value. c) Write the code for a memory-memory architecture d) Write the code for a load-store architecture e) Compare the number of instructions and memory accesses of the different implementations in parts a, b, c and d.Explanation / Answer
a)
load E
sub D
store G
load A
sub C
mul C
div G
sub B
store F
b)
push A
push B
sub
push C
mul
push E
push D
sub
div
push B
sub
pop F
c)
sub G,A,C
mul H,G,C
sub I,E,D
div J,H,I
sub F,J,B
d)
load R1,&A
load R2,&B
load R3,&C
load R4,&D
load R5,&E
load R6,&F
sub R7,R1,R3
mul R8,R7,R3
sub R9,R5,R4
div R10,R8,R9
subR6,R10,R2
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.