In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bernoulli wrote: 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. [code] 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 [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=253261 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)