Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .text
- global _start
- _start:
- mov ecx, 0
- l1:
- inc ecx
- mov eax, ecx
- call printIntLB
- cmp ecx, 14
- jne l1
- call quit
- printIntLB:
- call printInt
- push eax
- mov eax, 0Ah
- push eax
- mov eax, esp
- call printString
- pop eax
- pop eax
- ret
- printInt:
- push eax
- push ecx
- push edx
- push esi
- mov ecx, 0
- divideLoop:
- inc ecx
- mov edx, 0
- mov esi, 10
- idiv esi
- add edx, 48
- push edx
- cmp eax, 0
- jnz divideLoop
- printLoop:
- dec ecx
- mov eax, esp
- call printString
- pop eax
- cmp ecx, 0
- jnz printLoop
- pop esi
- pop edx
- pop ecx
- pop eax
- ret
- printString:
- push edx
- push ecx
- push ebx
- push eax
- call lengthString
- mov edx, eax
- pop eax
- mov ecx, eax
- mov ebx, 1
- mov eax, 4
- int 80h
- pop ebx
- pop ecx
- pop edx
- ret
- lengthString:
- push ebx
- mov ebx, eax
- nextchar:
- cmp byte [eax], 0
- jz done
- inc eax
- jmp nextchar
- done:
- sub eax, ebx
- pop ebx
- ret
- quit:
- mov ebx, 0
- mov eax, 1
- int 80h
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement