flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Help with 'repeat' directive |
Author |
|
Nistix 13 Jul 2017, 21:56
Found beautiful solution!
Code: ; Input ; eax dword for print ; rdi buffer PrintToBufferDwordHex: push rdx mov edx,eax rept 8 n:0 { rol eax,4 mov dl,al and dl,00Fh cmp dl,00Ah jb @f add dl,7 @@: add dl,'0' mov [rdi+n],dl } pop rdx ret |
|||
13 Jul 2017, 21:56 |
|
DimonSoft 16 Jul 2017, 09:09
Nistix wrote: Found beautiful solution! Why not just use plain assembler loops? 8 times more code might in most cases be worse than a small loop. |
|||
16 Jul 2017, 09:09 |
|
Nistix 16 Jul 2017, 16:04
DimonSoft wrote:
Yes, you are right. I had make this optimized code: Code: ; Input ; eax dword for print ; rdi buffer PrintToBufferHexDWord: push rcx rdx mov ecx,8 align 16 .char: shl rdx,8 mov dl,al and dl,00Fh cmp dl,00Ah jb @f add dl,'A'-'9'-1 ; 7 @@: add dl,'0' ror eax,4 loop .char mov [rdi],rdx pop rdx rcx ret It works fine |
|||
16 Jul 2017, 16:04 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.