0

I'm trying to create a program in iJVM using a .jas file with a MIC-1 ASSEMBLER to input two numbers by keyboard and multiply them together to get an out put EX: 2*2=4

In the code below I just bipushed random numbers because when i used 'in' to get input it wasn't giving me an input

When I bipush 7 and bipush 2 just in main without a method the output is: EX: Input x: 20 Input y: 2

I get the ascii digit so Im assuming its taking hex 0x20 and 0x02 and multiplying that to get 0x40 and outputting the ascii character

.main
.var
x
y
sum
.end-var
    BIPUSH  7
    ISTORE  x
    BIPUSH  5
    ISTORE  y
    BIPUSH  0x40
    INVOKEVIRTUAL   imul
    out


.end-main

.method imul(x,y)
.var
x
y
temp
sum
.end-var    
    BIPUSH  2
    ISTORE  x
    BIPUSH  20
    ISTORE  y
L1: 
    BIPUSH  0
    ISTORE  sum
    GOTO    L2

L2: ILOAD   y
    IFEQ    exit

    POP
    ILOAD   x
    DUP
    IADD
    ISTORE  temp
    GOTO    L3

L3: ILOAD   y
    BIPUSH  2
    ISUB
    ISTORE  y
    GOTO    L4

L4: ILOAD   temp
    ILOAD   sum
    IADD
    ISTORE  sum
    GOTO    L2

exit:   ILOAD   sum
    IRETURN

.end-method
  • What's your question? – Ken White Apr 05 '19 at 02:11
  • @KenWhite I'm trying to get get the user in a MIC-1 SIMULATOR to enter two numbers & multiply those two numbers and output them back – Austin Simpson Apr 05 '19 at 03:11
  • Yep. Got that from your explanation in the question. What I didn't (and still don't) see is a question that you're asking us to answer for you. This is a *question and answer* site, which means that before we can provide an answer, you first must clearly explain a problem and ask a specific question. We can't do our part until you've completed yours. :-) – Ken White Apr 05 '19 at 16:32

0 Answers0