indexing through variables in asm question
Rick_H
Posts: 116
I have a bunch of things I am doing for each output on my I2C bus per channel.
This is a small example
how would I use djnz and an index to get the variables in order?
This is a small example
I2Coutput cmp setting1, #1 wz if_z mov sin, out1 if_z call #HalfSin if_z mov out1, sin cmp setting2, #1 wz if_z mov sin, out2 if_z call #HalfSin if_z mov out2, sin jmp #I2Coutput sin long 0 setting1 long 0 setting2 long 0 out1 long 0 out2 long 0
how would I use djnz and an index to get the variables in order?
Comments
I am currently at 328 longs on just this asm code so I want to make some subs to save memory.
You could do something like this:
In PASM code is data. Not only does code occupy the same RAM as "local variables", but there are instructions specifically for changing the source and destination registers (MOVS & MOVD). It is also possible to use ALU operations (i.e. ADD, SUB) on instructions to change the source and destination registers. Heck, just look at how JMPRET (the real instruction used for CALL & RET) works under the covers.
Eric, ya I am seeing this kind of code for the first time, I have always been a High Level programer. I started with GWBasic on an old TI back in the 80's but never got a chance to do Micro programing. Tolken ring style was wher I started and then when OOP came about I was all over that in Basic 6.0. I'm also a PLC programmer and I do some robotics in a java style language for ABB. Industrial Controls was always my interest untill someone showed me a PLC based off the Basic Stamp, and then I was all over Mico Programing. I find it fasinating to program at this level without needing much hardware.