temporary_user_name
temporary_user_name

Reputation: 37098

Assembly Theory

We're working with assembly. I'm kind of lost. This is a practice question on a study guide:


Using 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=E+(A-C) – (B*E)

A. Can someone explain how those 4 different machine types differ in terms of the code? B. Can someone show me how to do one of the four as a place to start?

Upvotes: 1

Views: 298

Answers (1)

pät
pät

Reputation: 543

3-Addr. (Result and ops from memory)
mult b, b, e
sub  f, a, c
sub  f, f, b
add  f, e, f

2-Addr (Shared result and one op)
mult b, e
sub  a, c
load f, e
add  f, a
sub  f, b

1-Addr (Accu only)
lda  b
mult e
sta  b
lda  a
sub  c
sta  a
lda  e
add  a
sub  b
sta  f

0-Addr (Stack only)
push e
push a
push c
sub
add
push b
push e
mult
sub
pop f

Upvotes: 2

Related Questions