1
votes

say I've got 4 labels, label1, label2, label3, and label4 in assembly language. Each of them refers to the byte stored at some memory location in data memory.

How can I perform an operation where label4 = label1 + label2 + label3

Just starting to learn assembly language, so please explain everything step by step! Thank you :)

1
A decent assembly language tutorial should teach you everything you need to know. Try writing some code, and we will be better able to help you if you only ask about a small portion of your code.Kendall Frey

1 Answers

1
votes

You would not be able to assign anything to label4! The addition could easily be done with code like this :

mov ax,label1
add ax,label2
add ax,label3

If you wanted to position the label4 (at compile time) at the spot label1+label2+label3 then you might do this with an ALIGN directive.

ORG 0
nop
label1: db 8
nop
label2: db 9
nop
label3: db -4
ALIGN label1+label2+label3
label4: db 45

Label4 now is placed at offset 9 (=1+3+5)