I've been looking at a tutorial that shows (http://www.decard.net/article.php?body=tajga&chapter=07) :

mov ax,5
mov bx,5
add bx,
add ax,bx
;here ax contains 15, bx contains 10
five dw 5

Where exactly is it stored? Am I so close I can't see the answer?

Thanks. (Sorry if this is in the wrong section.)
Posted on 2005-09-10 22:18:36 by ~Steve~

add destination, source  ;=destination+source
result is stored in destination
mov eax, 1 ;eax=1
add eax, 1 ;adds eax and 1 and stores it in eax so eax now=2

five dw 5

mov ax,5    ;ax=5
mov bx,5    ;bx=5
add bx, ;(bx+ mem pointed by )=5+5=10    bx=10
add ax,bx    ;5+10  now ax=15 and bx still contains 10
;here ax contains 15, bx contains 10
Posted on 2005-09-10 22:27:07 by Desp
Thank you, now I understand. :)


Actually, now I've run into another problem.. I want to print this value onto the screen. I've tried mov ah, 2 and mov ah, 9... Then, mov dx, ax. Is 'mov dx, ax' the problem? I've tried using variables, either it came out blank or garbled messages with system beeps.
Posted on 2005-09-10 22:31:51 by ~Steve~
You have to run the code under dos and not command prompt.
Posted on 2005-09-11 01:31:33 by roticv
Ah... that's why.. Guess I'll need to run an emu. Thank you. :)
Posted on 2005-09-11 10:54:38 by ~Steve~
Hrm, I've tried it under DOSBox emulator. It still doesn't want to print the result onto the screen. I can print other words and numbers, but not calculations. I guess it's something with my code.

This is my code:

org 256

mov ah, 9h

mov ax, 5
mov bx, 5

add ax, bx

mov dx, ax

int 21h

int 20h
Posted on 2005-09-11 15:07:29 by ~Steve~
erm, considering its int 21h, so old dos stuff, you need to set the al value to the setting you want from int 21h, im guessing it should be 09h... this must be set prior to the int 21h call.. try that.. should work then
Posted on 2005-09-11 17:07:07 by evlncrn8
I took a look at it even further. In order for a string to be displayed, it needs to have a '$' at the end. How would I add '$' to the end of ax without overwriting the content? (To be more clear, before moving ax into dx, ax should be '10$' and not just '10'.)
Posted on 2005-09-11 19:45:00 by ~Steve~
Quote from FASM's doc

"The numbers in the expression are by default treated as a decimal, binary numbers should have the b letter attached at the end, octal number should end with o letter, hexadecimal numbers should begin with 0x characters (like in C language) or with the $ character (like in Pascal language) or they should end with h letter."
Posted on 2005-09-11 20:52:20 by roticv
The number in AX is not in displayable form. You need to add code that generates a string (series of characters) in memory that represents the (binary) value stored in AX. AX is not memory, it is a register separate from memory. You add the '$' character after the string you create.
Posted on 2005-09-11 23:02:22 by tenkey