I'm trying to read in two strings, convert them into numbers using atoi function, and then print out the result.
Here's my uninitialized variables. (%define BUFLEN 20)
SECTION .bss ; uninitialized data section
m: resb BUFLEN ;STRING 1
mlen: resb 4
r: resb BUFLEN ;STRING 2
rlen: resb 4
Here's where I get the user input/ attempt allocate it into memory
; prompt user for FIRST NUMBER
mov eax, SYSCALL_WRITE ; write function
mov ebx, STDOUT ; Arg1: file descriptor
mov ecx, msg1 ; Arg2: addr of message
mov edx, len1 ; Arg3: length of message
int 080h ; ask kernel to write
; read in user input
;
mov eax, SYSCALL_READ ; read function
mov ebx, STDIN ; Arg 1: file descriptor
mov ecx, m ; Arg 2: address of buffer
mov edx, BUFLEN ; Arg 3: buffer length
int 080h
mov [rlen], eax ; save length of string read
; prompt user for SECOND NUMBER
mov eax, SYSCALL_WRITE ; write function
mov ebx, STDOUT ; Arg1: file descriptor
mov ecx, msg2 ; Arg2: addr of message
mov edx, len2 ; Arg3: length of message
int 080h ; ask kernel to write
; read in user input
mov eax, SYSCALL_READ ; read function
mov ebx, STDIN ; source
mov ecx, r ; destination
mov edx, BUFLEN ; length of destination
int 080h
mov [mlen], eax ; save length of string read
Now I'm trying to convert the strings using atoi and print them out
;CONVERT TO #
mov eax, 0 ;zero out register
mov eax, m
call atoi
add esp, 4
;PRINT IT
push ax
push print_r
call printf
add esp, 8
;CONVERT TO #
mov eax, 0 ;zero out register
mov eax, r
call atoi
add esp, 4
;PRINT IT
push ax
push print_r
call printf
add esp, 8
This is my output...
Enter first #: 1234
Enter second#: 1234
Number: 1234
Hanging on second atoi call
push ax!