It is currently Sat Aug 24, 2019 10:09 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Why does CQO instruction not recognized by PB
PostPosted: Sat Feb 02, 2019 12:26 am 
Offline
New User
New User

Joined: Thu Jan 03, 2019 3:05 am
Posts: 8
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Why does CQO instruction not recognized by PB
PostPosted: Sat Feb 02, 2019 12:47 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3694
Location: Italy
I'm just guessing here.
I think PB EnableASM supports only the opcodes up to 80486, and CQO was introduced with x64.
You have compiled your PB program on x64 so you found that instruction in the generated code.

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye