Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "asm_io.inc"
- segment .bss
- string resb 32
- segment .text
- global main
- main:
- enter 0,0 ; setup stack frame
- pusha
- mov edx, 0
- mov ecx, 0
- mov ebx, 0
- repeat: call read_char
- sub eax, 48
- mov esi, eax
- mov eax, ecx
- mov ebx, 10
- mul ebx
- mov ecx, eax
- add ecx, esi
- mov byte [string+edx], al
- cmp al, 0x0a
- jne repeat
- mov byte [string+edx-1], 0
- mov eax, ecx
- call print_int
- call print_nl
- popa
- mov eax, 0 ; return value
- leave ; leave stack frame
- ret
- repeat:
- call read_char
- cmp al, 0x0a
- je exit_loop // exit the loop if enter
- //code as before
- jmp repeat //jump unconditionally to the beginning of the loop
- exit_loop:
- mov byte [string+edx-1], 0
Add Comment
Please, Sign In to add comment