Systems
elements such as
integers,
Floating point numbers, and
character strings
Answer
At least 19 bits are required to access each bit
of the word. (This is because 215 = 32K and 24
=16)
Three-address instruction
The general form of a three address
A, B , C;
C<-A*B
A, B , C ; C < - A + B
R1, R2, R3 ; R3 <- R1 - R2
Code Challenge
Z = A * B + C * D - E * F*G.
R1 <- A*B
R2 <- C*D
R1 <- R1+R2
R3 <- E*F
R3<-R3*G
Z <- R1-R3
MUL
MUL
MUL
MUL
ADD
SUB
A, B , R1 ; R1 <- A * B
C, D, R2 ; R2 <- C * D
E, F, R3 ; R3 <- E * F
R3, G, R3 ;
R3 <- R3*G
R1, R2, R1 ; R1 <- R1 + R2
R1, R3, Z ;
Z <- R1 - R3
Two-address instruction
If we drop the third address from the three-
Answer
MOV
MUL
MOV
MUL
MOV
MUL
MUL
ADD
SUB
MOV
A, R1 ; R1 <- A
B, R1 ; R1 <- R1 * B
C , R2 ; R2 <- C
D, R2 ; R2 <- R2 * D
E , R3 ; R3 <- E
F, R3 ; R3 <- R3 * F
F, R3 ; R3 <- R3 * G
R2, R1 ;
R1 <- R1 + R2
R3, R1 ;
R1 <- R1 - R3
R1, Z ; Z <- R1
One-address
This register always holds one of the source
operands.
Thus, we only need to specify one address in
the instruction, and therefore, this idea
reduces the instruction length. The oneaddress format is predominant in 8-bit
microprocessors.
Some typical one-address instructions are
LDA
ADD
MUL
STA
B;
C;
D;
E;
Acc <- B
Acc<- Acc+ C
Acc <- Acc * D
E <- Acc
Answer
LDA
E ; Acc <- E
MUL F ;
Acc <- Acc * F
MUL F ;
Acc <- Acc * G
STA T1 ; T1 <- Acc
LDA
C ; Acc <- C
MUL D ; Acc <- Acc * D
STA T2 ; T2 <- Acc
LDA
A ;Acc <- A
MUL B ; AcC <- Acc * B
ADD T2 ; Acc <- Acc +T2
SUB
T1 ; Acc <- Acc - T1
STA Z ; Z <- Acc
Assignment
Use zero-address arithmetic instructions to
Hint: Stack