Code: Select all
! Mov rax, $7FFFFFFF
Code: Select all
! Mov rax, $FFFFFFFF ; error...
Any help?
Answer : ups... I did not the difference between MOV and other arithmetic ops : MOV can accept immediate 64-bits values, but not OR, AND, XOR, etc...
Code: Select all
! Mov rax, $7FFFFFFF
Code: Select all
! Mov rax, $FFFFFFFF ; error...
Code: Select all
! Or [v_mypbvar], $1FFFFFFFF ; equ to mypbvar | $1FFFFFFFF ...and '1' is too much here...
Code: Select all
; Provide a 64-bits number which reveals
; if the 64 first numbers are prime number (status 0)
; or products of any factors (status 1)
; The result (var I) is read from right to left.
Define I.I
; (Assembly source instructions) (Comments) (PureBasic equivalent)
! push rbx ; RBX is a register which must be saved stack = rbx
! xor rax, rax ; RAX is the target of the sieve rax ! rax
! mov rdx, 1 ; RDX will be the shuttle rdx = 1
! mov rcx, 1 ; RCX will be the countor rcx = 1
! or rax, rdx ; '1' is not a prime number rax | 1
syncStart:
! test rax, rdx ; Is this number a product of factors ? if rax & rdx = 0
! jz l_isprime ; * No, it's so a prime number then goto isprime
nextNumber:
! inc rcx ; * Yes, let's go to the next number rcx + 1
! shl rdx, 1 ; move the shuttle rdx << 1
! jnz l_syncstart ; if rdx goto syncstart
! jmp l_fin ; goto fin
isPrime:
! mov r8, rdx ; save the shuttle r8 = rdx
! xor rbx, rbx ; initialize the mask rbx ! rbx
frameStamp:
! or rbx, rdx ; mark the mask rbx | rdx
! shl rdx, cl ; move the shuttle rdx << rcx
! jnz l_framestamp ; mask no complete ? So, repeat the marking if rdx goto framestamp
! mov rdx, r8 ; mask is complete ? So, restore the shuttle rdx = r8
! or rax, rbx ; sieve rax | rbx
! xor rax, rdx ; but excludes the prime number rax ! rdx
! jmp l_nextnumber ; continue goto nextNumber
fin:
! mov [v_I], rax ; set the value of RAX into I variable I = rax
! pop rbx ; Restore RBX rbx = stack
Debug Bin(I) ; Display the sieve (Debug)
Code: Select all
! Mov rax, $1FFFFFFFF ; move is enabled
! Or rax, $1FFFFFFFF ; arithmetic op is however disabled