0

I am being asked to write a code that multiply 2 inputs from the user in Marie's assembly . I did everything right except that in the question there is a condition in pseudocode that I cannot quite imply in my code .. if x =0 then x=x+3 which means if the first input is zero I need to increment x by 3 . my original multiplication code works and this is it:

ORG 512
Input
Store x
Input
Store y
loop,Load z
 Add x
 Store z
 Load y
 Subt one
 Store y
 Skipcond 400
 Jump loop
Load z
Output
Halt
x, DEC 0
y, DEC 0
one, DEC 1
z, DEC 0

this code works for any x or y to multiply yet I cannot implement the condition above even though I tried this

ORG 512
Input
Store x
Skipcond 800   /in case of input x to 0
Add one    /adding one to x to reach 1
Add one     /adding one to x to reach 2
Add one      /adding one to x to reach 3
Store x
Input
Store y
loop,Load z
   Add x
   Store z
   Load y
   Subt one
   Store y
   Skipcond 400
   Jump loop
Load z
Output
Halt
x, DEC 0
y, DEC 0
one, DEC 1
z, DEC 0

but this messes up when I put both x and y as positives and it gives strange answer to multiplication .

Jeenzoo KT
  • 1
  • 1
  • 3
  • `Skipcond` as the name implies only skips one instruction. You normally put a `Jump` after it and use the reversed condition. (Edit: I see you know this because you used such a construct in the loop.) So you want something like `Skipcond 400; Jump input_y` where `input_y` is a new label on the line with the second `Input`. – Jester Dec 05 '21 at 14:42
  • demonstration please? – Jeenzoo KT Dec 05 '21 at 15:12

0 Answers0