SX-48 Code
What's wrong with this code?
··mov···· W,#$1F···;Set Mode to 1Fh to set direction bits
··mov·M,W
··mov·!rd,#0···;Set ports D and E direction OUT
··mov·!re,#0
··clr·GTmpL···;Use these to waste some time
··clr·GTmpH
··mov·GTemp,128
··clr·re
··mov·w,#$0F···;Move them down again.· All bits have been toggled once
··mov·rd,W
s4··decsz·GTmpL
··jmp···· s4
··clc····;inner loop should take 21.3 us
· snb·re.5··;rotate RE.5 to RD.0 and through RD and RE
··stc
··rl·rd
··rl·re
··decsz·GTmpH
··jmp·s4
It is supposed to walk a pattern of four 1s through RD and the first six bits of RE.
The pattern goes through RD, but never gets to RE.· I tried placing a NOP between the two rl commands--it did no good
I modified the code to do the shifting in variables, as shown below and it worked fine.
··bank·TaskBank
··clrb·FSR.7
··mov·w,#$0F
··mov·rd,W
··mov·PatternL,w··;Set up fast walking pattern to toggle pins
··clr·PatternH
s4··decsz·GTmpL
··jmp···· s4
··clc
· snb·PatternH.5··;rotate RE.5 to RD.0 and through RD and RE
··stc
··rl·PatternL
··mov·rd,PatternL
··rl·PatternH
··mov·re,PatternH
··decsz·GTmpH
··jmp·s4
So why can rl get a carry out of RAM, but not out of a port?· Or is it failing to put the carry in RE?
·
··mov···· W,#$1F···;Set Mode to 1Fh to set direction bits
··mov·M,W
··mov·!rd,#0···;Set ports D and E direction OUT
··mov·!re,#0
··clr·GTmpL···;Use these to waste some time
··clr·GTmpH
··mov·GTemp,128
··clr·re
··mov·w,#$0F···;Move them down again.· All bits have been toggled once
··mov·rd,W
s4··decsz·GTmpL
··jmp···· s4
··clc····;inner loop should take 21.3 us
· snb·re.5··;rotate RE.5 to RD.0 and through RD and RE
··stc
··rl·rd
··rl·re
··decsz·GTmpH
··jmp·s4
It is supposed to walk a pattern of four 1s through RD and the first six bits of RE.
The pattern goes through RD, but never gets to RE.· I tried placing a NOP between the two rl commands--it did no good
I modified the code to do the shifting in variables, as shown below and it worked fine.
··bank·TaskBank
··clrb·FSR.7
··mov·w,#$0F
··mov·rd,W
··mov·PatternL,w··;Set up fast walking pattern to toggle pins
··clr·PatternH
s4··decsz·GTmpL
··jmp···· s4
··clc
· snb·PatternH.5··;rotate RE.5 to RD.0 and through RD and RE
··stc
··rl·PatternL
··mov·rd,PatternL
··rl·PatternH
··mov·re,PatternH
··decsz·GTmpH
··jmp·s4
So why can rl get a carry out of RAM, but not out of a port?· Or is it failing to put the carry in RE?
·