How do i take a dec. number and get the oct. equivlent? I got the hex number using wsprintf, can i do the same here?
Posted on 2001-04-01 15:29:00 by HeroInc
Nope wsprintf does a lot less then one might expect :) (at least i have not been able to make it do it :( ) for example i have not been able to do : "Test string:%s for:%lu times" Octal is just getting 3 bits a a time and converting them as decimal numbers :) i guess you have to make a routine that will do just that :) for example : 1001.1010 binary is 9A hexa and 10.011.010 is 232 octal ... same number the easy way to do that is: make and vector containing the octal digits in ASCII form: octal2ascii_table db "01234567" then index into this table using only the lower 3 bits mov ebx, and ebx,011b add ebx,offset octal2ascii_table mov eax, call "whatever function you have to print a single char(eax)" ;second digit mov ebx, shr ebx,3 ; loose first 3 bits ;same as digit 1 above here and ebx,011b add ebx,offset octal2ascii_table mov eax, call "whatever function you have to print a single char(eax)" ;digit 3 mov ebx, shr ebx,6 ; loose first 6 bits ;same as digit 1 above here and ebx,011b add ebx,offset octal2ascii_table mov eax, call "whatever function you have to print a single char(eax)" you have to replace: "whatever function you have to print a single char(eax)" with a finction that takes and aschii code in eax and prints it on screen, or maybe adds it to a Zstring that is "TextOuted" later ...
Posted on 2001-04-01 15:58:00 by BogdanOntanu
Here's a somewhat cleaner (but probably slower) routine: HexToOct proc uses edi edx ecx String: DWORD ; EAX has number mov edi,String xor ecx,ecx HO1: mov edx,eax and edx,7 shr eax,3 add edx,30h ; '0' push edx inc ecx cmp eax,0 jnz HO1 HO2: pop eax stosb dec ecx loop HO2 xor al,al stosb ret HexToOct endp This message was edited by Racso, on 4/1/2001 4:53:50 PM
Posted on 2001-04-01 16:17:00 by Racso