Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Assembly (http://www.programmingforums.org/forum20.html)
-   -   Arithmetic (http://www.programmingforums.org/showthread.php?t=7879)

CodeJunkie Jan 8th, 2006 9:22 AM

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?

CodeJunkie Jan 8th, 2006 11:29 AM

This is my 4th post with out any replys... Am i asking stupid questions?
Or am i frozen out of the communtiy or something??

andro Jan 8th, 2006 2:28 PM

I just don't think anybody has been able to answer you so far. Much better, in my opinion, than 4 or 5 posts with people going
"well i don't really know, but.."

or

"try this.. <insert obviously wrong answer>"

and

"so from what i understand you're trying to launch a rocket to the moon using assembly and writing your own OS right?"


If somebody who read this post knew the answer, they would be happy to respond.


All times are GMT -5. The time now is 4:05 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC