I am trying to write B to the file, read it, xor it with the integer 10 and write the result to the file, but I get an operand mismatch. How can I xor the value stored in a buffer with an integer and then write the result back to file? Thank you!
.section .bss
buffer: .skip 1
.align 8
file: .quad 0
.data
B: .byte 0x42
.text
filename: .asciz "file.bmp"
mode: .asciz "w+"
myText: .asciz "C"
toInt: .asciz "%u"
.global main
main:
pushq %rbp
movq %rsp, %rbp
movq $filename , %rdi
movq $mode , %rsi
call fopen
mov %rax, file
mov $B, %rdi
mov $1, %rsi
mov $1, %rdx
mov file, %rcx
call fwrite
mov file, %rdi
mov $0, %rsi
mov $0, %rdx
call fseek
mov $buffer, %rdi
mov $1, %rsi
mov $1, %rdx
mov file, %rcx
call fread
movq $10, %r10
xor %r10, $buffer
mov $buffer, %rdi
mov $0, %rsi
mov $0, %rdx
mov file, %rcx
call fwrite
movq %rbp, %rsp
popq %rbp
movq $0, %rdi
call exit
I tried to move the value from the buffer into an register, but that also doesnt seem to work. Also I tried to change the order of buffer and integer in the xor operation, still no results.