RosettaCodeData/Task/Loops-Do-while/X86-Assembly/loops-do-while.x86

26 lines
491 B
Plaintext

extern _printf
section .data
output db 0,0
section .text
global _main
_main:
mov bl, 0
looping:
add bl, 0x31 ;0x30 to 0x39 is 0 to 9 in ASCII
mov [output], bl
sub bl, 0x30
push output
call _printf
add esp, 4
xor eax, eax
xor edx, edx
mov al, bl
mov ecx, 6
div ecx ; remainder is saved in edx
cmp edx, 0
jne looping ; if n & 6 != 0 do looping again
xor eax, eax
ret