flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly
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.
|
|||
![]() |
|
Overflowz
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. |
|||
![]() |
|
AsmGuru62
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 |
|||
![]() |
|
Overflowz
AsmGuru62
.......... HOW I FORGOT ABOUT STACK! I feel like a dumbass right now. Thank you, AsmGuru62! |
|||
![]() |
|
AsmGuru62
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. |
|||
![]() |
|
baldr
AsmGuru62 wrote: If you're coding for your own OS, then probably, you should add CLD at the beginning of that procedure. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.