Hi guys, I am trying to compute the multiplication table for the number twelve, this is what I have so far.




.model small
.stack
.data

mensaje db 'Jan from Assembly kicking ass'
db 13,10, '$'

mensaje2 db 'Digite Una Letra'
db 13,10, '$'

mensaje3 db 'La letra fue' , '$'

mensaje4 db 'Y ahora aqui esta la tabla del 5'
db 13,10, '$'


.code

Inicio:


mov ax, @data
mov ds, ax


mov dx, offset mensaje

mov ah, 09
int 21h


mov dx, offset mensaje2
int 21h

mov ax, 01h ;I am just inputting here for the hell of it.
int 16h

mov bl, al

mov dx, offset mensaje3

mov ah, 09
int 21h

mov dl, bl

mov ah, 02
int 21h


mov dx, offset mensaje4
mov ah, 09
int 21h

mov cx, 12

tabla:
mov ax, 12
mov bx, cx ;bx=12, bx=11

mul bx

mov dx, ax

mov ah, 02
int 21h


loop tabla


mov ah, 4ch
int 21h


end Inicio



Alright what I am trying to do is print out the multiplication table for the number 12, what I do is that I start CX, at 12 and then move that number to bx, and do mul on bx (which unless I am reading the manual wrong, it multiplyes whatever is on AX with the source) this being BX, So Mul Bx= would be 144 on the first run. And then this value is store in DX:AX (now I don't know what the hell this means here), so I am guess this says that the value is stored in either dx or ax. So I move whatever I have on Ax, To Dx to display it on the screen. CX is decreased and the moved to bx, and we do this 12 times. Needless is to say that this thing is not working correctly. Please help

This is the output I get for the multiplication

??xl`TH<0$??

Thanks in advance
Posted on 2004-06-13 21:19:21 by incognito
DX:AX means that the high word is stored in DX and the low word in AX. You don't need to move the multiplicand into BX, as MUL will work on any general register. However, you don't need the MUL at all since you could instead subtract 12 from the previous result on every iteration.
Function 2 prints one character to the screen. Therefore you must call this multiple times with different characters to print the entire number to the screen. The ASCII codes for the digits 0-9 are 48-57. You have to build up the string backwards by successive divisions by 10 before it can be displayed, therefore I suggest you use function 9 in the end to print it.
Btw, instead of using mov dx,ax you should use xchg dx,ax as this is an 1 byte instruction.
Posted on 2004-06-14 07:30:11 by Sephiroth3
Thanks, I when I look at it ? is ascii for 144, so it seems to be right.......a function to print this as a number and not as a character, what function would do this for me?
Posted on 2004-06-15 14:25:52 by incognito
This could work:


mov di,offset str
mov si,di
push di
@@:
xor dx,dx
div word ptr [denominator]
xchg dx,ax
add al,'0'
stosb ; Store remainder.
xchg dx,ax
test ax,ax
jnz @B
mov [di],'$'
@@:
lodsb ; Reverse the digits.
xchg [di-1],al
mov [si-1],al
dec di
cmp si,di
jb @B
pop dx
mov ah,9
int 33 ; DOS Print string
...
denominator dw 10
.data?
str db 6 dup (?)
Posted on 2004-06-15 15:47:34 by Sephiroth3