mr99
mr99

Reputation: 1

Adding in EASy86K

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!

Upvotes: -3

Views: 423

Answers (1)

mr99
mr99

Reputation: 1

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
    

Upvotes: 0

Related Questions