I'm here with what is probably a very basic question, but I haven't been able to find many resources out there for the assembly I'm working with (YASM assembler, targeting 64-bit Intel CPUs [“x86-64”] on Linux).
As part of a program I'm writing, I need to write a function that receives a char* in rdi to the beginning of a string, and a char* in rsi to a "substring" that I must search for within the first string. It is supposed to "return" the first occurrence of where the substring is within the main string by setting [byte]rax to null (0 using ASCII).
Right now I am simply trying to return 0, or null, regardless of if the substring is present or not, and then figure out the rest after. When it didn't seem to be working, I tried this...
mov byte[rax], 0
cmp byte[rax], 0
je .not_found
...along with other variations, all very similar to each other. Of course if I do something like...
mov rax, 0
cmp rax, 0
je .not_found
...then it works, so what I'm not understanding is what I should be doing differently when targeting a single byte to set to 0 (as opposed to an entire 64 bit register), and checking this.
Any help would be appreciated, and I apologize if I wasn't being technically correct when describing what's happening, as assembly is still fairly new to me. Thank you!