In SX Microcontrollers, SX/B Compiler and SX-Key Tool, whelm wrote: 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? ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=181670 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)