|
Arithmetic
Hello all,
Im very very new to 8086 assembly and have an extremely basic knowledge
I would appreciate if anyone can tell me why when i perfom an arithmetic function on a value i get utter garbage back ??
I think i missing something very straight forward.. !!
For example
I have
GetNumber: ;initial start point
mov ax,0
mov temp,ax
lea dx, mess_prompt
@ ShowString
GNC: ;Get number and check
@ GetInput
cmp al,'0' ;was it zero
je zer
cmp al,'1' ;was it one
je one
cmp al,'2' ;was it two =
je two
cmp al,'3' ;was it three
je thr
cmp al,'4' ;was it four
je fou
cmp al,'5' ;was it five;;
je fiv
cmp al,'6' ;was it six
je six
cmp al,'7' ;was it seven
je sev
cmp al,'8' ;was it eight
je eig
cmp al,'9' ;was it nine
je nin
cmp al,01Bh ;Was it ESC (Used to stop infinate recursion)
je ExitToDos ;Quits
cmp al,13d ;evaluate to see if return was pressed =
je BigJump ;input is not complete
lea dx, Mess_ERROR ;Error handling
@ ShowString
@ GetNumber ;RESET INPUT
BigJump: ;jmp is out of bounds
@ Returning
zer:
;temp=temp*10+0
@ GNC
one:
@ GNC
two:
@ GNC
;------------------------------------------------
thr:
mov dl, offset temp
@ ShowChar ;DEBUG
;temp=temp*10+0
mov ax, temp
mul ten
mox temp2, ax
;xor ax,ax
;mov ax,10
;mul temp ;multiply temp x 10; (default is zero)
mov dl, offset temp
@ ShowChar ;DEBUG
;mov ax, temp2
;add ax, 3
;mov temp2, ax
;mov temp, temp2
;add temp,3 ;add 3 to temp and put result in temp
mov dl, offset temp
@ ShowChar ;DEBUG
@ GNC
;-------------------------------------------------
This as you guess is part of an inc file and @ just replaces call
GetInput is just a call to the O/s to get a char via the 21h interupt
All that should be happening in 3 (Which contains alot of failed attempts, but i leave them there until the program is complete as refrence) is take the intial value of temp, then times it by ten to shift it from units, to tens etc and add the current value I.e three so stacking the number up ready to return.
Please anybody help??
I really dont know where im going wrong , if i call upon the Value Temp it prints utter garbage, Do i have the data types wrong or something?
|