According to some tutorials I've seen, there's a number of ways to do things in Assembly. I'm at a marker here on whether I can do this or not. I'm ordering a book on Assembly, but right now I need to know the thing that is wrong with my High - Low game. It's meant to find the number of the user's choice. Besides the fact that I don't have it really doing much of anything yet, I'm stuck on a Floating Point Exception. I was using 32-bit registers, and I decided to try and move them to 64-bit, but that didn't help at all. I'm expecting it to run, and continue running until they do not press 'Y' or 'N' at the input point. Right now, as I said, it comes up with the FPEx and dumps without any user input.
I've tried Tutorials on YouTube, and some cheat sheets. But they just don't have the ability to confine me to the area where my bug is. I got as far as I am on running through those though. Very helpful, but I need to get some 1:1 right now.
global _start
section .data
message: db "High Lo", 10
m_len equ $-message
hot_cold: db "Am I getting warmer? (Y/N/Quit): "
w_len equ $-hot_cold
yes: db "Y"
no: db "N"
divide: dq 4.0
multiply: dq 2.0
section .bss
hilo: resq 1
NoHi: resq 1
NoLo: resq 1
newGuess: resq 1
yn: resd 1
section .text
_start:
mov rax, 1
mov rdi, 1
mov rsi, message
mov rdx, m_len
syscall
mov dword [NoHi], 50
mov dword [NoLo], 50
.loop:
mov rcx, [yes] ; char compare Y
mov rbx, [no] ; char compare N
xor rax, rax
xor rdi, rdi
xor rsi, rsi
xor rdx, rdx
syscall
mov rax, 1
mov rdi, 1
mov rsi, hot_cold
mov rdx, w_len
syscall
; xor rsi, rsi
xor rsp, rsp ; clear out register with y/n
xor rax, rax
xor rdx, rdx
xor rbp, rbp
mov rax, 0 ; setup for input
mov rbx, 0 ;
mov rsi, rsp ; collect input
mov rdx, 2 ; how many inputs
syscall ; init collection
.hop_yes:
cmp rcx, rsp ; compare to Y
jne .hop_no ; compare fail, try N
call _for_y ; compare success, change numbers
;syscall
jmp .loop ; loop on successful Y
.hop_no:
cmp rbx, rsp ; compare to N
jne _exit ; compare fail, rxit
call _for_n ; compare success change numbers
;syscall
jmp .loop
_for_y:
xor rax, rax
xor rdx, rdx
;xor rcx, rcx
mov rax, [NoHi]
mov rdx, [multiply]
mul rdx ; byte [multiply]
mov rdx, rax
syscall
;-----
xor rdi, rdi
;xor rdx, rdx
syscall
mov rax, 1
mov rdi, 1
mov rsi, rdx
;mov rdx, 3
syscall
;-----
xor rdx, rdx
mov rax, [NoLo]
mov rdx, [divide]
div rdx
mov rbp, rax
mov [NoLo], rbp
syscall
ret
_for_n:
xor rdx, rdx
mov rax, [NoLo]
mov rdx, [divide]
div rdx
mov [NoLo], rax
;-----
xor rax, rax
mov rax, [NoHi]
mov rdx, [multiply]
mul rdx
mov [NoLo], rax
syscall
ret