1. Using are hypothetical machines (3-address, 2-address, 1-address and 0-addres
ID: 3864238 • Letter: 1
Question
1. Using are hypothetical machines (3-address, 2-address, 1-address and 0-address) and the following commands:
load= puts value in address
add = +
mult = *
sub = -
lda=load in accumulator
sta = loads from accumulator to memory
push=copies to the stack
pop=copies from the stack
Show for each machine the instructions to perform the following task:
F=F+(A-C) – (B*E)
2. In DEBUG.
a. Execute the following command:
e 100 2c 3a 4e 51
Use the A command to enter the following program:
mov ch, [101]
mov bl, [100]
inc bx
mov ax, [102]
inc ax
nop
Execute the program using the T command.
b. Show the final values of ax, bx and cx. Explain in detail how each arrived at their particular values.
3. Get into DEBUG and enter the following assembly language instructions using the A command:
mov ax, -10
mov bh, -33
mov bl –16
nop
Run the program using the T command.
Notice the value placed in AX. How was that hexadecimal value arrived at?
4. PROGRAM Write an 80x86 assembly language program in a file, hw5.asm, that will read from memory a positive integer value and sum up the positive integer values to that value and including that value. Assume that the sum will be less than 255.
num1 BYTE 13
totall BYTE ?
After your program executes the value in totall should be 1+2+3+4+5+6+7+8+9+10+11+12+13=91
Explanation / Answer
1.
F=F+(A-C) – (B*E)
Three address code:
SUB X, A, C # X <- A - C
ADD F, F, X # F <- F + X
MPY Y, B, E # Y <- B * E
SUB F, F, Y # F <- F - Y
Two address code:
MOV F, A # F <- A
SUB F, C # F <- F - C
ADD F, F # F <- F + F
MOV T, B #T <- B
MPY T,E #T <- T * E
SUB F,T #F <- F - T
One address code:
LOAD B
MPY E
STOR F
LOAD A
SUB C
ADD F
STOR F
Stack (0 address code)
Push F
Push A
Push C
MULT
ADD
Push B
Push E
MULT
SUB
Pop F
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.