Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "io.inc"
- section .data
- mystring db "-543", 0
- section .text
- global CMAIN
- mul_10:
- push ebp
- mov ebp, esp
- mov ecx, [ebp + 8]
- shl ecx, 1
- mov ebx, ecx
- shl ecx, 2
- add ebx, ecx
- leave
- ret
- atoi:
- push ebp
- mov ebp, esp
- cld
- mov esi, [ebp + 8]
- xor ebx, ebx
- xor eax, eax
- xor edx, edx
- lodsb
- cmp al, '-'
- jne not_negative
- mov edx, 1
- add_digit:
- lodsb
- test al, al
- je end
- not_negative:
- push ebx
- call mul_10
- add esp, 4
- add ebx, eax
- sub ebx, '0'
- ;PRINT_DEC 1, al
- jmp add_digit
- end:
- cmp edx, 1
- PRINT_DEC 4, edx
- jne not_negative_end
- neg ebx
- not_negative_end:
- NEWLINE
- PRINT_DEC 4, ebx
- leave
- ret
- CMAIN:
- mov ebp, esp; for correct debugging
- push mystring
- call atoi
- pop eax
- mov ebp, esp
- xor eax, eax
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement