Why does CQO instruction not recognized by PB
Posted: Sat Feb 02, 2019 12:26 am
I wanted to see the timing difference between IDIV and DIV. So I wrote a simple program, looked at the assembly code and cut and pasted the portion for c=a/b into the timing loop. I changed IDIV to DIV. The compiler gave a syntax error for CQO line. I put a ! in front of the CQO to send directly to FASM and it worked fine. Any comments? Truly amazing how fast cpu's are today.
Code: Select all
ntimes=1e6
a=999999999999999999
b=567890123456789
atime=ElapsedMilliseconds()
For i=1 To ntimes
Next
btime=ElapsedMilliseconds()
For i=1 To ntimes
c=a/b
Next
c=0
ctime=ElapsedMilliseconds()
For i=1 To ntimes
;c=a/b
EnableASM
MOV r15,qword [v_a]
PUSH qword [v_b]
MOV rax,r15
POP rcx
!CQO ;trouble spot
DIV rcx
MOV r15,rax
MOV qword [v_c],r15
DisableASM
Next
dtime=ElapsedMilliseconds()
OpenConsole()
PrintN("nsec/loop")
PrintN(Str(btime-atime)+" "+Str(ctime-btime)+" "+Str(dtime-ctime))
PrintN(Str(a/b)+ " "+Str(c))
Input()
End