// (D'Arcy's) shiftOut subroutine: // Assumption(s): ATmega328P, DATA on PB0, CLOCK on PB3, Latch is LOW // : LSBFIRST, data in r22 // Register Use: r23 for count "shiftOut: \n" // Shiftout subroutine LSBfirst "push r23 \n" // preserve incoming value in r23 "ldi r23,8 \n" // set count to 8 "nextBit: \n" "cbi 0x05,3 \n" // set clock LOW "cbi 0x05,0 \n" // assume data LOW "sbrc r22,0 \n" // skip next statement if our assumption was correct "sbi 0x05,0 \n" // set data HIGH "sbi 0x05,3 \n" // set clock HIGH "lsr r22 \n" // Shift the byte to the right one position "dec r23 \n" // reduce count "brne nextBit \n" // "pop r23 \n" // restore value in r23 for outgoing "ret \n" //