diff options
Diffstat (limited to 'cmpen472_hw8McDonnell/bin/main.dbg')
| -rw-r--r-- | cmpen472_hw8McDonnell/bin/main.dbg | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/cmpen472_hw8McDonnell/bin/main.dbg b/cmpen472_hw8McDonnell/bin/main.dbg index 9467888..ee34a63 100644 --- a/cmpen472_hw8McDonnell/bin/main.dbg +++ b/cmpen472_hw8McDonnell/bin/main.dbg @@ -144,6 +144,10 @@ mainLoop ldy lenInput ; Load the length of inputBuffer into Y jsr Zeros ; Zero out inputBuffer + sei ; Disable interrupts + jsr PrintTime ; Jump to PrintTime to print new time + cli ; Enable interrupts + bra mainLoop ; Loop back to mainLoop always TypeWrite @@ -195,7 +199,8 @@ rtidone jsr PrintTime ; Jump to PrintTime rtiSkip pulx ; Restore X from the stack RTI -PrintTime pshd ; Save D to the stack +PrintTime + pshd ; Save D to the stack pshy ; Save Y to the stack pshx ; Save X to the stack ldaa #CR ; Load the character CR into A @@ -251,10 +256,46 @@ goodSecs ldy #buffer ; Load the address of buffer into Y ExecuteCommand pshd ; Save D to the stack + pshy ; Save Y to the stack ldaa 1,x+ ; Load the character from X into A - beq ecDone ; If A == 0, jump to ecDone + lbeq ecDone ; If A == 0, jump to ecDone cmpa #'t' ; Compare A to 't' bne isH ; If A != 't', branch to isH +skipSpaces ldaa 1,+x ; Load the next character into X + cmpa #' ' ; Compare A to ' ' character + beq skipSpaces ; If A == ' ', loop to skipSpaces + sei ; Disable interrupts + jsr ReadDecimal ; Read Hour number + exg y,d ; Exchange Y and D + cpd #24 ; Compare D to 24 + bhs badCommand ; If D >= 24, badCommand + cpd #0 ; Compare D to 0 + blt badCommand ; If D < 0, badCommand + std hours ; Save D to hours + ldaa -1,x ; Load the next character into A + cmpa #':' ; Compare A to ':' + bne badCommand ; If A != ':', bad command + jsr ReadDecimal ; Read minute number + exg y,d ; Exchange Y and D + cpd #60 ; Compare D to 60 + bhs badCommand ; If D >= 60, badCommand + cpd #0 ; Compare D to 0 + blt badCommand ; If D < 0, badCommand + std minutes ; Save D to minutes + ldaa -1,x ; Load the next character into A + cmpa #':' ; Compare A to ':' + bne badCommand ; If A != ':', bad command + jsr ReadDecimal ; Read second number + exg y,d ; Exchange Y and D + cpd #60 ; Compare D to 60 + bhs badCommand ; If D >= 60, badCommand + cpd #0 ; Compare D to 0 + blt badCommand ; If D < 0, badCommand + std seconds ; Save D to seconds + ldaa -1,x ; Load the next character into A + cmpa #NULL ; Compare A to NULL + bne badCommand ; If A != ':', bad command + cli ; Enable interrupts bra ecDone ; Branch to ecDone isH cmpa #'h' ; Compare A to 'h' bne isM ; If A != 'h', branch to isM @@ -283,16 +324,17 @@ isQ cmpa #'q' ; Compare A to 'q' cmpb #NULL ; Compare B to NULL bne badCommand ; If B != NULL, branch to ecDone jmp TypeWrite ; Jump to TypeWrite -badCommand pshx ; Save X to the stack +badCommand cli ; Reenable interrupts + pshx ; Save X to the stack ldx #error ; Load the address of the error prompt into X jsr WriteString ; Jump to WriteString ldx #badInput ; Load the address of badInput into X jsr WriteString ; Jump to WriteString - pulx ; Restore X from stack -ecDone puld ; Restore D from the stack + pulx ; Restore X from the stack +ecDone puly ; Restore Y from the stack + puld ; Restore D from the stack rts ; Return to caller - ;************************************************************************* ; ReadDecimal subroutine ; @@ -323,6 +365,8 @@ dHLoop ldab 1,x+ ; Read Next character from X beq dHDone ; If B == '+', end of number cmpb #'/' ; Compare B to '/' beq dHDone ; If B == '-', end of number + cmpb #':' ; Compare B to ':' + beq dHDone ; If B == '-', end of number cmpb #' ' ; Compare B to space character beq dHDone ; If B == ' ', exit loop cmpb #'0' ; Compare B to '0' character |
