I am trying to compile the following asm code and I am getting some errors.
The program is supposed to ask for user input to try to guess if person1 is wealthier than person two
hello.o: in function compare_loop:
hello.asm:(.text+0x51): relocation truncated to fit: R_386_16 against .data
hello.asm:(.text+0x5b): relocation truncated to fit: R_386_16 against .data
%macro write_string 2
mov eax, 4
mov ebx, 1
mov ecx, %1
mov edx, %2
int 80h
%endmacro
section .bss ;Uninitialized data
guess resb 5
section .text
global _start
_start:
write_string msg1, len1
write_string msg2, len2
write_string msg3, len3
int 0x80
mov ecx, 0 ;streak counter
mov si, 0 ;array index
compare_loop:
push ecx
mov ecx, [wealth + si]
add ecx, 0
inc si
mov edx, [wealth + si]
add edx, 0
cmp ecx, edx
jb store_y
jmp store_n
input_compare:
mov eax, 3
mov ebx, 0
mov ecx, guess
mov edx, 5 ;5 bytes (numeric, 1 for sign) of that information
cmp ebx, guess
je true
jmp false
true:
write_string msgyes, lenyes
pop ecx
inc ecx
push ecx
cmp ecx, 5
jb victory
jmp keep_playing
false:
write_string msgno, lenno
mov ecx, 0
push ecx
jmp keep_playing
keep_playing:
write_string msgcontinue, lencontinue
mov eax, 3
mov ebx, 0
mov ecx, guess
mov edx, 5 ;5 bytes (numeric, 1 for sign) of that information
cmp ecx, 79h
je compare_loop
jmp finish_game
victory:
write_string msgvictory, lenvictory
pop ecx
mov ecx, 0
mov si, 0
jmp keep_playing
finish_game:
write_string msgfinish, lenfinish
jmp exit
store_y:
mov ebx, 79h
push ebx
jmp input_compare
store_n:
mov ebx, 6eh
push ebx
jmp input_compare
exit:
mov eax,1 ;system call number (sys_exit)
mov ebx,0
int 0x80 ;call kernel
section .data
msg1 db 'Welcome!', 0xA, 0xD
len1 equ $ - msg1
msg2 db 'Try to guess if the last given personality is wealthier than the previous given one.', 0xA, 0xD
len2 equ $- msg2
msg3 db 'Answer in lower case (y or n). 5 correct streak to win', 0xA, 0xD
len3 equ $- msg3
msgyes db 'Yes! You answered correctly!', 0xA, 0xD
lenyes equ $- msgyes
msgno db 'Oh no! You answered incorrectly!', 0xA, 0xD
lenno equ $- msgno
msgcontinue db 'Do you want to keep playing? (y to continue, n to stop).', 0xA, 0xD
lencontinue equ $- msgcontinue
msgvictory db 'Congratulations! You won!', 0xA, 0xD
lenvictory equ $- msgvictory
msgfinish db 'Thank you for playing!', 0xA, 0xD
lenfinish equ $- msgfinish
wealth: db 20,50,15,75,80,10,100