![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | ||
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
Quote:
Quote:
I am very confuse do you mind shedding some of your knowledge onto us(can u please explain) |
||
|
|
|
|
|
#12 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 3
![]() |
>but why did u put 2 in the di regester
Here's how the division algorithm works: 123 / 10 AX = 12 DX = 3 12 / 10 AX = 1 DX = 2 1 / 10 AX = 0 DX = 1 --0---1---2---3--
save: | | | |'$'|
-----------------
DX = '3'
DI = 2
--0---1---2---3--
save: | | |'3'|'$'|
-----------------
DX = '2'
DI = 1
--0---1---2---3--
save: | |'2'|'3'|'$'|
-----------------
DX = '1'
DI = 0
--0---1---2---3--
save: |'1'|'2'|'3'|'$'|
----------------- mov di,0
convert:
mov dx,0
div bx
add dx,'0'
mov [save+di],dl
inc di
test ax,ax
jnz convert
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#13 |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
so what are you doing or testing when you do
test ax,ax are you comparing ax to ax |
|
|
|
|
|
#14 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 3
![]() |
"test ax,ax" does the same thing as "cmp ax,0", but in a different way. In case you're curious, because at this point it doesn't really matter, cmp performs a subtraction and test performs a bitwise AND.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#15 |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
okay thanks but i still don't understand how you got the number stored backwards in the string save.
|
|
|
|
|
|
#16 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 3
![]() |
The division trick takes the least significant digit off each time, so the digits you get will be in 3,2,1 order rather than 1,2,3 order.
If you save each digit at the index specified by DI in 0,1,2 order, the string will be "321$". If you save each digit at the index specified by DI in 2,1,0 order, the string will be "123$".
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#17 |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
you taught me something new on every post just like to say thanks.........but when you do this
save db 4 dup '$' are you setting up a variable that can only store 4 characters? |
|
|
|
|
|
#18 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 3
![]() |
>save db 4 dup '$' are you setting up a variable that can only store 4 characters?
Kind of. It sets aside four bytes, initializes them to the $ character, and creates a label called "save" that refers to the memory address of the first byte. That's technically a variable in assembly, but it's important to know what's going on. You could also do this to the same effect:save: db '$' db '$' db '$' db '$' save: db '$$$$'
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#19 |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
okay narue another question why did you add a 0 to whats inside dx
add dx,'0' |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|