![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
After division, DX contains the remainder. In this case, DX holds the digit we just sliced off. Earlier I posted how the division works:
123 / 10 AX = 12 DX = 3 12 / 10 AX = 1 DX = 2 1 / 10 AX = 0 DX = 1
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#22 |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
nicely explain Narue u have taught me alot in this thread alone and i can't think of anyway to thank you.................THANK YOU
|
|
|
|
|
|
#23 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
hey Narue was just playing around with the code and when i change it to something like this: you don't get an ouput...... is like as if the save variable is blank?....................why is this.
Quote:
|
|
|
|
|
|
|
#24 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
jnz relies on test to set the flags properly for the loop. dec also modifies flags, so if you move dec after test, jnz uses the result of dec as the loop condition. The reason it doesn't print anything is because save is initialized to DOS string terminators (the '$' character). When DI is 1, it's decremented to 0 and jnz is false, so the loop ends before filling in the first character of save. Since the first character is still '$', it's technically an empty string.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#25 |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
oh ok...............that makes sense.............nicely explained again............your pretty advanced at this langauge do you do as a career Narue?
|
|
|
|
|
|
#26 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
try playing around with this code even more but this time the DOS window just freezes when ever i run this program, here is the code:
Quote:
|
|
|
|
|
|
|
#27 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>jmp calc
There's no need for this unless you're jumping over something. Since calc is the next thing in the source, execution will fall through to it without your help. >jnz calc jne would make your intentions more obvious. >add save,10 This doesn't make sense. >mov al,00 You forgot the int 21h to terminate your program. One big issue is the infinite loop you're going to cause by entering strings longer than two characters. Since you test the loop condition at the bottom, after you copy to save, entering something like 123 will actually cause '1', '2', 3', 10 to be written to memory. That erases the last '$', and 09h will just keep going until it finds a '$' somewhere else in memory. So you need to use a top testing loop to avoid writing the carriage return to save: save db 4 dup '$'
start:
mov di,0
calc:
mov ah,01
int 21h
cmp al,13 ; Test for CR first
je show
mov [save+di],al
inc di
jmp calc
show:
mov ah,02h
mov dl,10
int 21h
; Display the result
mov ah,09h
mov dx,save
int 21h
fini:
mov ah,4CH
mov al,0
int 21hsave db 4 dup '$'
start:
mov di,0
jmp compare
calc:
mov [save+di],al
inc di
compare:
mov ah,01
int 21h
cmp al,13
jne calc
show:
mov ah,02h
mov dl,10
int 21h
; Display the result
mov ah,09h
mov dx,save
int 21h
fini:
mov ah,4CH
mov al,0
int 21h>do you do as a career Narue? I'm a professional programmer, yes. I tend to use assembly more than many programmers, but most of my work is in C and C++.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#28 |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
okay i see my mistake................but what if i wanted to add a number to whats inside the save variable that's what the "add save,10" was for
|
|
|
|
|
|
#29 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>but what if i wanted to add a number to whats inside the save variable
You access the memory just like you did when you copied the character in the first place: add [save+index],value
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#30 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
i Hav tried to run the following code:
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|