Using a WORD value in my Sx/B calculations
duffling
Posts: 73
Im having trouble working out how to compute WORD values ..
I understand a word is two bytes , i create a two byte array
number var byte(2)
and i realize that a word is the same as a 16bit binary value ..
but im finding it hard to get my head around how i can duplicate the word type in sx/b
i basically need to store 16bit numbers in an eeprom
previously i did this using Number.highbyte , number.lowbyte etc
if anyone has any Sx/b maths routines i can study
also
in assembly if i wish to count a 16bit number im using the Addb command to add a bit using status.0 , the carry bit
im still a bit in the dark as to how this command actually works.. ive studied the code numerous times.. and im missing something
thanks again
·
I understand a word is two bytes , i create a two byte array
number var byte(2)
and i realize that a word is the same as a 16bit binary value ..
but im finding it hard to get my head around how i can duplicate the word type in sx/b
i basically need to store 16bit numbers in an eeprom
previously i did this using Number.highbyte , number.lowbyte etc
if anyone has any Sx/b maths routines i can study
also
in assembly if i wish to count a 16bit number im using the Addb command to add a bit using status.0 , the carry bit
im still a bit in the dark as to how this command actually works.. ive studied the code numerous times.. and im missing something
thanks again
·
Comments
numberL VAR BYTE
numberH VAR BYTE
working VAR BYTE
' add 8-bit to 16-bit
numberL=numberL + working
numberH = numberH + C
The addb command expands to:
SNB status.0
INC variable
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video Display Module" Available Now.
www.sxvm.com
"A problem well defined, is a problem·half solved."
·
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000
number VAR BYTE(2) ' number(0) = LSB; number(1) = MSB
working VAR BYTE
Program Start
Start:
· PUT number,232,3 ' Store 1000 in number
· working=100
· ' Add "working" to "number"
· ASM
··· MOV __PARAM1,working
· · MOV FSR,#number
··· ADD IND,__PARAM1
· · INC FSR
··· ADDB IND,C
· · BANK $00
· ENDASM
END
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video Display Module" Available Now.
www.sxvm.com
"A problem well defined, is a problem·half solved."
Post Edited (Bean) : 3/28/2005 3:58:05 PM GMT
You can put some initial values in term0 and prod0 and single step through the program watching what happens until you understand what is going on.
term0··· ds 1
prod0··· ds 1
term1··· ds 1
prod1··· ds 1
mov W, term0
add prod0, W
mov W, term1
snb C
movsz W, ++term1
add prod1, W
'PUT number,232,3 ' Store 1000 in number'
i may need some help with this .. everything else makes sense thou
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔