Additions:
+SJMP START
MOV R1, #255 ; Initialise register R1 for the masterclock.
MOV R2, #50 ; Initialise register R2 to count the cycles.
MOV R1, #6 ;; MAKE IT 6.
CJNE R2, #0, COMPAREDONE ;; IF R2 IS NOT ZERO, JUMP TO COMPAREDONE, OTHERWISE:
MOV R2, #255 ;; MASTERCLOCK, COUNTDOWN TO 0
TIMING:
MOV R0, #92 ;;ONE PHASE
TIMELORD: ;; ONE CLOCK TO COUNT 6 CYCLES
DJNZ R0, TIMELORD ;; IT LOOPS AROUND IN A CIRCLE UNTIL IT'S ZERO.
DJNZ R1, TIMELORDCONTINUED ;; COUNDOWN FROM 6 WHEN IT GETS TO ZERO, GO TO TIMELORDCONTINUED
TIMELORDCONTINUED: ;; ANOTHER CLOCK TO COUNT 50 CYCLES
CJNE R1, #0, TIMENEXT ;; IF R1 IS NOT ZERO, JUMP TO TIMENEXT, OTHERWISE:
DJNZ R2, TIMENEXT ;; COUNTDOWN FROM 50, R2, THEN GO TO TIMENEXT
TRANSMIT: ;;BREAKING THE LOOP, USING THE TWO COUNTERS SIMULTANEOUSLY,1.7 DOES STH WHEN ONE IS 2 AND THE OTHER IS 6
CJNE R1, #255, ENDTRANSMIT ;; TO TRANSMIT STH KEEP COMPARING UNTIL R1 IS NOT 2,IF IT IS NOT 2 THEN GO TO ENDTRANSMIT
CJNE R2, #50, ENDTRANSMIT ;; TO TRANSMIT STH KEEP COMAPRING UNTIL R2 IS NOT 6, IF IT NOT 6 GO TO ENDTRANSMIT
CPL P1.7 ;; If they ARE, toggle P1.7
RET ;; Back out.
CJNE R1, #255, ENDRECEIVE ;; If R1 != 4, jump to ENDRECEIVE
CJNE R2, #50, ENDRECEIVE ;; If R2 != 40, jump to ENDRECEIVE
CPL P1.6 ;; If they do though, toggle P1.6
RET ;; Back out.
CJNE R1, #255, ENDKEYBOARD ;; If R1 != 4, jump to ENDRECEIVE
CJNE R2, #50, ENDKEYBOARD ;; If R2 != 40, jump to ENDRECEIVE
CPL P1.5 ;; If they do though, toggle P1.5
RET ;; Back out.
END ; END the application.
Deletions:
SJMP START
MOV R1, #6 ; Initialise register R1 for the masterclock.
MOV R2, #50 ; Initialise register R2 to count the cycles.
MOV R1, #6 ;; MAKE IT 6.
CJNE R2, #0, COMPAREDONE ;; IF R2 IS NOT ZERO, JUMP TO COMPAREDONE, OTHERWISE:
MOV R2, #50 ;; MAKE IT 50
TIMING:
MOV R0, #92
TIMELORD:
DJNZ R0, TIMELORD ;; IT LOOPS AROUND IN A CIRCLE UNTIL IT'S ZERO.
DJNZ R1, TIMELORDCONTINUED ;; SUBTRACT 1 FROM R1, GO TO TIMELORDCONTINUED
TIMELORDCONTINUED:
CJNE R1, #0, TIMENEXT ;; IF R1 IS NOT ZERO, JUMP TO TIMENEXT, OTHERWISE:
DJNZ R2, TIMENEXT ;; SUBTRACT ONE FROM R2, GO TO TIMENEXT
TRANSMIT:
CJNE R1, #2, ENDTRANSMIT ;; If R1 != 2, jump to ENDTRANSMIT
CJNE R2, #6, ENDTRANSMIT ;; If R2 != 6, jump to ENDTRANSMIT
CPL P1.7 ;; If they do though, toggle P1.7
RET ;; Back out.
CJNE R1, #4, ENDRECEIVE ;; If R1 != 4, jump to ENDRECEIVE
CJNE R2, #40, ENDRECEIVE ;; If R2 != 40, jump to ENDRECEIVE
CPL P1.6 ;; If they do though, toggle P1.6
RET ;; Back out.
CJNE R1, #5, ENDKEYBOARD ;; If R1 != 4, jump to ENDRECEIVE
CJNE R2, #33, ENDKEYBOARD ;; If R2 != 40, jump to ENDRECEIVE
CPL P1.5 ;; If they do though, toggle P1.6
RET ;; Back out.
END ; END the application.
Additions:
KEYBOARD:
CJNE R1, #5, ENDKEYBOARD ;; If R1 != 4, jump to ENDRECEIVE
CJNE R2, #33, ENDKEYBOARD ;; If R2 != 40, jump to ENDRECEIVE
CPL P1.5 ;; If they do though, toggle P1.6
ENDKEYBOARD:
END ; END the application.
Deletions:
KEYBOARD: RET
END ; END the application.
Additions:
; Assumptions: 11.0592
CJNE R1, #2, ENDTRANSMIT ;; If R1 != 2, jump to ENDTRANSMIT
CJNE R2, #6, ENDTRANSMIT ;; If R2 != 6, jump to ENDTRANSMIT
CPL P1.7 ;; If they do though, toggle P1.7
RET ;; Back out.
CJNE R1, #4, ENDRECEIVE ;; If R1 != 4, jump to ENDRECEIVE
CJNE R2, #40, ENDRECEIVE ;; If R2 != 40, jump to ENDRECEIVE
CPL P1.6 ;; If they do though, toggle P1.6
RET ;; Back out.
END ; END the application.
Deletions:
; Assumptions: The TIMELORD is god.
CJNE R1, #2, ENDTRANSMIT
CJNE R2, #6, ENDTRANSMIT
CPL P1.7
CJNE R1, #4, ENDRECEIVE
CJNE R2, #40, ENDRECEIVE
CPL P1.6
END ; END the application.
Additions:
The flowchart that applies for this revision is available at
B164LFlowchart.
Additions:
CPL P1.6
Deletions:
CPL 1.6
Additions:
DJNZ R1, TIMELORDCONTINUED ;; SUBTRACT 1 FROM R1, GO TO TIMELORDCONTINUED
TIMELORDCONTINUED:
DJNZ R2, TIMENEXT ;; SUBTRACT ONE FROM R2, GO TO TIMENEXT
Deletions:
SUBB R1, #1 ;; SUBTRACT 1 FROM R1
SUBB R2, #1 ;; SUBTRACT ONE FROM R2
Additions:
; Assumptions: The TIMELORD is god.
ACALL COUNTERS
ACALL TIMING
ACALL TRANSMIT
ACALL RECEIVE
ACALL KEYBOARD
ACALL DISPLAY
;;;;; IF ANY OF OUR COUNTERS < 1, FIX IT.
COUNTERS:
CJNE R1, #0, COMPARENEXT ;; If R1 IS NOT ZERO, JUMP TO COMPARENEXT, OTHERWISE:
MOV R1, #6 ;; MAKE IT 6.
COMPARENEXT:
CJNE R2, #0, COMPAREDONE ;; IF R2 IS NOT ZERO, JUMP TO COMPAREDONE, OTHERWISE:
MOV R2, #50 ;; MAKE IT 50
COMPAREDONE:
;;;; ONE OF THESE = 1 PHASE OF 1 CYCLE.
TIMING:
MOV R0, #92
TIMELORD:
DJNZ R0, TIMELORD ;; IT LOOPS AROUND IN A CIRCLE UNTIL IT'S ZERO.
SUBB R1, #1 ;; SUBTRACT 1 FROM R1
CJNE R1, #0, TIMENEXT ;; IF R1 IS NOT ZERO, JUMP TO TIMENEXT, OTHERWISE:
SUBB R2, #1 ;; SUBTRACT ONE FROM R2
TIMENEXT:
TRANSMIT:
CJNE R1, #2, ENDTRANSMIT
CJNE R2, #6, ENDTRANSMIT
CPL P1.7
ENDTRANSMIT:
RECEIVE:
CJNE R1, #4, ENDRECEIVE
CJNE R2, #40, ENDRECEIVE
CPL 1.6
ENDRECEIVE:
KEYBOARD: RET
DISPLAY: RET
Deletions:
; Assumptions: Adam probably isn't showing up today. Carnage.
MOV R3, #4 ; We want to do something every 4 cycles.
ACALL CYCLECOUNTER ; go to the CYCLECOUNTER
;;;; SUBROUTINE: CYCLECOUNTER
CYCLECOUNTER:
ACALL MASTERCLOCK ; Run ONE cycle of the MASTERCLOCK
DJNZ R3, CYCLECOUNTERCONTINUED ; if r3 is not zero, go to cyclecountercontinued. if it is, do:
ACALL ONESIX ; toggle pin 1.6
MOV R3, #4
;;;; SUBROUTINE: CYCLECOUNTERCOUNTINUED
CYCLECOUNTERCONTINUED:
DJNZ R2, CYCLECOUNTER ; if r2 is not zero, do it again, if it is, move on.
MOV R1, #50 ; it's zero. set it back to 50 and
ACALL ONESEVEN ; toggle pin 1.7
RET ; go back to what we were doing before.
;;;; SUBROUTINE: MASTERCLOCK
MASTERCLOCK: ; More subroutines for timing.
ACALL TIMER ; Run the delay once -- one call to this makes ONE PHASE.
DJNZ R1, MASTERCLOCK ; if(registerR1 > 0){ goto MASTERCLOCK; registerR1 - 1 }else{ go to next line }
MOV R1, #6 ; It's 0. Set it back to 6.
RET ; E.T. Go home.
;;;; SUBROUTINE: TIMER
TIMER: ; Subroutine to do timing.
MOV R0, #92 ; Set reg. R0 to 92 (borrowed from initial lab.)
;;;; SUBROUTINE: TIMELOOP
TIMELOOP: ; Subroutine to assist with timing
; -- TIMER will run into this one after the MOV.
DJNZ R0, TIMELOOP ; (R0 = R0 - 1); if it's not 0, run again, otherwise, move on.
RET
;;;; SUBROUTINE: ONESIX
ONESIX:
JNB P1.6,ONESIXHIGH ; if P1.6 is low, this jumps to ONESIXHIGH
CLR P1.6 ; othewrise, set P1.6 low
;;;; SUBROUTINE: ONESIXHIGH
ONESIXHIGH:
SETB P1.6 ; Set P1.6 high
;;;; SUBROUTINE: ONESEVEN
ONESEVEN:
JNB P1.7,ONESEVENHIGH ; if P1.7 is low, this jumps to ONESIXHIGH
CLR P1.7 ; othewrise, set P1.7 low
;;;; SUBROUTINE: ONESEVENHIGH
ONESEVENHIGH:
SETB P1.7 ; Set P1.7 high
Additions:
MOV R3, #4
Deletions:
ACALL CYCLECOUNTERCONTINUED ; then go to cycle countercontinued
Deletions:
ACALL ONESEVEN ; Toggle P1.7
Additions:
; B164L Group: Y53 Authors: KCL, ANG, MP
; Date: 29.10.2008 VERSION 1.0
; Assumptions: Adam probably isn't showing up today. Carnage.
MOV R1, #6 ; Initialise register R1 for the masterclock.
MOV R2, #50 ; Initialise register R2 to count the cycles.
MOV R3, #4 ; We want to do something every 4 cycles.
SJMP MAIN ; Go to MAIN
;;;; SUBROUTINE: MAIN
ACALL CYCLECOUNTER ; go to the CYCLECOUNTER
ACALL ONESEVEN ; toggle pin 1.7
SJMP MAIN ; JUMP to the beginning.
;;;; SUBROUTINE: CYCLECOUNTER
CYCLECOUNTER:
ACALL MASTERCLOCK ; Run ONE cycle of the MASTERCLOCK
DJNZ R3, CYCLECOUNTERCONTINUED ; if r3 is not zero, go to cyclecountercontinued. if it is, do:
ACALL ONESIX ; toggle pin 1.6
ACALL CYCLECOUNTERCONTINUED ; then go to cycle countercontinued
;;;; SUBROUTINE: CYCLECOUNTERCOUNTINUED
CYCLECOUNTERCONTINUED:
DJNZ R2, CYCLECOUNTER ; if r2 is not zero, do it again, if it is, move on.
MOV R1, #50 ; it's zero. set it back to 50 and
RET ; go back to what we were doing before.
;;;; SUBROUTINE: MASTERCLOCK
MASTERCLOCK: ; More subroutines for timing.
ACALL TIMER ; Run the delay once -- one call to this makes ONE PHASE.
ACALL ONESEVEN ; Toggle P1.7
DJNZ R1, MASTERCLOCK ; if(registerR1 > 0){ goto MASTERCLOCK; registerR1 - 1 }else{ go to next line }
MOV R1, #6 ; It's 0. Set it back to 6.
;;;; SUBROUTINE: TIMER
TIMER: ; Subroutine to do timing.
MOV R0, #92 ; Set reg. R0 to 92 (borrowed from initial lab.)
;;;; SUBROUTINE: TIMELOOP
TIMELOOP: ; Subroutine to assist with timing
; -- TIMER will run into this one after the MOV.
RET
;;;; SUBROUTINE: ONESIX
JNB P1.6,ONESIXHIGH ; if P1.6 is low, this jumps to ONESIXHIGH
CLR P1.6 ; othewrise, set P1.6 low
;;;; SUBROUTINE: ONESIXHIGH
SETB P1.6 ; Set P1.6 high
;;;; SUBROUTINE: ONESEVEN
JNB P1.7,ONESEVENHIGH ; if P1.7 is low, this jumps to ONESIXHIGH
CLR P1.7 ; othewrise, set P1.7 low
;;;; SUBROUTINE: ONESEVENHIGH
SETB P1.7 ; Set P1.7 high
END ; END the application.
Deletions:
; B164L Group: Y53 Authors: KCL, ANG, MP
; Date: 29.10.2008 VERSION 1.0
; Assumptions: Obama got > 270 E.V. in the election.
MOV R1, #6 ; Initialise register R1 for the masterclock.
SJMP MAIN ; Go to MAIN
ACALL MASTERCLOCK ; go to the masterclock -- one call to this makes ONE CYCLE.
ACALL ONESIX ; Toggle P1.6
;ACALL SEND ; Call SEND
;ACALL RECEIVE ; Call RECEIVE
;ACALL KEYREAD ; Call KEYREAD
;ACALL LEDWRITE ; Call LEDWRITE
SJMP MAIN ; JUMP to the beginning.
MASTERCLOCK: ; More subroutines for timing.
ACALL TIMER ; Run the delay once -- one call to this makes ONE PHASE.
ACALL ONESEVEN ; Toggle P1.7
DJNZ R1, MASTERCLOCK ; if(registerR1 > 0){ goto MASTERCLOCK; registerR1 - 1 }else{ go to next line }
MOV R1, #6 ; It's 0. Set it back to 6.
TIMER: ; Subroutine to do timing.
MOV R0, #92 ; Set reg. R0 to 92 (borrowed from initial lab.)
TIMELOOP: ; Subroutine to assist with timing
; -- TIMER will run into this one after the MOV.
RET
JNB P1.6,ONESIXHIGH ; if P1.6 is low, this jumps to ONESIXHIGH
CLR P1.6 ; othewrise, set P1.6 low
SETB P1.6 ; Set P1.6 high
JNB P1.7,ONESEVENHIGH ; if P1.7 is low, this jumps to ONESIXHIGH
CLR P1.7 ; othewrise, set P1.7 low
SETB P1.7 ; Set P1.7 high
;SEND: RET ; Subroutine to send data.
;RECEIVE: RET ; Subroutine to receive data.
;KEYREAD: RET ; Subroutine to read from keyboard.
;LEDWRITE: RET ; Subroutine to write to the display.
END ; END the application.
Additions:
ORG 0
SJMP START
ORG 40H
START:
Additions:
ACALL MASTERCLOCK ; go to the masterclock -- one call to this makes ONE CYCLE.
ACALL ONESIX ; Toggle P1.6
ACALL TIMER ; Run the delay once -- one call to this makes ONE PHASE.
ACALL ONESEVEN ; Toggle P1.7
ONESIX:
JNB P1.6,ONESIXHIGH ; if P1.6 is low, this jumps to ONESIXHIGH
CLR P1.6 ; othewrise, set P1.6 low
RET
ONESIXHIGH:
SETB P1.6 ; Set P1.6 high
RET
ONESEVEN:
JNB P1.7,ONESEVENHIGH ; if P1.7 is low, this jumps to ONESIXHIGH
CLR P1.7 ; othewrise, set P1.7 low
RET
ONESEVENHIGH:
SETB P1.7 ; Set P1.7 high
RET
;SEND: RET ; Subroutine to send data.
;RECEIVE: RET ; Subroutine to receive data.
;KEYREAD: RET ; Subroutine to read from keyboard.
;LEDWRITE: RET ; Subroutine to write to the display.
Deletions:
ACALL MASTERCLOCK ; go to the masterclock
ACALL TIMER ; Run the delay once.
SEND:
SETB p1.7 ; Port 1, Pin 7 High
RET ; Subroutine to send data.
RECEIVE:
CLR p1.7 ; Port 1, Pin 7 Low
RET ; Subroutine to receive data.
KEYREAD: RET ; Subroutine to read from keyboard.
LEDWRITE: RET ; Subroutine to write to the display.
Additions:
; Assumptions: Obama got > 270 E.V. in the election.
MOV R1, #6 ; Initialise register R1 for the masterclock.
; 6 phases to each cycle.
SJMP MAIN ; Go to MAIN
MAIN: ; Define the MAIN subroutine..
ACALL MASTERCLOCK ; go to the masterclock
;ACALL SEND ; Call SEND
;ACALL RECEIVE ; Call RECEIVE
MASTERCLOCK: ; More subroutines for timing.
ACALL TIMER ; Run the delay once.
DJNZ R1, MASTERCLOCK ; if(registerR1 > 0){ goto MASTERCLOCK; registerR1 - 1 }else{ go to next line }
MOV R1, #6 ; It's 0. Set it back to 6.
RET ; E.T. Go home.
SETB p1.7 ; Port 1, Pin 7 High
Deletions:
; Assumptions: Assuming makes an Ass out of you.
MAIN: ; Define the MAIN subroutine.
ACALL SEND ; Call SEND
ACALL TIMER
ACALL RECEIVE ; Call RECEIVE
ACALL TIMER
SETB p1.7 ; Port 1, Pin 7 High
Additions:
SJMP MAIN ; JUMP to the beginning.
Deletions:
ACALL MAIN ; Call the beginning.
ACALL TIMER
Additions:
%%(asm)
Additions:
Additions:
Additions:
ACALL TIMER
RET
Deletions:
ACALL TIMER ; Call TIMER
RET ; The TIMELOOP is done, go back to TIMER.
RET ; TIMER is done, go back to MAIN.
Additions:
ACALL TIMER
;ACALL KEYREAD ; Call KEYREAD
;ACALL LEDWRITE ; Call LEDWRITE
SETB p1.7 ; Port 1, Pin 7 High
RET ; The TIMELOOP is done, go back to TIMER.
RET ; TIMER is done, go back to MAIN.
END ; END the application.
Deletions:
ACALL KEYREAD ; Call KEYREAD
ACALL LEDWRITE ; Call LEDWRITE
SETB p1.7 ; Port 1, Pin 7 High
RET ; The timer is done, go back to MAIN.
END ; END the application.
Categories:
CategoryUni
$include (reg66x.inc)
; B164L Group: Y53 Authors: KCL, ANG, MP
; Date: 29.10.2008 VERSION 1.0
; Summay: This is a framework for the ethernet project.
; Input: 3 buttons, "network data"
; Output: 3 LEDs, "network data"
; Assumptions: Assuming makes an Ass out of you.
MAIN: ; Define the MAIN subroutine.
ACALL SEND ; Call SEND
ACALL TIMER ; Call TIMER
ACALL RECEIVE ; Call RECEIVE
ACALL KEYREAD ; Call KEYREAD
ACALL LEDWRITE ; Call LEDWRITE
ACALL MAIN ; Call the beginning.
SEND:
SETB p1.7 ; Port 1, Pin 7 High
RET ; Subroutine to send data.
RECEIVE:
CLR p1.7 ; Port 1, Pin 7 Low
RET ; Subroutine to receive data.
KEYREAD: RET ; Subroutine to read from keyboard.
LEDWRITE: RET ; Subroutine to write to the display.
TIMER: ; Subroutine to do timing.
MOV R0, #92 ; Set reg. R0 to 92 (borrowed from initial lab.)
TIMELOOP: ; Subroutine to assist with timing
; -- TIMER will run into this one after the MOV.
DJNZ R0, TIMELOOP ; (R0 = R0 - 1); if it's not 0, run again, otherwise, move on.
RET ; The timer is done, go back to MAIN.
END ; END the application.
Categories:
CategoryUni