Assembly code snippets
Details
Title | Unsigned 64bit interger to dec ASCIIZ without MMX |
---|---|
Author | The Svin |
Submitted by: | The Svin |
Date added: | 2002-02-20 06:04:44 |
Date modified: | 2002-02-20 15:26:03 |
Comments
Title explains everything.
Format for m32lib
Snippet
.586
.model flat, stdcall
option casemap:none
.code
uqw2a proc uses ebx esi edi lBuffer,lQword
LOCAL num18:QWORD
mov esi,lQword
mov edi,lBuffer
mov edx,[esi]
mov eax,[esi+4]
N19H equ 0DE0B6B3h
N19L equ 0A7640000h
N20H equ 8AC72304h
N20L equ 89E80000h
cmp eax,N19H
jc C18
jne C20
cmp edx,N19L
jc C18
C20: cmp eax,N20H
jc DO19
jne DO20
cmp edx,N20L
jc DO19
DO20: mov byte ptr [edi],'1'
sub edx,N20L
lea edi,[edi+1]
sbb eax,N20H
DO19: mov byte ptr [edi],'0'-1
@@: inc byte ptr [edi]
sub edx,N19L
sbb eax,N19H
jnc @B
add edx,N19L
adc eax,N19H
inc edi
C18: mov dword ptr num18,edx
mov dword ptr num18+4,eax
sub esp,10
fild num18
fbstp [esp]
xor esi,esi
@@:
pop eax
bswap eax
mov ebx,eax
mov ecx,eax
mov bl,bh
shr ecx,16
mov ah,al
shr bl,4
shr al,4
and bh,0fh
and ah,0fh
shl ebx,16
and eax,0FFFFh
mov edx,ecx
mov cl,ch
mov dh,dl
shr cl,4
shr dl,4
and ch,0fh
and dh,0fh
shl ecx,16
lea eax,[eax][ebx]+30303030h
lea edx,[edx][ecx]+30303030h
mov [edi+10],eax
mov [edi+14],edx
xor esi,1
lea edi,[edi-8]
jne @B
mov ah,byte ptr [esp]
add edi,16
mov al,ah
add esp,2
shr al,4
mov esi,lBuffer
and eax,0f0fh
or eax,3030h
mov word ptr [edi],ax
cmp edi,esi
mov byte ptr [edi+18],0
jne @P
mov ecx,-20
add edi,19
@@:
inc ecx
cmp byte ptr [edi][ecx],30h
je @B
mov eax,ecx
js @Zero
neg eax
add esi,eax
@@: mov al,byte ptr [edi][ecx]
mov byte ptr [esi][ecx],al
inc ecx
jne @B
@P: ret
@Zero:
mov byte ptr [esi+1],0
jmp @P
uqw2a endp
end
.model flat, stdcall
option casemap:none
.code
uqw2a proc uses ebx esi edi lBuffer,lQword
LOCAL num18:QWORD
mov esi,lQword
mov edi,lBuffer
mov edx,[esi]
mov eax,[esi+4]
N19H equ 0DE0B6B3h
N19L equ 0A7640000h
N20H equ 8AC72304h
N20L equ 89E80000h
cmp eax,N19H
jc C18
jne C20
cmp edx,N19L
jc C18
C20: cmp eax,N20H
jc DO19
jne DO20
cmp edx,N20L
jc DO19
DO20: mov byte ptr [edi],'1'
sub edx,N20L
lea edi,[edi+1]
sbb eax,N20H
DO19: mov byte ptr [edi],'0'-1
@@: inc byte ptr [edi]
sub edx,N19L
sbb eax,N19H
jnc @B
add edx,N19L
adc eax,N19H
inc edi
C18: mov dword ptr num18,edx
mov dword ptr num18+4,eax
sub esp,10
fild num18
fbstp [esp]
xor esi,esi
@@:
pop eax
bswap eax
mov ebx,eax
mov ecx,eax
mov bl,bh
shr ecx,16
mov ah,al
shr bl,4
shr al,4
and bh,0fh
and ah,0fh
shl ebx,16
and eax,0FFFFh
mov edx,ecx
mov cl,ch
mov dh,dl
shr cl,4
shr dl,4
and ch,0fh
and dh,0fh
shl ecx,16
lea eax,[eax][ebx]+30303030h
lea edx,[edx][ecx]+30303030h
mov [edi+10],eax
mov [edi+14],edx
xor esi,1
lea edi,[edi-8]
jne @B
mov ah,byte ptr [esp]
add edi,16
mov al,ah
add esp,2
shr al,4
mov esi,lBuffer
and eax,0f0fh
or eax,3030h
mov word ptr [edi],ax
cmp edi,esi
mov byte ptr [edi+18],0
jne @P
mov ecx,-20
add edi,19
@@:
inc ecx
cmp byte ptr [edi][ecx],30h
je @B
mov eax,ecx
js @Zero
neg eax
add esi,eax
@@: mov al,byte ptr [edi][ecx]
mov byte ptr [esi][ecx],al
inc ecx
jne @B
@P: ret
@Zero:
mov byte ptr [esi+1],0
jmp @P
uqw2a endp
end