-3

I have to do a homework assignment in which the program will receive 2 numbers from the keyboard and add and multiply them, but I don’t know how. So far, I've done this:

  ORG    $1000
START: 
    LEA INPUT, A1               
    MOVE.B #14, D0
    TRAP #15
    
    MOVE.B #4, D0
    TRAP #15
            
    JSR SHOWNEWLINE
    
    LEA INPUT, A1              
    MOVE.B #14, D0
    TRAP #15
    
    MOVE.B #4, D0
    TRAP #15
    
    JSR SHOWNEWLINE

    ADDX D0, D0
    MOVE.B #14, D5
    TRAP #15
    
    SIMHALT
    
SHOWNEWLINE:
    LEA NEWLINE, A3
    MOVE.B #0, D1
    MOVE.B #0, D0
    TRAP #15
    RTS
    
INPUT DC.B 'Enter numbers', 0
NEWLINE DC.B ''    
  
    END START

It should be done in the EASy68K simulator.

Thank you!

Thomas Jager
  • 4,836
  • 2
  • 16
  • 30
mr99
  • 1
  • 2
  • 3
    Welcome to Stack Overflow. You'll have an easier time getting answered if you're more specific about the problem you have. – Thomas Jager Mar 11 '21 at 17:27
  • 1
    Note that you're immediately discarding the result of [trap task 4](http://www.easy68k.com/QuickStart/TrapTasks.htm) when you call `SHOWNEWLINE` which sets `D1` to 0. – Michael Mar 11 '21 at 17:29
  • 2
    What happens when you single step in the debugger? What is the first line that doesn't do what you want? Then work backwards from there to figure out why... – Erik Eidt Mar 11 '21 at 18:14

1 Answers1

0

My deadline was until midnight so I had to find a solution. Since it was not explained to us in the lecture how to use EASy86k, I tried to find help here. I hope this can help beginners.

    ORG    $1000
START: 
    LEA INPUT1, A1
    MOVE.B #14, D0
    MOVE.B #14, D1
    TRAP #15

    MOVE.B #4, D0
    TRAP #15

    MOVE.B D1, D2
            
    LEA INPUT2, A1 
    MOVE.B #14, D0
    MOVE.B #14, D1
    TRAP #15
              
    MOVE.B #4, D0
    TRAP #15

    MOVE.B D1, D3

    JSR SHOWNEWLINE

    LEA SUM, A1 
    MOVE.B #14, D0
    MOVE.B #14, D1
    TRAP #15

    MOVE.B D2, D4
    ADDX D3,D4
    MOVE.B D4, D1
    MOVE.B #3, D0
    TRAP #15

    JSR SHOWNEWLINE

    LEA MULTIPLICATION, A1 
    MOVE.B #14, D0
    MOVE.B #14, D1
    TRAP #15

    MOVE.B D2, D5
    MULS D3,D5
    MOVE.B D5, D1
    MOVE.B #3, D0
    TRAP #15

    SIMHALT

SHOWNEWLINE:
    LEA NEWLINE, A3
    MOVE.B #0, D1
    MOVE.B #0, D0
    TRAP #15
    RTS

INPUT1 DC.B 'Enter 1st number: ', 0
INPUT2 DC.B 'Enter 2nd number: ', 0
SUM DC.B 'Sum: ', 0
MULTIPLICATION DC.B 'Multiplication: ', 0
NEWLINE DC.B ''    

    END START
    
mr99
  • 1
  • 2