YYYEJI

[CS] Example for Operand 본문

Computer architectures

[CS] Example for Operand

YEJI ⍢ 2022. 9. 19. 21:15
728x90

 

Let's find out about assembly language by solving the example below.

 

 

↓↓↓   Question   ↓↓↓

Implement the following expression with three-, two-, one-, and zero-operand instruction sequences.

Assume we have ADD and DIV instruction.

 

Z = (A+B)/C

 

 

↓↓↓   Solution   ↓↓↓

 

When 2 address,

Z = A

Z = Z + B

Z = Z/C = (A + B)/C

 

 

When 1 address,

AC = A

AC = AC(A) + B

AC = AC(A+B) / C

 

 

 

↓↓↓   Answer   ↓↓↓

 

When 3 address,

ADD   Z, A, B

DIV     Z, Z, C

 

 

When 2 address,

MOV      Z, A

ADD      Z, B

DIV       Z, C

 

 

When 1 address,

LOAD     A

ADD        B

DIV         C

STORE   Z

 

 

When 0 address,

PUSH   A

PUSH   B

ADD        

PUSH   C

DIV         

POP      Z

 

 

 

 

◡̈

 

 

'Computer architectures' 카테고리의 다른 글

[CS] Exercise for Addressing Modes  (0) 2022.09.22
[CS] Addressing Modes  (0) 2022.09.21
[CS] Number of Operands  (0) 2022.09.19
[CS] Instruction 구성  (0) 2022.09.19
[CS] Special Purpose Registers  (0) 2022.09.19