PowerBASIC Forums
  PowerBASIC for Windows
  BIT Question Part 2 - PB Compiler output

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   BIT Question Part 2 - PB Compiler output
Lothar Pink
Member
posted March 03, 2004 08:24 AM     Click Here to See the Profile for Lothar Pink     Edit/Delete Message   Reply w/Quote
If I compile & run the following code:


FUNCTION PBMAIN AS LONG
DIM a AS INTEGER

! nop
! nop

BIT SET a, 6

! nop
! nop

! mov eax, 0
! mov [eax], eax ; I always use that in order to trigger a GPF so I can view the disassembly

END FUNCTION

It compiles to


004010A3 nop
004010A4 nop
004010A5 mov eax,6
004010AA lea ebx,[ebp-80h]
004010AD mov dword ptr [ebp-80h],esi
004010B0 call 004017B3
004010B5 mov esi,dword ptr [ebp-80h]
004010B8 nop
004010B9 nop
004010BA mov eax,0
004010BF mov dword ptr [eax],eax

At 004017B3:


004017B3 call 004017CB
004017B8 or byte ptr [ebx],al
004017BA ret

At 004017CB:


004017CB mov cl,al
004017CD shr eax,3
004017D0 add ebx,eax
004017D2 and cl,7
004017D5 mov al,1
004017D7 shl al,cl
004017D9 ret

Why not just use "bts" ? I don't want to complain about the performance
but what's wrong with bts?

Best Regards

------------------
ADDED: With REGISTER NONE - similar


004010A3 nop
004010A4 nop
004010A5 mov eax,6
004010AA lea ebx,[ebp-80h]
004010AD call 004017B3
004010B2 nop
004010B3 nop
004010B4 mov eax,0
004010B9 mov dword ptr [eax],eax

[This message has been edited by Lothar Pink (edited March 03, 2004).]

IP: Logged

Michael Mattias
Member
posted March 03, 2004 08:29 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote

BIT SET a, 6

Why not 'bts'?, well, Why not..


a = a OR 64%

I do not know what 'bts' does, but maybe it has something to do with the fact that the BIT SET function will set bits beyond the nominal range of the operand?

Or maybe 'bts' requires a certain minimum processor type?

[This message has been edited by Michael Mattias (edited March 03, 2004).]

IP: Logged

Lothar Pink
Member
posted March 03, 2004 08:31 AM     Click Here to See the Profile for Lothar Pink     Edit/Delete Message   Reply w/Quote
I don't know about the processor compatibility, but BTS - as far as I know - allows
to set a bit at ANY position in memory, as long as it's in the process memory. So, it's
a single statement - instead of two CALLs here.

PS: The reason I'm asking is actually if there is some reason why I should NOT use the BTS
assembler instruction - since PB is avoiding it.

------------------

[This message has been edited by Lothar Pink (edited March 03, 2004).]

IP: Logged

Paul Dixon
Member
posted March 03, 2004 12:00 PM     Click Here to See the Profile for Paul Dixon     Edit/Delete Message   Reply w/Quote
Lothar,
<<! mov [eax], eax ; I always use that in order to trigger a GPF so I can view the disassembly>>

That's what "!int 3" is for. It calls the current debugger.

The Bit set ASM opcodes have existed since the 386 so I don't see why they aren't used. They can set any bit but only 2^32 BITS are addressable within a single instruction (i.e.1/8th of the total RAM that is addressable).

Paul.

IP: Logged

Marco Pontello
Member
posted March 03, 2004 04:47 PM     Click Here to See the Profile for Marco Pontello     Edit/Delete Message   Reply w/Quote
See this for a quick way to look at the compiler output for some lines of PowerBASIC code:
http://www.powerbasic.com/support/forums/Forum7/HTML/002258.html

Bye!

------------------
Try TrID file identifier! Over 990 filetypes and counting... ;)
Give a powerfull scriptable Lua interface to your application with PowerBLua

IP: Logged

All times are EasternTime (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | PowerBASIC BASIC Compilers

Copyright © 1999-2007 PowerBASIC, Inc. All Rights Reserved.


Ultimate Bulletin Board 5.45c