; nasm -f elf myprog.asm
; ld -s -o myprog myprog.o
global _start
section .text
_start:
mov ebx, -28
top:
lea eax, [ebx - 5]
call showeaxsigned
add ebx, 8
cmp ebx, 25
jl top
exit:
mov eax, 1
int 80h
;---------------------------
putc:
push edx
push ecx
push ebx
push eax
mov eax, 4
mov ebx, 1
mov ecx, esp
mov edx, 1
int 80h
pop eax
pop ebx
pop ecx
pop edx
ret
;-----------------------------
;--------------------
showeaxsigned:
or eax, eax
jns positive
push eax
mov eax, '-'
call putc
pop eax
neg eax
positive:
call showeaxd
mov al, 10
call putc
ret
;------------------------
;---------------------------------
showeaxd:
push eax
push ebx
push ecx
push edx
push esi
sub esp, 10h
lea ecx, [esp + 12]
mov ebx, 10
xor esi, esi
mov byte [ecx], 0
.top:
dec ecx
xor edx, edx
div ebx
add dl, '0'
mov [ecx], dl
inc esi
or eax, eax
jnz .top
mov edx, esi
mov ebx, 1
mov eax, 4
int 80h
add esp, 10h
pop esi
pop edx
pop ecx
pop ebx
pop eax
ret
;---------------------------------
Oh, you didn't want it for Linux? Shoulda left it in C! :)
Best,
Frank