Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Really need help with Marie assembly language project

Hello, I'm a new programmer and am stuck on this problem z<- (ab) * (cd) , and you have to use a subroutine. I'm having trouble understanding how to do it with one subroutine, so I have 3 in my program, but would like to get it down to one. If anyone could help me I would be extremeley grateful, my code is below

input
store a
output
input
store b
output
input
store c
output
input
store d
output

load a
store temp1
load b
store temp2
JnS Multiply

load c
store temp3
load d
store temp4
JnS Multiply2

load temp1
output
load temp2
output
load temp3
output
load temp4
output

Jns FinalMultiply

HALT

Multiply, hex 0000
Loop, load temp1
add temp1
output
store temp1
output
load temp2
output
subt one
store temp2
skipcond 400
Jump Loop
JumpI Multiply

Multiply2, hex 0001
Loopy, load temp3
add temp3
output
store temp3
output
load temp4
output
subt one
store temp4
skipcond 400
Jump Loopy
JumpI Multiply2

FinalMultiply, hex 3

temp1, dec 0
temp2, dec 0
temp3, dec 0
temp4, dec 0

a, dec 0
b, dec 0
c, dec 0
d, dec 0
zero, dec 0
one, dec 1

Sign In or Register to comment.