Skip to content

Instantly share code, notes, and snippets.

@siviae
Created February 28, 2014 22:35
Show Gist options
  • Save siviae/9281471 to your computer and use it in GitHub Desktop.
Save siviae/9281471 to your computer and use it in GitHub Desktop.
extern __imp__MessageBoxA@16
extern __imp__ExitProcess@4
%assign MB_ICONINFORMATION 40h
section .text
global _start2
_start2:
mov eax, -2345;тут храним введённое число
mov ebx, 0;тут храним текущий сдвиг по строке
mov ecx, 45; сначала знак минус, потом 10
push -1; пихаем в стек символ конца строки
mov edx,0
cmp eax, 0
jle br2
jmp continue
br2:; вставка знака минус
mov [number], ecx
inc ebx
neg eax; получаем абсолютное значение
jmp continue
continue:
mov cx, 10
div cx
mov ebp, 48; ASCII - символ нуля
add ebp, edx
push ebp
mov edx,0
cmp eax,0
jne continue
jmp output
output:
pop eax
cmp eax,-1
je finish
mov [number+ebx], eax
inc ebx
jmp output
finish:; окончание программы,
push MB_ICONINFORMATION
push hello_title
push number
push 0
call [__imp__MessageBoxA@16]
push 0
call [__imp__ExitProcess@4]
ret
section .data
hello_title: db "title",0
hello_msg: db "Hello,World!",0
number: db " ",0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment