flat assembler
Message board for the users of flat assembler.
Index
> Windows > displaying hex-values Goto page Previous 1, 2, 3 |
Author |
|
Ali.Z 30 Jun 2018, 15:57
ok seems to be important to clear DF
"When the DF flag is set to 0, string operations increment the index registers" esi/edi :: BUT when i debugged my flag using olly, it shows the DF was already '0' maybe i can get rid of cld? |
|||
30 Jun 2018, 15:57 |
|
DimonSoft 30 Jun 2018, 22:51
Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.
|
|||
30 Jun 2018, 22:51 |
|
revolution 30 Jun 2018, 22:55
Ali.A wrote: ok seems to be important to clear DF |
|||
30 Jun 2018, 22:55 |
|
Ali.Z 01 Jul 2018, 09:42
meant debugged my program* lol
anyhow, thanks for the info rev. |
|||
01 Jul 2018, 09:42 |
|
Picnic 02 Jul 2018, 08:42
Ali.A wrote: damn, i feel like im a dummmmmm. Nice job Ali.A. lodsb also advances the esi pointer, that's why you don't have to add an extra: add esi,1. Quote:
revolution gave the answer for this. I guess i gained some good habits from the forum. |
|||
02 Jul 2018, 08:42 |
|
Ali.Z 09 Apr 2019, 22:06
back to this old thread, but with something different to ask.
previously you guys helped me to convert ascii to int and int to ascii both in hex form. now i want to convert int to ascii in decimal form, BUT without fixed point aritmetic nor div or mul instructions. is that doable? (again i dont know anything related to math, the only thing im good at is basic addition and subtraction lol) ... (even in real life) _________________ Asm For Wise Humans |
|||
09 Apr 2019, 22:06 |
|
revolution 10 Apr 2019, 02:28
Division can be emulated by using repeated subtraction. Multiplication can be emulated by repeated addition.
4 * 5 ===> 5 + 5 + 5 + 5 17 / 3 ===> 17 - 3 - 3 - 3 - 3 - 3 The basic operation for decimal conversion is division by powers of 10. So you can make code to go the "long way around" and just keep subtracting powers of 10 instead of using DIV (or the equivalent MUL by 1/10). |
|||
10 Apr 2019, 02:28 |
|
Ali.Z 10 Apr 2019, 12:09
so are you saying:
Code: ; target: convert register contents into decimal form to store as ascii decimal ; edx = 00001388 ; 5000 decimal convert: mov eax,edx .loop: sub eax,0Ah cmp eax,0Ah jnb .loop or eax,30h stosb shr edx,4 or edx,edx jnz convert ; ... but that not gonna work. _________________ Asm For Wise Humans |
|||
10 Apr 2019, 12:09 |
|
revolution 10 Apr 2019, 12:29
There are two main approaches.
1) work from the MSD down to the LSD, or 2) work from the LSD up to the MSD Let's work through approach 1 Code: A = input number ;(5000) call print_decimal exit print_decimal: B = 1000 ;(the MSD) call divide display C B = 100 call divide display C B = 10 call divide display C B = 1 call divide display C return divide: C = 0 loop: A = A - B if A < 0 then A = A + B return C else C = C + 1 goto loop |
|||
10 Apr 2019, 12:29 |
|
Ali.Z 10 Apr 2019, 16:18
its working, thank you.
Code: itoa: push ebx edi mov edx,[data] ; 5000 mov edi,[coords] ; buffer mov ebx,3E8h ; 1000 call .convert mov ebx,64h ; 100 call .convert mov ebx,0Ah ; 10 call .convert mov ebx,1 ; 1 call .convert pop edi ebx ret .convert: or ecx,-1 .loop: sub edx,ebx jns .greater_than add edx,ebx not ecx mov eax,ecx add eax,30h stosb ret .greater_than: loop .loop the problem is: i have to add more entries, for example mov ebx,2710h (10000 decimal) if i want to convert numbers above 9999. but for being time, its okay. (and mouse coordinates wont go above 9999 - probably) _________________ Asm For Wise Humans |
|||
10 Apr 2019, 16:18 |
|
revolution 10 Apr 2019, 17:28
Note that you can use decimal numbers directly in the source code:
Code: mov ebx,1000 ;decimal 1000 |
|||
10 Apr 2019, 17:28 |
|
Goto page Previous 1, 2, 3 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.