I'm trying to learn assembly (specifically the nasm variety on ideone.com). When I jump to a procedure I'm getting error code 11, while when I just call the procedure there is no error. I've tried it with and without the "ret" at the end of the block. Note that the _printOne procedure is only called if the input is of length 2, e.g "a[newline]". Here is my code
global _start
section .data
sys_read equ 3
sys_write equ 4
max_line_len equ 10
stdin equ 0
oneStr db '1'
oneStrLen equ $ - oneStr
section .bss
line resb 10
segment .text
_start:
call _readLine ; stores value in line
cmp eax, dword 2 ; if input has length of 2, print out '1'
je _printOne ; No error if "call _printOne"!
mov eax, 01h ; exit()
xor ebx, ebx ; errno
int 80h
_readLine:
mov eax, sys_read ; syscall to read
mov ebx, stdin ; stdin
mov ecx, line ; put line into ecx
mov edx, max_line_len ; length to read
int 0x80
ret
_printOne:
mov eax, sys_write
mov ebx, stdout
mov ecx, oneStr
mov edx, oneStrLen
int 80h
ret