0 Members and 1 Guest are viewing this topic.
include "ez8.inc"vector reset = 1000horg 1000hmain: di ;Disable interrupts as we won't be using them srp #00h ;Set working registers base address (Working registers are R0-R15) ldx SPH,#00h ;Set stack pointer base address ldx SPL,#FFh ;(the stack is 00ffh - 0000h so 256 bytes large) ldx PAADDR, #01h ;Access the data direction subregister ldx PACTL,#00h ;Set data direction of port B to all outputs. 0 = output, 1 = input ld R4, #77h ;Load register R0 with EEh. This will be our rotated value. brk ;Breakpoint. The debugger will stop the cpu here.Press the go button to ;continue execution.loop: ldx PAOUT, R4 ;Load the output register of port B with the value of our counter. rr R4 ;Increase our counter by 1. call delay ;Call our delay function. jp loop ;Jump back to loopdelay: ld R0,#0Fh ;Load value 0FFFh in the 16 bit register pair RR0 (consists of R0 and R1) ld R1,#FFhouter: ld R2,#FFh ;Load value 0FFh in 8 bit register R2 djnz R2,$ ;Decrease decw RR0 jp nz, outer ;While the register pair has not reached 0 (nz) yet jump back to outer ret ;Return from routine