SETB problem
Gents,
I am trying to use a variable to help me set select bits within another variable. The bits set will vary, and thus the desire to use a variable. What I think should work does not. So, I know I must not be understanding something. Can someone help me on this?
Here is an example code to illustrate how I am trying to manipulate bits in TestByte by using the variable BitLocation as a bit positioner. The counter will go from 7 to 0, so that all bits will be set for this example.
I am using the SXSim to monitor the process. The BitLocation does get smaller, but the use of it in the SETB command is not reflected.
I am trying to use a variable to help me set select bits within another variable. The bits set will vary, and thus the desire to use a variable. What I think should work does not. So, I know I must not be understanding something. Can someone help me on this?
Here is an example code to illustrate how I am trying to manipulate bits in TestByte by using the variable BitLocation as a bit positioner. The counter will go from 7 to 0, so that all bits will be set for this example.
I am using the SXSim to monitor the process. The BitLocation does get smaller, but the use of it in the SETB command is not reflected.
DEVICE SX28, TURBO, STACKX, OSC4MHZ IRC_CAL IRC_4MHZ FREQ 4_000_000 RESET Start ;************************ Program Variables ***************************** org $08 ;First register address in main memory ;bank TestByte ds 1 ;Temporary storage BitLocation ds 1 ;Bit location within TestByte org $100 Start break mov BitLocation,#$07 ;location of bit to be set in TestByte mov TestByte,#$00 ;Initial value = 0 Main SETB TestByte.BitLocation DEC BitLocation JMP Main
Comments
Here is how I would do it using a mask value and "OR":
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
Post Edited (Bean (Hitt Consulting)) : 2/27/2008 1:45:38 PM GMT