can't pass variables between sxb and assembly
Hello still not working still.
·
In the program below I am trying to use the variable byte try4 in the assembly code I have included in the sxb program. It doesn’t seem to be working. Can you tell me how to pass variables between sxb and assembly?
·
Thanks Warner
DEVICE········· SX28, OSCHS2, TURBO, STACKX, OPTIONX
FREQ··········· 50_000_000
'
' IO Pins
'
led············ VAR···· Rc.7
'
' Variables
'
try1··var ·byte
try2··var ·byte
try3··var ·byte
try4··var·byte
· PROGRAM Start
Start:
Main:
·try4 = 255
····· ·high led
·pause try4
·low led
·pause try4
· ·'SHIFTIN ra.0, ra.1, msbpost, datain
asm
·
In the program below I am trying to use the variable byte try4 in the assembly code I have included in the sxb program. It doesn’t seem to be working. Can you tell me how to pass variables between sxb and assembly?
·
Thanks Warner
DEVICE········· SX28, OSCHS2, TURBO, STACKX, OPTIONX
FREQ··········· 50_000_000
'
' IO Pins
'
led············ VAR···· Rc.7
'
' Variables
'
try1··var ·byte
try2··var ·byte
try3··var ·byte
try4··var·byte
· PROGRAM Start
Start:
Main:
·try4 = 255
····· ·high led
·pause try4
·low led
·pause try4
· ·'SHIFTIN ra.0, ra.1, msbpost, datain
asm
Comments
The byte to transmit was passed in __PARAM1 and you can see it used about half way down the listing. Note that the compiler takes care of moving your value (constant or variable) to the correct internal (__PARAMx or __WPARAMxx) variable.
Post Edited (JonnyMac) : 3/20/2007 8:49:25 PM GMT
Main:
try4 = 255
high led
pause try4
low led
pause try4
'SHIFTIN ra.0, ra.1, msbpost, try4
end
asm
loopy
call delay ;delay
mov W,/RC ;toggle all of RC port
mov RC,W
jmp loopy
Delay clr try1
clr try2
mov try3,#try4
Loop djnz try1,loop ;Decrement until all are zero
djnz try2,loop
djnz try3,loop
ret
endasm
If you don't have it you might want to get a copy of Guether Daubach's excellent book, "Programming the SX Microcontroller."
The easiest thing to do is look at the SX/B output to see how to use variables and stuff.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Educate your children to self-control, to the habit of holding passion and prejudice and evil tendencies subject to an upright and reasoning will, and you have done much to abolish misery from their future and crimes from society"
Benjamin Franklin
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Coming soon! Propeller based OSD module www.hittconsulting.com
·
I was having the same issue for the past days, and I believe I have figured out what you need to know. The situation is where one has defined a VAR and CON SX/B and they want them to also be used in an assembly routine which is part of the overall SX/B program.
Let me give two examples which may help illustrate this. For each example in assembly, we will make X = Y.
If Y is a variable in SX/B, then use in assembly: mov X,Y
If Y is a constant in SX/B, then use in assembly: mov X,#Y
If anyone has other tidbits of information not noted in the documents, I would enjoy knowing about them.
Thanks
For example let's say that you have a variable named "X" that is stored at RAM location $0F and has the value 123. The "value" of X is $0F, and the value contain in RAM at location $0F will be 123.
In assembly the instruction "MOV X,Y" means to move the value in RAM location "Y" to RAM location "X". Where "MOV X,#Y" means to move the actual value of "Y" to RAM location "X".
When you use arrays what you do is assign the array location (held in the array name) to the FSR register, then access the array element with the IND register. But·in this case you really DO want the RAM location, so·you need to put a "#" in front of the array name.
These two instructions are the same as "MyArray(0) = 123"
MOV FSR,#MyArray
MOV IND,#123
I hope this helps,
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
Post Edited (Bean (Hitt Consulting)) : 2/20/2008 4:26:00 PM GMT