Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern __imp__MessageBoxA@16
- extern __imp__wsprintfA
- extern __imp__ExitProcess@4
- global start
- section .text
- putflagPlus:
- mov byte[flags], 1
- jz flag
- putflagMinus:
- mov byte[flags + 1], 1
- jz flag
- putflagHashCode:
- mov byte[flags + 2], 1
- jz flag
- putflagZero:
- mov byte[flags + 3], 1
- jz flag
- percent:
- inc esi
- cmp byte[esi], '+'
- jz putflagPlus
- cmp byte[esi], '-'
- jz putflagMinus
- cmp byte[esi], '#'
- jz putflagHashCode
- cmp byte[esi], '0'
- jz putflagZero
- mov edx, [esi]
- sub edx, 48
- cmp edx, 9
- jbe digit
- cmp byte[esi], '.'
- jz point
- cmp byte[esi], 'd'
- jz formatD
- cmp byte[esi], 'i'
- jz formatI
- cmp byte[esi], 'x'
- jz formatX
- cmp byte[esi], 's'
- jz formatS
- cmp byte[esi], 'c'
- jz formatC
- cmp byte[esi], 'h'
- jz lenh
- cmp byte[esi], 'l'
- jz lenl
- cmp byte[esi], 'L'
- jz lenL
- flag:
- inc esi
- jmp percent
- digit:
- mov ecx, 0
- mov edx, [esi]
- sub edx, 48
- cmp edx, 9
- jbe cycleDigit
- cycleDigit:
- mov [wid + ecx], edx
- inc ecx
- inc esi
- jmp digit
- cmp byte[esi], 'd'
- jz formatD
- cmp byte[esi], 'i'
- jz formatI
- cmp byte[esi], 'x'
- jz formatX
- cmp byte[esi], 's'
- jz formatS
- cmp byte[esi], 'c'
- jz formatC
- cmp byte[esi], 'h'
- jz lenh
- cmp byte[esi], 'l'
- jz lenl
- cmp byte[esi], 'L'
- jz lenL
- lenh:
- mov byte[lengths], 1
- inc esi
- jmp len
- lenL:
- mov byte[lengths + 1], 1
- inc esi
- jmp len
- lenl:
- mov byte[lengths + 2], 1
- inc esi
- jmp len
- len:
- cmp byte[esi], 'd'
- jz formatD
- cmp byte[esi], 'i'
- jz formatI
- cmp byte[esi], 'x'
- jz formatX
- cmp byte[esi], 's'
- jz formatS
- cmp byte[esi], 'c'
- jz formatC
- point:
- jmp toDigitPrecision
- toDigitPrecision:
- inc esi
- mov ecx, 0
- mov edx, [esi]
- sub edx, 48
- cmp edx, 9
- jbe cycleDigitPrecision
- cycleDigitPrecision:
- mov [precision + ecx], edx
- inc ecx
- jmp toDigitPrecision
- cmp byte[esi], 'd'
- jz formatD
- cmp byte[esi], 'i'
- jz formatI
- cmp byte[esi], 'x'
- jz formatX
- cmp byte[esi], 's'
- jz formatS
- cmp byte[esi], 'c'
- jz formatC
- cmp byte[esi], 'h'
- jz lenh
- cmp byte[esi], 'l'
- jz lenl
- cmp byte[esi], 'L'
- jz lenL
- formatS:
- mov edx, 0
- mov ecx, [parameters]
- step:
- cmp byte[ecx + edx], 0
- jz normal
- mov edi, [ecx + edx]
- mov [buf + edx], edi
- jmp step
- cmp word[esi], 0
- jnz normal
- formatC:
- formatD:
- formatI:
- formatX:
- normal:
- mov byte[lengths], 0
- mov byte[lengths + 1], 0
- mov byte[lengths + 2], 0
- mov byte[flags], 0
- mov byte[flags + 1], 0
- mov byte[flags + 2], 0
- mov byte[flags + 3], 0
- jmp percent
- sprintf:
- push esi
- push edi
- push ebx
- push ebp
- mov ebp, esp
- sub esp, 24; width(8), precision(12), len(16), flag
- wid equ ebp - 12 ; 4 bytes
- precision equ ebp - 16 ; 4 bytes
- parameters equ ebp + 16; 4 bytes
- lengths equ ebp - 8; 4 bytes
- buf equ ebp + 8
- flags equ ebp - 4
- mov esi, [ebp + 12]
- jmp normal
- start:
- push s
- push f
- push res
- call sprintf
- pop eax
- pop ebx
- pop ecx
- push 0
- push prog_title
- push res
- push 0
- call [__imp__MessageBoxA@16]
- push 0
- call [__imp__ExitProcess@4]
- section .data
- res db " ",0
- section .rodata
- prog_title db "sprintf",0
- f db "%s",0
- s db "Hello",0
- end
Add Comment
Please, Sign In to add comment