2003-03-24 03:25 AM
2003-03-20 11:30 PM
In ST7 code I am DEC a var in RAM.
In ST6 code you could DEC and then JRNZ as the zero flag is set when zero value is reached. It seems in ST7 the conditional flags are not affected with a RAM variable, is there an easy way to DEC or INC a value and the jump / branch when zero reached.2003-03-21 12:41 AM
try to OR your val and then check Zero flag
2003-03-21 03:43 AM
Hi,
I've just tried some code, the Z flag was set when a RAM variable reached zero using DEC If you do LD A, var If var is zero the zero flag will be set Also, if you TNZ var the z is set if the value of var is zero Hope this helps regards, Simon [ This message was edited by: sjh on 12-11-2003 16:21 ]2003-03-23 03:57 PM
Hello,
The conditional flags are affected by operations on RAM variables too. The instructions for jumping on status of zero flag are JREQ and JRNE, though there is a restriction that the jump is within a range of -127 to +128 bytes around the instruction.2003-03-23 08:02 PM
Below is from Page 47 of the ST7 instuction set.
The destination byte is read, then decremented by one, and the result is written at the destination byte. The destination is either a memory byte or a register. This instruction is compact, and does not affect any register when used with RAM variables. Now I Interpret this as in you DEC A, X & Y then the Z is affected but if you use your own variable then it is not. I understand that you can load the variable and check it but in the ST6 code you could just to the following:- DEC secs JRNZ loop [ This message was edited by: BrianM on 24-03-2003 09:35 ]2003-03-23 09:30 PM
Well,
In ST7 we can say dec secs jrne loop It is better to refer to the STVD7 ''Help on Instruaction'' online help.2003-03-23 10:37 PM
Quote:
On 2003-03-24 09:32, BrianM wrote: Below is from Page 47 of the ST7 instuction set. This instruction is compact, and does not affect any register when used with RAM variables. Now I Interpret this as in you DEC A, X & Y then the Z is affected but if you use your own variable then it is not. This means that A,X and Y are not changed or used in the process. The status flags are affected. Simon2003-03-24 12:55 AM
To give a conclusion. Yes, DEC and INC instructions affect N and Z flags (refer to the ST7 instruction set available in this site) whatever the variable is (a register: A, X or Y or a RAM0 variable, which means a variable with a short address (a byte as address)).
So, JRNE or JREQ can be used to branch depending on the Z flag value. So the code can be: BYTES segment 'ram0' .var DS.B 1 WORDS segment 'rom' .main ld A,#4 ld var,A again dec var jrne again ..... you'll exit from the dec loop when var=0! Hope it will help! A simple way to check this kind of things is to use the simulator STVD7 (given for free on this site) and the ST7 assembly tool chain! [ This message was edited by: stef on 24-03-2003 14:26 ][ This message was edited by: stef on 24-03-2003 14:27 ]2003-03-24 03:25 AM
Thank you all for your help