I am trying to load only the first byte in a register after data is passed into it for example if I have the following ASM code
global _start
section .data
string db "Hello", 0x00 ; string = Hello
section .text
_start:
mov eax, string ; move "Hello" into eax (just to store it for now)
this is where I am stuck, I want to ONLY store "H" into eax, so for instance if I moved "H" into EAX, then moved eax into edx so EDX = "H", I could do:
mov ebx, 1
mov ecx, edx ; This is so I can store "H" in ecx
mov edx, 12 ; 12 is longer than the string, however, I am just using this to test, as it should only output "H", rather than anything else, the reason for this is later I want to use "H" in a cmp statement
int 0x80 ; execute the system call
Now I have also tried using al, ex: mov [edx], al after moving string into eax, but this still outputs the full string, if a working example can be provided for this, that would be greatly appreciated
mov [edx], alstores the byte in AL into the memory location pointed at by EDX. This is way off.global _start section .data string db "testing", 0x00 section .text _start: xor eax, eax mov eax, string mov [edx], al mov eax, 4 mov ebx, 1 mov ecx, edx mov edx, 12 int 0x80 mov eax, 1 mov ebx, 0 int 0x80It returns a segfault, any ideas?mov [edx],alyou try to write a byte into the memory location that EDX points to. EDX contains garbage. That's your segfault.