I'm really new to assembly and I wrote this code:
SYS_WRITE equ 1
SYS_READ equ 0
SYS_EXIT equ 60
STDOUT equ 1
section .bss
uinput resb 24
uinput_len equ $ - uinput
section .data
text db "You wrote: "
text_len equ $ - text
optiona db "It's a first letter of the alphabeth"
optiona_len equ $ - optiona
optionb db "It's a second letter of the alphabeth"
optionb_len equ $ - optionb
section .text
global _start
_start:
mov rax, SYS_READ
mov rdi, STDOUT
mov rsi, uinput
mov rdx, uinput_len
syscall
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, text
mov rdx, text_len
syscall
;mov ax, 'a'
;mov bx, 'b'
cmp uinput, 'a' ; or ax(?)
je uinput_a
jne nextCheck
nextCheck:
cmp uinput, 'b' ; or bx(?)
je uinput_b
jne end
uinput_a:
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, optiona
mov rdx, optiona_len
mov rax, SYS_WRITE
mov rsi, 0
syscall
uinput_b:
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, optionb
mov rdx, optionb_len
mov rax, SYS_WRITE
mov rsi, 0
syscall
end:
mov rax, SYS_WRITE
mov rdi, STDOUT
mov rsi, uinput
mov rdx, uinput_len
syscall
mov rax, SYS_WRITE
mov rsi, 0
syscall
It lets user input a char, if the value is equal to 'a' it's suppposted to write on display "It's the first letter of the alphabet" (same if the value is 'b', just showing different text), but if it isn't equal neither 'a' or 'b' it's just writing down the char that you inputed.
The problem is, when I'm trying to compile it, it is returning an error at line 40 and 46: "invalid combination of opcode and operands" and I have absolutely no idea what went wrong.