summaryrefslogtreecommitdiff
path: root/cmpen472_hw8McDonnell/bin/main.dbg
diff options
context:
space:
mode:
Diffstat (limited to 'cmpen472_hw8McDonnell/bin/main.dbg')
-rw-r--r--cmpen472_hw8McDonnell/bin/main.dbg60
1 files changed, 45 insertions, 15 deletions
diff --git a/cmpen472_hw8McDonnell/bin/main.dbg b/cmpen472_hw8McDonnell/bin/main.dbg
index ee34a63..6d18ef7 100644
--- a/cmpen472_hw8McDonnell/bin/main.dbg
+++ b/cmpen472_hw8McDonnell/bin/main.dbg
@@ -99,9 +99,9 @@ outputBuf dc.b 'h' ; Used to control what to output on 7 se
*
* There is a section Data Section at the end of the file
**************************************************************************
-* Interrupt Vector Section: address used [ $FFF0 to $FFFF ] RAM Memory
+* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory
*
- org $FFF0 ; Memory location for Interrupt vector section for simulator
+ org $FFF0 ; Memory location for RTI interrupt vector section for simulator
dc.w rtiisr ; Real Time Interrupt vector
*
**************************************************************************
@@ -127,6 +127,9 @@ pgstart lds #$3100 ; initialize the stack pointer
bset CRGINT,%10000000; enable RTI interrupt
bset CRGFLG,%10000000; clear RTI IF (Interrupt Flag)
+ ldaa #$FF ; Two 7 segment displays on PORTB
+ staa DDRB ; Set all of PORTB as output
+
ldx #inputBuffer ; Load the address of inputBuffer into X
ldy lenInput ; Load the length of inputBuffer into Y
jsr Zeros ; Zero out inputBuffer
@@ -158,6 +161,7 @@ TypeWrite
twLoop jsr getchar ; Read a character from the serial console
tsta ; Compare A to 0
beq twLoop ; If A == 0, branch to twLoop
+ staa PORTB ; Write A to PORTB
jsr putchar ; Write character to serial console
bra twLoop ; Branch always to twLoop
@@ -166,12 +170,11 @@ twLoop jsr getchar ; Read a character from the serial conso
*
rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag
- pshx ; Save X to the stack
ldx counter ; Load counter into X
inx ; Increment counter by 1
stx counter ; Save X to counter
- cpx #9000 ; Compare counter to 9000, This is about 1 second on my computer
- bne rtiSkip ; If counter != 400, branch to rtiSkip
+ cpx #200 ; Compare counter to 200, This is about 1 second on my computer
+ bne rtiSkip ; If counter != 200, branch to rtiSkip
ldx #0 ; Load 0 into X
stx counter ; Save X to counter
ldx seconds ; Load the seconds into X
@@ -196,8 +199,7 @@ rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag
ldx #0 ; Reset the hours
stx hours ; Save the updated hours
rtidone jsr PrintTime ; Jump to PrintTime
-rtiSkip pulx ; Restore X from the stack
- RTI
+rtiSkip RTI ; Return from RTI ISR
PrintTime
pshd ; Save D to the stack
@@ -249,11 +251,40 @@ goodSecs ldy #buffer ; Load the address of buffer into Y
jsr WriteString ; Write the string to the serial
ldx #inputBuffer ; Load the address of the inputBuffer into X
jsr WriteString ; Write the string to the serial
+ ldaa outputBuf ; Load outputBuf into A
+ cmpa #'h' ; Compare A to 'h'
+ bne pTimeIsM ; If A != 'h', branch to pTimeIsM
+ ldd hours ; Load hours into B
+ bra skipRest ; Jump to skipRest
+pTimeIsM cmpa #'m' ; Compare A to 'm'
+ bne pTimeIsS ; If A != 'm', branch to pTimeIsS
+ ldd minutes ; Load Minutes into D
+ bra skipRest ; Jump to skipRest
+pTimeIsS ldd seconds ; Load seconds into D
+skipRest jsr TimeOnPortB ; Call TimeOnPortB to output time
pulx ; Restore X from the stack
puly ; Restore Y from the stack
puld ; Restore D from the stack
rts ; Return to caller
+TimeOnPortB
+ pshd ; Save D to the stack
+ pshx ; Save X to the stack
+ ldx #10 ; Load 10 into X to get digit
+ idiv ; Divide D by X and save Digit into D
+ pshb ; Save B to the stack (Lower Byte of D)
+ exg x,d ; Swap X and D
+ ldx #10 ; Load 10 into X to get digit
+ lslb ; Shift B left by 1
+ lslb ; Shift B left by 1
+ lslb ; Shift B left by 1
+ lslb ; Shift B left by 1
+ orab 1,sp+ ; Or B with Digit on stack
+ stab PORTB ; Save B to PORTB
+ pulx ; Restore X from the stack
+ puld ; Restore D from the stack
+ rts ; Return from caller
+
ExecuteCommand
pshd ; Save D to the stack
pshy ; Save Y to the stack
@@ -326,6 +357,11 @@ isQ cmpa #'q' ; Compare A to 'q'
jmp TypeWrite ; Jump to TypeWrite
badCommand cli ; Reenable interrupts
pshx ; Save X to the stack
+ ldaa #' ' ; Load Space character into A
+ jsr putchar ; Jump to putchar to write space character
+ jsr putchar ; Jump to putchar to write space character
+ jsr putchar ; Jump to putchar to write space character
+ jsr putchar ; Jump to putchar to write space character
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
@@ -583,9 +619,7 @@ readLoop jsr getchar ; Jump to putchar to write byte to seria
dey ; Decrement Y by 1
beq doneRead ; If Y == 0, no more room, stop reading
bra readLoop ; branch always to readLoop
-doneRead ldaa #LF ; Load Line Feed into A
- jsr putchar ; Write LF to terminal
- pulx ; Restore X from the stack
+doneRead pulx ; Restore X from the stack
pulY ; Restore Y from the stack
pula ; restore A from the stack
rts ; return to caller
@@ -627,17 +661,13 @@ getchar7 clra ; Set A to 0
* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory
*
-invalidStr dc.b 'Invalid Input',CR,LF,NULL ; Invalid input error message
-
clock dc.b 'Clock> ',NULL ; Prompt string for clock
CMD dc.b 'CMD> ',NULL ; Prompt string for CMD
error dc.b 'Error> ',NULL ; Prompt string for errors
-badInput dc.b 'Invalid Input',CR,LF,NULL ; Invalid Input Prompt
-
-overflow dc.b 'Overflow Error',CR,LF,NULL ; Overflow error message
+badInput dc.b 'Invalid Input',NULL ; Invalid Input Prompt
; twMsg: welcome message for typewrite
twMsg dc.b 'Clock stopped and Typewrite program started.',CR,LF