I'm trying to learn some assembly, and following this guide.
I'm at exercise 3, which sounds like this:
Given n (stored in rdi) values stored in IN:
1. For each of BYTE value x taken from IN:
i. If x > 0x50, write x - 0x37 to OUT.
ii. Else, write x + 0x13 to OUT.
Hint: Note that values from 0x80 to 0xff are considered as negative values when they are a BYTE (because MSB is set). Make sure you use the unsigned versions of the jcc instructions.
To simplify your experience, r8 is initialised to 0x1000(IN), and r9 to 0x2000(OUT).
So my thought was that I should use the loop operator, and that I should use jg to test for a greater than comparison:
loop:
mov r10, r8
cmp r8, 0x50
jg great
not_great:
sub r10, 0x37
mov r9, r10
great:
add r10, 0x13
mov r9, r10
end:
hlt
jmp loop
There's probably a few issues here. But the first one is that I think I am just reading the same value from r8 again and agai, not iterating over them. How do I actually iterate over them? so I don't hit the same value again and again?