do I have to put a x after ffffx
If your 'ffff' is to be the hexadecimal representation of the number 65535, then write it as 0xFFFF, prepending the 0x hexadecimal prefix.
does je mean if rax equals ffff jump
The je mnemonic stands for JumpIfEqual. Your code will jump if rax equals 0xFFFF.
I think my loop is wrong ...
Good news: your loop is correct, but you could write it somewhat better:
- For testing the loop termination condition where
r10 equals 0xFFFF, you don't need to first copy r10 to rax.
- And instead of exiting the loop on
r10 == 0xFFFF, better continue the loop on r10 != 0xFFFF. It will save you from writing the extra unconditional jmp.
... and the r10 register is not printing to the screen
For NASM, an instruction like mov know, r10 makes no sense. In this instruction, know is merily an immediate number and it can't possibly be the destination of anything. You were trying to store the contents of the r10 register in the buffer pointed at by know. The correct instruction would be mov [know], r10 using the square brackets.
An instruction like mov rcx, know is fine since it moves an immediate number (the address of know) into the register. Immediates can be the source operand.
Displaying a number requires you to convert the binary value into a string of characters that represent decimal digits.
The following Q/A's explain the process:
The value in r10 seems small enough, that we should not use the 64-bit division and instead use the faster 32-bit division:
know resb 64
...
REDO: inc r10d
mov eax, r10d
mov ebx, know + 63 ; High up in the buffer
mov ecx, ebx
mov edi, 10 ; CONST
.more: xor edx, edx
div edi
add edx, '0' ; Remainder [0,9] -> ["0","9"]
mov [rcx], dl
dec ecx
test eax, eax
jnz .more
mov byte [rcx], ' ' ; Leading space
sub ebx, ecx ; Number of digits
lea edx, [rbx + 1] ; plus the leading space char
mov ebx, 1
mov eax, 4
int 0x80
cmp r10d, 0x0000FFFF
jne REDO
END:
The leading space was added so that the numbers are not sticking together in this long series of numbers.
My previous answer nasm linux x64 how do i find and cmp EOF to stop printing data from file to screen
already warned you about using int 0x80 in 64-bit code. Today you still use it; was anything not clear from the link that I gave you?
know resb 64
...
REDO: inc r12d
mov eax, r12d
mov rbx, know + 63 ; High up in the buffer
mov rsi, rbx
mov edi, 10 ; CONST
.more: xor edx, edx
div edi
add edx, '0' ; Remainder [0,9] -> ["0","9"]
mov [rsi], dl
dec rsi
test eax, eax
jnz .more
mov byte [rsi], ' ' ; Leading space
sub rbx, rsi ; Number of digits
lea edx, [rbx + 1] ; plus the leading space char
mov edi, 1
mov eax, 1
syscall
cmp r12d, 0x0000FFFF
jne REDO
END: