flat assembler
Message board for the users of flat assembler.
Index
> Main > decimal to unicode |
Author |
|
LocoDelAssembly 21 Oct 2012, 23:18
Since the architecture is little-endian storing DX without any swapping should already provide the wide character you need, so search the forum for an IntToStr implementation and modify it to store DX instead of DL.
|
|||
21 Oct 2012, 23:18 |
|
Overflowz 21 Oct 2012, 23:33
You don't get me. I have e.g 123h decimal. When I'm converting to unicode, it must be written with big-endian.
if I get remainders first time 1, second time 2, and last time 3, it must be written as 3, 2 and 1. |
|||
21 Oct 2012, 23:33 |
|
AsmGuru62 22 Oct 2012, 04:05
This is possible solution:
Code: ; ; EAX = value to convert into string ; EDI = address of the UNICODE string buffer ; UInt32_to_UNICODE: pusha xor ebx, ebx ; EBX = 0 to count digits in result push 10 ; ECX = 10 pop ecx .divide_by_10: xor edx, edx div ecx add dl, '0' ; Store next digit into stack push edx inc ebx test eax, eax ; Is there more digits? jnz .divide_by_10 ; Yes. Go back for more. ; ; At this point stack has EBX digits stored. ; These must be put into buffer at EDI. ; mov ecx, ebx .save_result: pop eax stosw loop .save_result ; ; Terminate string with null ; mov [edi], cx popa ret |
|||
22 Oct 2012, 04:05 |
|
Overflowz 22 Oct 2012, 09:57
AsmGuru62
.......... HOW I FORGOT ABOUT STACK! I feel like a dumbass right now. Thank you, AsmGuru62! |
|||
22 Oct 2012, 09:57 |
|
AsmGuru62 22 Oct 2012, 14:27
This code assumes that Direction Flag is cleared, because for Win32 it is always cleared in User code.
If you're coding for your own OS, then probably, you should add CLD at the beginning of that procedure. |
|||
22 Oct 2012, 14:27 |
|
baldr 21 Nov 2012, 16:52
AsmGuru62 wrote: If you're coding for your own OS, then probably, you should add CLD at the beginning of that procedure. |
|||
21 Nov 2012, 16:52 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.