hi,
I have to do a task and i have to write an assembly lanuage program to read in a series of pairs of numbers and for each pair output the sum and the difference. That's my code already pls help i have no idea:

    BR          main       ; Branch around data 

sum: .WORD 0x0000
num1: .BLOCK 2 ; Set up a block for num1
num2: .BLOCK 2 ; Set up a block for num2
msg1: .ASCII " Enter two numbers : \x00"
msg2: .ASCII " The sum is :\x00"
msg3: .ASCII " The difference is :\x00"
letter: .BLOCK 1

main: LDA num1,d
LDA num2,d

while:STRO msg1,d
DECI num1,d ; Read and store num1
ADDA num1,d
DECI num2,d ; Read and store num2
ADDA num2,d
;output the sum
STRO msg2,d
STA sum,d ; Store the sum
DECO sum,d ; output sum
; output the difeerence
STRO msg3,d
SUBA num2,d
BR while
BREQ quit

quit: STOP ; Stop the processing
.END ; End of the program

While I do and did write too much assembly language long ago, I've always had to tell those that I want help from what CPU this is for.
In the case of a PC I might have to write that I'll be using BIOS calls for string I/O. But you didn't reveal that so on with a comment how I go from a probem statement to code.

It's a few steps. Mostly trying to write out each step. Like this.

  1. Input a number.
  2. Input a second number.
  3. calculate this.
  4. calculate that.

Notice we try to break it down in small steps that get us to bite size coding. If we have a step that encompasse too much we break it down again.

This article has been dead for over six months. Start a new discussion instead.