Professional Documents
Culture Documents
-----
All operations are performed on an It uses set of general purpose registers (RO, 0
~ ed accumulator (AC) register. R1, R2 ...), one-;fllie most widely accepted operations are carried out on \he top of the
stack. (TOS). The operand, are Implicitly
madel1 far machine ardiitecture taday
E,,/ With one operand i~ citly In the
- 1p eclried on TOS.
~
✓
accumulator register minimi%es the
internal complexity of themachine
and allow for-;~ ructions/
□ Specifies all operands explicit
// Rl +- R2
.... - Here ADD con,i,h of onl
address field. It ha, th~
ode and no
f popp ing
above three types of organizations. Some the toptwo numbe rs from the sta ck, adding
- -
Each address field may specify a
~rocessor register ar a memory operand.
.,.
the stack.
Three address instructions
• Destination Address Source Address 1 Source Address 2
Three-address instrudion format
► ----
It has two address fields
---
Each address field may specify a processor register or a memory operand.
✓ 't)l1 ~ ~
► Example lnstrudion: ADD R 1, R2
MOV RI , R2
II RI
-
II RI
~
~
RI + R2
.,,.
R2
--
One address instructions
• Operand Address (S/ D)
One-address instrudion format
> It has only one address field. The operand specified in the instruction may be source
or destination, depending on instruction
> One address instrudions use a implied ACCUMULATOR (AC) register for all data
manipulation.
► Implied means that the CPU already know that one operand is in accumulator so there is no need to
specify it.
► In zero address instrudions Stefk is used. Also called stack based organization
► A stack based computer does not use an address field in the instructions (like ADD,
MUL)
► PUSH and POP instructions, however, need an address field to specify the operand
that communicate with stack.
■ -
SUB Rl, A, B //Rl ~M[A]-M[B] /
MUL R2, D, E
. - // !l2 ~ M[D] * M[E]
SUB R2, R2, F // R2 ~ R_2 -M[F]
-
MUL R2, R2, C
- -
// R2 ~ R2 * M[C]
-
✓ ADD&-1, ~1, ~2 //
- - -
Rl ~ Rl + R2
MUL
. R3, H,. K
~
// R3 ~ M[H] * M[K]
-
ADD R3, R3, G
- - -
// R3 ~ R3
-
+ M[G]
-
- -
DIV X, Rl, R3
,...
// M[X]~Rl /R3
XL * (D
~\ Qi ~' --B + C-11.-i- ~ E - _F}
____ ~e,))
using two-address instructions .~
:mffi1t!:
G +H*K
MOV .~ 1, A II Rl -- M[A]
\ SUB Rl,B II Rl -- Rl - M[B] V
"i) --s -
MOV ~2, D II R2 -- M[D]
MUL R2, E I I R2 -- RJ * M[E]
\
- -
SUB R2, F
. ""
MUL R2, C
.
- - -
II R2 -- R2 - M[F]
I I R2 -- R2 * M[C]
- ... ,, -
1''°:ADD1 ~, ~2 II R!-- Rl + R2
MOV R3, H I I R2_i -- M[H]
1)
.MUL R3, K
./
ADD ~3, ~
.
I I R3 ---
I I R3 -- R3 * M[K]
- -- R3 + M[G]
DIV Rl, R3 I I R1 -- R1 I R3
MOV X, Rl // M[X] -- Rl
J . .
x =
~ A - B Q\ C * (D * E - F) ~c
~L ~ - 1 ; ' P. ::... using one-address instructions JL)
G +H * K ✓ ~l, lffl~l\'H-
■ J
'Jc -
SUB B ll~ C ~ 'ic- M[B] MUL K II AC~ A~ * M[K]
STORE T II M[T] ~
~
ADD G 11 ~c~ ~
-
+~
LOAD D
-
II AC~ M[D]
~ ::>-
- - TORE Tl
-
·-
II M[Tl] ~ AC
- -
MUL E
SUB F II - -----
I I AC ~ AC * M[E]
AC~ A_s. - ,Mif]
-
r' LOAD T
DIV T1
,:,
-
II AC~ M[T]
AC~ AC I M[Tl]
II _.... -,..J -
MUL C II AC~ A.£.* M[_C] II M[X] ~ AC 1)
-
I I AC ~ AC + M[T]
STORE X
.,..
-
1\1 ADD T
,,.- - -
STORE T II M[T] ~ AC
~r
X - ---
A - B + C * (D * E - F)
-
~ using zero-address instructions
-
•
~ ovorso Polish Notation (Postfix }: A B - C ~ E * F .;.
,
*✓,
+ G H K "' + I
- •
~
PUSH A //T'3S - A ')
PUSH G //TOS - G V
PUSH B //Tos - B ;v
SUB //Tos - (A-B) ~
PUSH H //TOS - H)
PUSH K //TOS - K
PUSH C // TOS - cV MUL // TOS - (H* K) ✓
PUSH D //Tos - D,
ADD //Tos - (G+ (H * K) r-=)
PUSH E //Tos - E •
DIV // TOS - ((A-B)+(C* ((D* E)-F))/(G+(H* K)
MUL //TOS - (D' POP X // M[XJ - ros
PUSH F //Tos - F
SUB // TOS - ((D* E) -F)) Y
MUL // TOS - (C* ((D* E)-f)) ✓
ADD // TOS - ((A-B)+(C* ((D* E)- f)) /