'Assembler HCS12 how does register with index work with TST-instruction?
Hello this is my test code:
LDX #$2000
LDY #$1000
LDD #$0000
la: ADDD #1
MOVB 1, X+, 1, Y+
TST -1, X <-- what do I check here?
BNE la
My question is what do I check with the TST -1,X? I know that TST checks if my register is 0 or negative. But what does -1, X mean?. When is this condition not true?
Solution 1:[1]
This is a copy function, possibly used for null terminated strings. X
and Y
are the 16 bit index registers used to hold addresses.
With MOVB 1, X+, 1, Y+
you first move the data from address X
to Y
and then post-increment both addresses. TST -1, X
checks the contents of the address that X
had before that post-increment. If not zero then loop, otherwise stop.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Lundin |