summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2025-04-07 20:14:07 -0400
committerJacob McDonnell <jacob@jacobmcdonnell.com>2025-04-07 20:14:07 -0400
commitc785e7f8c1e0b58fb0b911703599bd9e65e1841b (patch)
tree05ef539bfdbcd3092b307d997a71e1f878ef8cfe
parent2fd1f7292d432684783e021c149e89c275f69334 (diff)
HW10: 8KHz waves functional and ready
-rw-r--r--cmpen472hw10_McDonnell/Sources/main.asm380
-rw-r--r--cmpen472hw10_McDonnell/bin/Project.absbin10518 -> 10894 bytes
-rw-r--r--cmpen472hw10_McDonnell/bin/Project.abs.phy4
-rw-r--r--cmpen472hw10_McDonnell/bin/Project.abs.s19129
-rw-r--r--cmpen472hw10_McDonnell/bin/main.dbg380
-rw-r--r--cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.obin10518 -> 10894 bytes
-rw-r--r--cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.sx129
-rw-r--r--cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/TargetDataWindows.tdtbin66759 -> 62911 bytes
8 files changed, 400 insertions, 622 deletions
diff --git a/cmpen472hw10_McDonnell/Sources/main.asm b/cmpen472hw10_McDonnell/Sources/main.asm
index 5be05f0..2d80cd9 100644
--- a/cmpen472hw10_McDonnell/Sources/main.asm
+++ b/cmpen472hw10_McDonnell/Sources/main.asm
@@ -113,7 +113,7 @@ numPoints dc.w 2048 ; Max Number of points for waves
timeTrigger dc.b $00 ; Tracks when timer is triggered
-waveType dc.b 'q' ; Used to track wave type 'T' for increasing triangle,
+waveType dc.b 'S' ; Used to track wave type 'T' for increasing triangle,
; 't' for decreasing triangle,
; 'Q' for square high
; 'q' for square low
@@ -161,26 +161,20 @@ pgstart lds #$3100 ; initialize the stack pointer
cli ; Enable interrupts
mainLoop
+ ldaa #'>' ; Load '>' character
+ jsr putchar ; Print to serial console
+ ldaa #' ' ; Load ' ' character
+ jsr putchar ; Print to serial console
ldx #inputBuffer ; Load the address of inputBuffer into X
ldy lenInput ; Load the length of inputBuffer into Y
jsr ReadString ; Jump to ReadString to read input
- ldd #0 ; Clear D
- std outputCnt ; Clear outputCnt
- staa outputVal ; Clear outputVal
-
- jsr StartTimer5oc ; Start Timer on CH5
-
-looooop ldaa timeTrigger
- beq looooop
- clra
- staa timeTrigger
- jsr PrintWave ; Jump to PrintWave
- ldd outputCnt
- cpd numPoints
- blo looooop
+ ldx #inputBuffer ; Load the address of inputBuffer into X
+ jsr ExecuteCommand ; Jump to ExecuteCommand
- jsr StopTimerCH5
+ ldx #inputBuffer ; Load the address of inputBuffer into X
+ ldy lenInput ; Load the length of inputBuffer into Y
+ jsr Zeros ; Zero out input buffer
bra mainLoop ; Loop back to mainLoop always
@@ -395,6 +389,27 @@ StopTimerCH5
pula ; Restore A from the stack
rts ; Return
+GenWave
+ pshd ; Save D to the stack
+ ldd #0 ; Clear D
+ std outputCnt ; Clear outputCnt
+ staa outputVal ; Clear outputVal
+
+ jsr StartTimer5oc ; Start Timer on CH5
+
+
+genLoop ldaa timeTrigger ; Load timeTrigger into A
+ beq genLoop ; If A == 0, loop
+ clra ; Clear A
+ staa timeTrigger ; Clear timeTrigger
+ jsr PrintWave ; Jump to PrintWave
+ ldd outputCnt ; Load outputCnt into D
+ cpd numPoints ; Compare D to numPoints
+ blo genLoop ; If D < numPoints, Loop
+
+ jsr StopTimerCH5 ; Turn off timer
+ puld ; Restore D from the stack
+ rts ; Return
;*************************************************************************
; PrintTime subroutine
@@ -431,28 +446,6 @@ skipRest jsr TimeOnPortB ; Call TimeOnPortB to output time
rts ; Return to caller
;*************************************************************************
-; PrintPrompt subroutine
-;
-; This subroutine will output the CMD prompt and any current input to the serial console
-;
-; Input: No Input
-; Output: The CMD prompt and any input onto the serial console
-; Registers in use: X for addresses of strings
-; Memory locations in use: PORTB memory location, CMD prompt memory locaiton, inputBuffer location
-;
-; Comments: This subroutine requires WriteString subroutine.
-;
-
-PrintPrompt
- pshx ; Save X to the stack
- ldx #CMD ; Load the address of CMD into X
- 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
- pulx ; Restore X from the stack
- rts ; Return
-
-;*************************************************************************
; TimeOnPortB subroutine
;
; This subroutine will output the time given on on PORTB for two seven segment displays.
@@ -527,64 +520,121 @@ skipSpaces ldaa 1,+x ; Load the next character into X
jsr ReadDecimal ; Read minute number
exg y,d ; Exchange Y and D
cpd #60 ; Compare D to 60
- bhs badMinutes ; If D >= 60, badMinutes
+ lbhs badMinutes ; If D >= 60, badMinutes
cpd #0 ; Compare D to 0
- blt badMinutes ; If D < 0, badMinutes
+ lblt badMinutes ; If D < 0, badMinutes
std minutes ; Save D to minutes
ldaa -1,x ; Load the next character into A
cmpa #':' ; Compare A to ':'
- bne badMinutes ; If A != ':', badMinutes
+ lbne badMinutes ; If A != ':', badMinutes
ldd seconds ; Load seconds into D
pshd ; Save seconds to the stack
jsr ReadDecimal ; Read second number
exg y,d ; Exchange Y and D
cpd #60 ; Compare D to 60
- bhs badSeconds ; If D >= 60, badSeconds
+ lbhs badSeconds ; If D >= 60, badSeconds
cpd #0 ; Compare D to 0
- blt badSeconds ; If D < 0, badSeconds
+ lblt badSeconds ; If D < 0, badSeconds
std seconds ; Save D to seconds
ldaa -1,x ; Load the next character into A
cmpa #NULL ; Compare A to NULL
- bne badSeconds ; If A != ':', badSeconds
+ lbne badSeconds ; If A != ':', badSeconds
clra ; Set A to 0
staa counter ; Clear Counter
cli ; Enable interrupts
puld ; Restore D from the stack
puld ; Restore D from the stack
puld ; Restore D from the stack
- bra ecDone ; Branch to ecDone
+ lbra ecDone ; Branch to ecDone
isH cmpa #'h' ; Compare A to 'h'
bne isM ; If A != 'h', branch to isM
ldab 1,x+ ; Load next character into B
cmpb #NULL ; Compare B to NULL
- bne badCommand ; If B != CR, bad command
+ lbne badCommand ; If B != CR, bad command
staa outputBuf ; Store A into outputBuf
- bra ecDone ; Branch to ecDone
+ lbra ecDone ; Branch to ecDone
isM cmpa #'m' ; Compare A to 'm'
bne isS ; If A != 'm', branch to isS
ldab 1,x+ ; Load next character into B
cmpb #NULL ; Compare B to NULL
- bne badCommand ; If B != CR, bad command
+ lbne badCommand ; If B != CR, bad command
staa outputBuf ; Store A into outputBuf
- bra ecDone ; Branch to ecDone
+ lbra ecDone ; Branch to ecDone
isS cmpa #'s' ; Compare A to 's'
bne isQ ; If A != 's', branch to isQ
ldab 1,x+ ; Load next character into B
cmpb #NULL ; Compare B to NULL
- bne badCommand ; If B != CR, bad command
+ lbne badCommand ; If B != CR, bad command
staa outputBuf ; Store A into outputBuf
- bra ecDone ; Branch to ecDone
+ lbra ecDone ; Branch to ecDone
isQ cmpa #'q' ; Compare A to 'q'
- bne isEquation ; If A != 'q', branch to isEquation
+ bne isGw ; If A != 'q', branch to isGw
ldab 1,x+ ; Load next character into B
cmpb #NULL ; Compare B to NULL
- bne badCommand ; If B != NULL, branch to ecDone
+ lbne badCommand ; If B != NULL, branch to ecDone
jmp TypeWrite ; Jump to TypeWrite
-isEquation dex ; Decrement X by 1
- jsr VerifyInput ; Verify input is valid equation
- beq badCommand ; If Z == 1, badCommand
- jsr Solve ; Jump to Solve to solve equation
- bra ecDone ; Branch always to ecDone
+isGw cmpa #'g' ; Compare A to 'g'
+ lbne badCommand ; If A != 'g', branch to badCommand
+ ldaa 1,x+ ; Load next character into B
+ cmpa #'w' ; Compare A to 'w'
+ bne isGt ; If A != 'w', branch to isGt
+ ldab 1,x+ ; Load next charater into B
+ cmpb #NULL ; Compare B to NULL
+ bne isGw2 ; If B != NULL, branch to isGw2
+ ldx #swMsg ; Load address of sawtooth message
+ jsr WriteString ; Write string
+ ldaa #'S' ; Load 'S' for sawtooth
+ staa waveType ; Save A to waveType
+ jsr GenWave ; Jump to GenWave
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
+isGw2 cmpb #'2' ; Compare B to '2'
+ lbne badCommand ; If B != '2', bad
+ ldab 1,x+ ; Load next character into B
+ cmpb #NULL ; Compare to NULL
+ lbne badCommand ; Not NULL? bad
+ ldx #sw2Msg ; Load address of sawtooth 125Hz message
+ jsr WriteString ; Write string
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
+isGt cmpa #'t' ; Compare A to 't'
+ bne isGq ; If A != 't', branch to isGq
+ ldab 1,x+ ; Load next character into B
+ cmpb #NULL ; Compare to NULL
+ lbne badCommand ; A != NULL? bad
+ ldx #tMsg ; Load address of triangle message
+ jsr WriteString ; Write string
+ ldaa #'T' ; Load 'T' for triangle
+ staa waveType ; Save A to waveType
+ jsr GenWave ; Jump to GenWave
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
+isGq cmpa #'q' ; Compare A to 'q'
+ lbne badCommand ; A != 'q'? bad
+ ldab 1,x+ ; Load next character into B
+ cmpb #NULL ; Compare B to NULL
+ bne isGq2 ; B != NULL? isGq2
+ ldx #sqMsg ; Load address of square message
+ jsr WriteString ; Write string
+ ldaa #'q' ; Load 'q' for square
+ staa waveType ; Save A to waveType
+ jsr GenWave ; Jump to GenWave
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
+isGq2 cmpb #'2' ; Compare B to '2'
+ lbne badCommand ; B != '2'? bad
+ ldab 1,x+ ; Load next character into B
+ cmpb #NULL ; Compare B to NULL
+ bne badCommand ; B != NULL? bad
+ ldx #sq2Msg ; Load address of square 125Hz message
+ jsr WriteString ; Write string
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
badSeconds puld ; Restore Seconds from the stack
std seconds ; Restore seconds before change
badMinutes puld ; Restore minutes from the stack
@@ -593,13 +643,6 @@ badHours puld ; Restore hours from the stack
std hours ; Restore hours before change
cli ; Reenable interrupts
badCommand 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
jsr WriteString ; Jump to WriteString
pulx ; Restore X from the stack
@@ -608,182 +651,6 @@ ecDone puly ; Restore Y from the stack
rts ; Return to caller
;*************************************************************************
-; Solve subroutine
-;
-; This subroutine will solve the math equation in the given string.
-;
-; Input: Address of null terminated string in X.
-; Output: No Output, Control flow changed to proper subroutine.
-; Registers in use: X for the address of the string, A & B to read characters from
-; from the string.
-; Memory locations in use: Memory Address for serial line, address of the string, numBuf word
-;
-; Comments: This subroutine EXPECTS the input to be valid. RUN VerifyInput BEFORE
-; TO MAKE SURE THE STRING IS VALID, OTHERWISE THERE WILL BE ERRORS.
-;
-
-Solve
- pshy ; Save Y to the stack
- pshd ; Save D to the stack
- pshx ; Save X to the stack
- jsr ReadDecimal ; Read First number
- pshy ; Save Y to the stack
- ldaa -1,x ; Read operator from X and save to A
- jsr ReadDecimal ; Read First number
- cmpa #'+' ; Compare A to '+'
- beq sAdd ; Jump to sAdd to add the numbers
- cmpa #'-' ; Compare A to '-'
- beq sSub ; Jump to sSub to add the numbers
- cmpa #'*' ; Compare A to '*'
- beq sMul ; Jump to sMul to add the numbers
- exg y,x ; Exchange X and Y
- puly ; Restore Y from the stack
- exg y,d ; Exchange Y and D
- idiv ; Divide D/X => X
- exg x,d ; Exchange X & D
- bra sDone ; Jump to sDone
-sAdd sty numBuf ; Save Y to numBuf
- puly ; Restore Y from the stack
- exg y,d ; Exchange Y and D
- addd numBuf ; Add D and numBuf
- bra sDone ; Jump to sDone
-sSub sty numBuf ; Save Y to numBuf
- puly ; Restore Y from the stack
- exg y,d ; Exchange Y and D
- subd numBuf ; Subtract D and numBuf
- bra sDone ; Jump to sDone
-sMul exg y,d ; Exchange Y and D
- puly ; Restore Y from the stack
- emul ; Multiply Y*D => Y:D
- cpy #0 ; Compare Y to 0
- bne sOverflow ; If Y != 0, Overflow
-sDone cpd #9999 ; Compare D to 9999 (Max output)
- bgt sOverflow ; Branch to sOverflow if D > 9999
- cpd #-9999 ; Compare D to -9999 (Min output)
- blt sOverflow ; Branch to sOverflow if D < -9999
- sei ; Disable Interrupts
- jsr PrintTime ; Print Time to serial
- psha ; Save A to the stack
- ldaa #' ' ; Load the space character into A
- jsr putchar ; Print the space character to the serial console
- jsr putchar ; Print the space character to the serial console
- jsr putchar ; Print the space character to the serial console
- jsr putchar ; Print the space character to the serial console
- pula ; Restore A from the stack
- pulx ; Restore X from the stack
- pshx ; Save X to the stack
- jsr WriteString ; Write original equation to serial console
- pulx ; Restore X from the stack
- ldy lenInput ; Load the length of the input buffer into Y
- jsr Zeros ; Clear input buffer
- psha ; Save A to the stack
- ldaa #'=' ; Load '=' into A
- jsr putchar ; Print '=' to serial console
- pula ; Restore A from the stack
- ldy #buffer ; Load address of buffer into Y
- jsr PrintDecimalWord; Print the answer to the Serial console
- clra ; Clear A
- staa operator ; Clear operator
- jsr PrintTime ; Print the time to the serial console
- ldx #spacer ; Load the address of spacer into X
- jsr WriteString ; Write the spacer string to the output
- jsr PrintPrompt ; Write CMD prompt to serial
- cli ; Enable Interrupts
- puld ; Restore D from the stack
- puly ; Restore Y from the stack
- rts ; Return to caller
-sOverflow ldaa #' ' ; Load a 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 ; Write original string to serial console
- ldaa #' ' ; Load a space character into A
- jsr putchar ; Jump to putchar to write space character
- ldx #overflow ; Load address of overflow string into X
- jsr WriteString ; Write overflow string to serial
- pulx ; Restore X from the stack
- puld ; Restore D from the stack
- puly ; Restore Y from the stack
- rts ; Return to caller
-
-;*************************************************************************
-; VerifyInput subroutine
-;
-; This subroutine will verify the user input is valid.
-;
-; Input: An address of a Null terminated string in register X.
-; Output: If valid Zero bit = 0 in CCR, if invalid, Zero bit = 1
-; and the string is outputed up to the error on the serial
-; console with an error message.
-; Registers in use: X for the address of the string, A for reading characters.
-; Y to count the number of digits in a number, & B to count the number of numbers
-; Memory locations in use: Memory Address for serial line, address of the string, 1 byte for operator
-;
-; Comments: This subroutine will modify the user string if invalid.
-;
-
-VerifyInput
- pshy ; Save Y to the stack
- pshd ; Save D to the stack
- pshx ; Save X to the stack
- clrb ; Set B to Zero
- stab operator ; Clear operator
- ldy #0 ; Load Zero into Y
-vNumLoop ldaa 1,x+ ; Load character from X into A
- cmpa #'9' ; Compare A to '9'
- bhi vInvalid ; If A > '9', not valid string
- cmpa #'0' ; Compare A to '0'
- blt vIsOp ; If A < '0', check if operator
- iny ; Increment Y by 1 to count numbers
- cpy #4 ; Compare Y to 4
- bhi vInvalid ; If greater than 4, invalid
- bra vNumLoop ; Loop back to check for more digits
-vIsOp cmpa #'+' ; Compare A to '+'
- beq vOp ; This is an operator
- cmpa #'-' ; Compare A to '-'
- beq vOp ; This is an operator
- cmpa #'*' ; Compare A to '*'
- beq vOp ; This is an operator
- cmpa #'/' ; Compare A to '/'
- beq vOp ; This is an operator
- cmpa #NULL ; Compare A to NULL character
- beq vEndOfLine ; Check if end of line
-vInvalid clra ; Set A to zero
- staa 0,X ; Write Null terminator to X
- ldaa #4 ; Load 4 into A to set zero bit
- tap ; Transfer A to CCR
- pulx ; Restore X from the stack
- puld ; Restore D from the stack
- puly ; Restore Y from the stack
- rts ; Return to caller
-vOp staa operator ; Store operator in operator buffer
- ldaa -2,x ; Load previous character into A
- cmpa #'0' ; Compare A to '0'
- blt vInvalid ; Invalid string since previous is not number
- cmpa #'9' ; Compare A to '9'
- bhi vInvalid ; Invalid string since previous is not number
- addb #1 ; Increment B by 1
- cmpb #1 ; Compare B to 1
- bhi vInvalid ; Invalid string since B > 1 and we have another operator
- ldy #0 ; Set Y to 0
- bra vNumLoop ; Check for next number
-vEndOfLine ldaa -2,x ; Load previous character into A
- cmpa #'0' ; Compare A to '0'
- blt vInvalid ; Invalid string since previous is not number
- cmpa #'9' ; Compare A to '9'
- bhi vInvalid ; Invalid string since previous is not number
- ldaa operator ; Load operator character from buffer
- beq vInvalid ; If operator buffer is zero, invalid
- clra ; Set A to zero
- tap ; Transfer A to CCR
- pulx ; Restore X from the stack
- puld ; Restore D from the stack
- puly ; Restore Y from the stack
- rts ; Return to caller
-
-;*************************************************************************
; ReadDecimal subroutine
;
; This subroutine will read an ASCII string of a number in decimal and convert it to
@@ -1031,7 +898,11 @@ 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 pulx ; Restore X from the stack
+doneRead ldaa #CR ; Load CR into A
+ jsr putchar ; Print to serial
+ ldaa #LF ; Load LF into A
+ jsr putchar ; Print to serial
+ pulx ; Restore X from the stack
pulY ; Restore Y from the stack
pula ; restore A from the stack
rts ; return to caller
@@ -1073,25 +944,28 @@ getchar7 clra ; Set A to 0
* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory
*
-clock dc.b 'Tcalc> ',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',NULL ; Invalid Input Prompt
-
-overflow dc.b 'Overflow Error',NULL ; Overflow error message
+badInput dc.b 'Invalid Input',CR,LF,NULL ; Invalid Input Prompt
; twMsg: welcome message for typewrite
twMsg dc.b CR,LF,'Clock stopped and Typewrite program started.',CR,LF
dc.b 'You may type below.',CR,LF,NULL
-; spacer: the white space between time and cmd prompt
-spacer dc.b ' ',NULL
+; Messages for different waveforms
+swMsg dc.b 'sawtooth wave generation...',CR,LF,NULL
+sw2Msg dc.b 'sawtooth wave 125Hz generation...',CR,LF,NULL
+tMsg dc.b 'triangle wave generation...',CR,LF,NULL
+sqMsg dc.b 'square wave generation...',CR,LF,NULL
+sq2Msg dc.b 'square wave 125Hz generation...',CR,LF,NULL
+
+doneWave dc.b 'Done generating wave.',CR,LF,NULL
; msg: this is the main option menu string
msg dc.b 'Commands:',CR,LF
+ dc.b 'gw: generate sawtooth wave, printing 0 through 255, repeated for total 2048 points',CR,LF
+ dc.b 'gw2: generate sawtooth wave of 125Hz, wave repeated for total 2048 points',CR,LF
+ dc.b 'gt: generate triangle wave, printing 0 through 255, then 255 down to 0, repeated for total 2048 points',CR,LF
+ dc.b 'gq: generate square wave, printing 0 for 255 times, then print 255 for 255 times, then repeated for total 2048 points',CR,LF
+ dc.b 'gq2: generate square wave of 125Hz, wave repeated for total 2048 points',CR,LF
dc.b 't: Set the time in format HH:MM:SS',CR,LF
dc.b 'h: Display the hours on the 7 segment displays',CR,LF
dc.b 'm: Display the minutes on the 7 segment displays',CR,LF
diff --git a/cmpen472hw10_McDonnell/bin/Project.abs b/cmpen472hw10_McDonnell/bin/Project.abs
index 6b1437f..d36595c 100644
--- a/cmpen472hw10_McDonnell/bin/Project.abs
+++ b/cmpen472hw10_McDonnell/bin/Project.abs
Binary files differ
diff --git a/cmpen472hw10_McDonnell/bin/Project.abs.phy b/cmpen472hw10_McDonnell/bin/Project.abs.phy
index e44254d..484ecc3 100644
--- a/cmpen472hw10_McDonnell/bin/Project.abs.phy
+++ b/cmpen472hw10_McDonnell/bin/Project.abs.phy
@@ -1,4 +1,4 @@
S0590000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E343732687731305F4D63446F6E6E656C6C5C62696E5C50726F6A6563742E6162731E
-S2060FFFE431BC1A
-S2060FFFF0316B5F
+S2060FFFE431B224
+S2060FFFF0316169
S9030000FC
diff --git a/cmpen472hw10_McDonnell/bin/Project.abs.s19 b/cmpen472hw10_McDonnell/bin/Project.abs.s19
index b79eb51..8647ad8 100644
--- a/cmpen472hw10_McDonnell/bin/Project.abs.s19
+++ b/cmpen472hw10_McDonnell/bin/Project.abs.s19
@@ -1,61 +1,76 @@
S0590000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E343732687731305F4D63446F6E6E656C6C5C62696E5C50726F6A6563742E6162731E
S123300000000000000000000000000000000000000010000000000000000000000000009C
S123302000000000001000000000000000000000000000000000000000000000000000007C
-S1103040000010730000000BB808000071C0
-S1233100CF310086F15A03860C5ACBCC00015CC8CE36CB1636054C3B194C38804C378086E2
-S1233120FF5A0310EFCE3030FD3041163611CC00007C30457A30441632C4B6304B27FB87A6
-S12331407A304B1631DDFC3045BC304925EC1632E320D214104D3880CE366E163605163646
-S1233160329727FA5A0116362B20F34C378010EFFE302C087E302C8E00C8263FCE00007E37
-S1233180302CFE302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C26189B
-S12331A0CE00007E3028FE3026087E30268E00182606CE00007E30261632E90BFC3047D341
-S12331C05A5C5A4C4E2086017A304BFC3045C300017C3045BC304925031632E30B3B35B6C6
-S12331E0304C81541827008A8174182700AC81511827002B81711827005087F63044CD3026
-S12332000016358736860D16362B860A16362B32C300018C0100182600A4C71820009F8707
-S1233220C6FFCD300016358736860D16362B860A16362B3287F63044C300018C01001826FD
-S1233240007CC786717A304C207487C7CD300016358736860D16362B860A16362B3287F693
-S12332603044C300018C01002654C786517A304C204C87F63044CD300016358736860D166C
-S1233280362B860A16362B32C300018C0100262E86747A304C830001202487F63044CD3045
-S12332A00016358736860D16362B860A16362B328300018CFFFF260686547A304CC77B3043
-S12332C044313A3D3B86205A405A4C86805A4686005A4DCC0BB8D3445C5A4C4E2086205AF4
-S12332E04C3A3D36875A4C323D3BB6304381682605FC3026200C816D2605FC30282003FCB3
-S1233300302A1633163A3D34CE3643163605CE3030163605303D3B34CE000A181037B7D490
-S1233320CE000A58585858EAB05B01303A3D3B35A630182700E08174266DA620812027FA3F
-S12333401410FC30263B163534B7E48C0018182400A28C0000182D009B7C3026A61F813A5E
-S123336018260090FC30283B163534B7E48C003C247E8C00002D797C3028A61F813A26704C
-S1233380FC302A3B163534B7E48C003C245E8C00002D597C302AA61F81002650877A302C33
-S12333A010EF3A3A3A206F8168260BE630C10026497A30432060816D260BE630C100263AAA
-S12333C07A304320518173260BE630C100262B7A3043204281712609E630C100261C06317E
-S12333E053091634CB2713163419202A3A7C302A3A7C30283A7C302610EF34862016362BF7
-S123340016362B16362B16362BCE3649163605CE365116360530313A3D353B3416353435CF
-S1233420A61F163534812B2713812D271A812A2721B7E531B7E41810B7D4201F7D302E3116
-S1233440B7E4F3302E20147D302E31B7E4B3302E2009B7E431138D0000264D8C270F2E4850
-S12334608CD8F12D4314101632E936862016362B16362B16362B16362B323034163605305F
-S1233480FD30411635F636863D16362B32CD3000163587877A302F1632E9CE36B41636056E
-S12334A016330710EF3A313D862016362B16362B16362B16362BCE364916360586201636FF
-S12334C02BCE365F163605303A313D353B34C77B302FCD0000A6308139222081302D080265
-S12334E08D0004221620EE812B271B812D2717812A2713812F270F81002723876A00860406
-S1233500B702303A313D7A302FA61E81302DEC813922E8CB01C10122E2CD000020B7A61EF1
-S123352081302DD7813922D3B6302F27CE87B702303A313D3BCD0000E630272EC12B272A51
-S1233540C12D2726C12A2722C12F271EC13A271AC1202716C1302D17C1392213C03037CC12
-S1233560000A13B7C63319ED20CE87B7023A3D8604B7023A3D343536A67F27056A3020F873
-S1233580876A303231303D34353B8C0000274C2D533635348630CE3013CD00051635FF3061
-S12335A031876A4032CE000A18108E00002708CB306B60B7D420EE8C000026F3B6302F811C
-S12335C02D26026A60CE3013163575163605FD3024CE30131635F63A31303D863016362BFE
-S12335E03A31303D36862D7A302F3240800150C001C30001209B36876A300436FB323D6A45
-S1233600300436FB3D36A630270516362B20F7323D36353416363227FB810D270A6A301621
-S1233620362B03270220ED3031323D4FCC80FC5ACF3D4FCC200396CF3D873D5463616C6394
-S12336403E2000434D443E20004572726F723E2000496E76616C696420496E707574004F28
-S1233660766572666C6F77204572726F72000D0A436C6F636B2073746F7070656420616E06
-S123368064205479706577726974652070726F6772616D20737461727465642E0D0A596F99
-S12336A075206D617920747970652062656C6F772E0D0A002020202020202020202020204A
-S12336C02020202020202020202000436F6D6D616E64733A0D0A743A2053657420746865C8
-S12336E02074696D6520696E20666F726D61742048483A4D4D3A53530D0A683A20446973FA
-S1233700706C61792074686520686F757273206F6E207468652037207365676D656E742055
-S1233720646973706C6179730D0A6D3A20446973706C617920746865206D696E75746573E2
-S1233740206F6E207468652037207365676D656E7420646973706C6179730D0A733A2044EC
-S12337606973706C617920746865207365636F6E6473206F6E207468652037207365676DC2
-S1233780656E7420646973706C6179730D0A713A2053746F702074686520636C6F636B2020
-S11A37A0616E6420656E74657220747970657772697465720D0A0007
-S105FFE431BC2A
-S105FFF0316B6F
+S1103040000010730000000BB808000053DE
+S1233100CF310086F15A03860C5ACBCC00015CC8CE36EC1635A04C3B194C38804C37808627
+S1233120FF5A0310EF863E1635D086201635D0CE3030FD30411635ACCE303016333BCE304D
+S123314030FD304116359120DC14104D3880CE35F01635A01635D79727FA5A011635D0207E
+S1233160F34C378010EFFE302C087E302C8E00C8263FCE00007E302CFE302A087E302A8EF1
+S1233180003C262ACE00007E302AFE3028087E30288E003C2618CE00007E3028FE302608BD
+S12331A07E30268E00182606CE00007E30261633050BFC3047D35A5C5A4C4E2086017A3029
+S12331C04BFC3045C300017C3045BC304925031632D90B3B35B6304C81541827008A8174BC
+S12331E0182700AC81511827002B81711827005087F63044CD300016352236860D1635D0E4
+S1233200860A1635D032C300018C0100182600A4C71820009F87C6FFCD300016352236868A
+S12332200D1635D0860A1635D03287F63044C300018C01001826007CC786717A304C207441
+S123324087C7CD300016352236860D1635D0860A1635D03287F63044C300018C0100265435
+S1233260C786517A304C204C87F63044CD300016352236860D1635D0860A1635D032C3006B
+S1233280018C0100262E86747A304C830001202487F63044CD300016352236860D1635D051
+S12332A0860A1635D0328300018CFFFF260686547A304CC77B3044313A3D3B86205A405AF0
+S12332C04C86805A4686005A4DCC0BB8D3445C5A4C4E2086205A4C3A3D36875A4C323D3BE5
+S12332E0CC00007C30457A30441632BAB6304B27FB877A304B1631D3FC3045BC304925EC7D
+S12333001632D93A3D3BB6304381682605FC3026200C816D2605FC30282003FC302A1633EC
+S1233320233A3D3B34CE000A181037B7D4CE000A58585858EAB05B01303A3D3B35A630188B
+S12333402701898174267BA620812027FA1410FC30263B1634CFB7E48C00181824015F8C69
+S12333600000182D01587C3026A61F813A1826014DFC30283B1634CFB7E48C003C18240185
+S1233380398C0000182D01327C3028A61F813A18260127FC302A3B1634CFB7E48C003C180D
+S12333A02401138C0000182D010C7C302AA61F810018260101877A302C10EF3A3A3A182055
+S12333C0010A8168260FE630C100182600F67A3043182000F7816D260FE630C10018260061
+S12333E0E37A3043182000E48173260FE630C100182600D07A3043182000D18171260BE6D0
+S123340030C100182600BD0631498167182600B4A6308177263CE630C1002618CE363616CD
+S123342035A086537A304C1632DFCE36D41635A018200098C1321826008AE630C10018265A
+S12334400082CE36541635A0CE36D41635A01820007A81742620E630C10018260066CE3674
+S1233460781635A086547A304C1632DFCE36D41635A018200056817118260048E630C1004E
+S12334802618CE36961635A086717A304C1632DFCE36D41635A018200032C13218260024CF
+S12334A0E630C100261ECE36B21635A0CE36D41635A0182000163A7C302A3A7C30283A7C67
+S12334C0302610EF34CE35E01635A030313A3D3BCD0000E630272EC12B272AC12D2726C10D
+S12334E02A2722C12F271EC13A271AC1202716C1302D17C1392213C03037CC000A13B7C6D5
+S12335003319ED20CE87B7023A3D8604B7023A3D343536A67F27056A3020F8876A303231E9
+S1233520303D34353B8C0000274C2D533635348630CE3013CD000516359A3031876A403216
+S1233540CE000A18108E00002708CB306B60B7D420EE8C000026F3B6302F812D26026A60F1
+S1233560CE30131635101635A0FD3024CE30131635913A31303D86301635D03A31303D36FB
+S1233580862D7A302F3240800150C001C30001209B36876A300436FB323D6A300436FB3D11
+S12335A036A63027051635D020F7323D3635341635D727FB810D270A6A301635D0032702AB
+S12335C020ED860D1635D0860A1635D03031323D4FCC80FC5ACF3D4FCC200396CF3D873D10
+S12335E0496E76616C696420496E7075740D0A000D0A436C6F636B2073746F707065642077
+S1233600616E64205479706577726974652070726F6772616D20737461727465642E0D0A12
+S1233620596F75206D617920747970652062656C6F772E0D0A00736177746F6F7468207772
+S12336406176652067656E65726174696F6E2E2E2E0D0A00736177746F6F74682077617656
+S12336606520313235487A2067656E65726174696F6E2E2E2E0D0A00747269616E676C6524
+S123368020776176652067656E65726174696F6E2E2E2E0D0A007371756172652077617667
+S12336A0652067656E65726174696F6E2E2E2E0D0A007371756172652077617665203132CD
+S12336C035487A2067656E65726174696F6E2E2E2E0D0A00446F6E652067656E6572617476
+S12336E0696E6720776176652E0D0A00436F6D6D616E64733A0D0A67773A2067656E6572A4
+S123370061746520736177746F6F746820776176652C207072696E74696E672030207468FC
+S1233720726F756768203235352C20726570656174656420666F7220746F74616C203230E1
+S1233740343820706F696E74730D0A6777323A2067656E657261746520736177746F6F743F
+S1233760682077617665206F6620313235487A2C20776176652072657065617465642066AC
+S12337806F7220746F74616C203230343820706F696E74730D0A67743A2067656E65726197
+S12337A0746520747269616E676C6520776176652C207072696E74696E672030207468726E
+S12337C06F756768203235352C207468656E2032353520646F776E20746F20302C20726571
+S12337E070656174656420666F7220746F74616C203230343820706F696E74730D0A67710D
+S12338003A2067656E65726174652073717561726520776176652C207072696E74696E67C4
+S1233820203020666F72203235352074696D65732C207468656E207072696E7420323535CB
+S123384020666F72203235352074696D65732C207468656E20726570656174656420666FA5
+S12338607220746F74616C203230343820706F696E74730D0A6771323A2067656E657261F6
+S12338807465207371756172652077617665206F6620313235487A2C207761766520726562
+S12338A070656174656420666F7220746F74616C203230343820706F696E74730D0A743A76
+S12338C020536574207468652074696D6520696E20666F726D61742048483A4D4D3A535364
+S12338E00D0A683A20446973706C61792074686520686F757273206F6E207468652037208E
+S12339007365676D656E7420646973706C6179730D0A6D3A20446973706C61792074686512
+S1233920206D696E75746573206F6E207468652037207365676D656E7420646973706C61F9
+S123394079730D0A733A20446973706C617920746865207365636F6E6473206F6E20746854
+S1233960652037207365676D656E7420646973706C6179730D0A713A2053746F7020746867
+S12239806520636C6F636B20616E6420656E74657220747970657772697465720D0A006C
+S105FFE431B234
+S105FFF0316179
S9030000FC
diff --git a/cmpen472hw10_McDonnell/bin/main.dbg b/cmpen472hw10_McDonnell/bin/main.dbg
index 58564c7..3934132 100644
--- a/cmpen472hw10_McDonnell/bin/main.dbg
+++ b/cmpen472hw10_McDonnell/bin/main.dbg
@@ -113,7 +113,7 @@ numPoints dc.w 2048 ; Max Number of points for waves
timeTrigger dc.b $00 ; Tracks when timer is triggered
-waveType dc.b 'q' ; Used to track wave type 'T' for increasing triangle,
+waveType dc.b 'S' ; Used to track wave type 'T' for increasing triangle,
; 't' for decreasing triangle,
; 'Q' for square high
; 'q' for square low
@@ -161,26 +161,20 @@ pgstart lds #$3100 ; initialize the stack pointer
cli ; Enable interrupts
mainLoop
+ ldaa #'>' ; Load '>' character
+ jsr putchar ; Print to serial console
+ ldaa #' ' ; Load ' ' character
+ jsr putchar ; Print to serial console
ldx #inputBuffer ; Load the address of inputBuffer into X
ldy lenInput ; Load the length of inputBuffer into Y
jsr ReadString ; Jump to ReadString to read input
- ldd #0 ; Clear D
- std outputCnt ; Clear outputCnt
- staa outputVal ; Clear outputVal
-
- jsr StartTimer5oc ; Start Timer on CH5
-
-looooop ldaa timeTrigger
- beq looooop
- clra
- staa timeTrigger
- jsr PrintWave ; Jump to PrintWave
- ldd outputCnt
- cpd numPoints
- blo looooop
+ ldx #inputBuffer ; Load the address of inputBuffer into X
+ jsr ExecuteCommand ; Jump to ExecuteCommand
- jsr StopTimerCH5
+ ldx #inputBuffer ; Load the address of inputBuffer into X
+ ldy lenInput ; Load the length of inputBuffer into Y
+ jsr Zeros ; Zero out input buffer
bra mainLoop ; Loop back to mainLoop always
@@ -395,6 +389,27 @@ StopTimerCH5
pula ; Restore A from the stack
rts ; Return
+GenWave
+ pshd ; Save D to the stack
+ ldd #0 ; Clear D
+ std outputCnt ; Clear outputCnt
+ staa outputVal ; Clear outputVal
+
+ jsr StartTimer5oc ; Start Timer on CH5
+
+
+genLoop ldaa timeTrigger ; Load timeTrigger into A
+ beq genLoop ; If A == 0, loop
+ clra ; Clear A
+ staa timeTrigger ; Clear timeTrigger
+ jsr PrintWave ; Jump to PrintWave
+ ldd outputCnt ; Load outputCnt into D
+ cpd numPoints ; Compare D to numPoints
+ blo genLoop ; If D < numPoints, Loop
+
+ jsr StopTimerCH5 ; Turn off timer
+ puld ; Restore D from the stack
+ rts ; Return
;*************************************************************************
; PrintTime subroutine
@@ -431,28 +446,6 @@ skipRest jsr TimeOnPortB ; Call TimeOnPortB to output time
rts ; Return to caller
;*************************************************************************
-; PrintPrompt subroutine
-;
-; This subroutine will output the CMD prompt and any current input to the serial console
-;
-; Input: No Input
-; Output: The CMD prompt and any input onto the serial console
-; Registers in use: X for addresses of strings
-; Memory locations in use: PORTB memory location, CMD prompt memory locaiton, inputBuffer location
-;
-; Comments: This subroutine requires WriteString subroutine.
-;
-
-PrintPrompt
- pshx ; Save X to the stack
- ldx #CMD ; Load the address of CMD into X
- 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
- pulx ; Restore X from the stack
- rts ; Return
-
-;*************************************************************************
; TimeOnPortB subroutine
;
; This subroutine will output the time given on on PORTB for two seven segment displays.
@@ -527,64 +520,121 @@ skipSpaces ldaa 1,+x ; Load the next character into X
jsr ReadDecimal ; Read minute number
exg y,d ; Exchange Y and D
cpd #60 ; Compare D to 60
- bhs badMinutes ; If D >= 60, badMinutes
+ lbhs badMinutes ; If D >= 60, badMinutes
cpd #0 ; Compare D to 0
- blt badMinutes ; If D < 0, badMinutes
+ lblt badMinutes ; If D < 0, badMinutes
std minutes ; Save D to minutes
ldaa -1,x ; Load the next character into A
cmpa #':' ; Compare A to ':'
- bne badMinutes ; If A != ':', badMinutes
+ lbne badMinutes ; If A != ':', badMinutes
ldd seconds ; Load seconds into D
pshd ; Save seconds to the stack
jsr ReadDecimal ; Read second number
exg y,d ; Exchange Y and D
cpd #60 ; Compare D to 60
- bhs badSeconds ; If D >= 60, badSeconds
+ lbhs badSeconds ; If D >= 60, badSeconds
cpd #0 ; Compare D to 0
- blt badSeconds ; If D < 0, badSeconds
+ lblt badSeconds ; If D < 0, badSeconds
std seconds ; Save D to seconds
ldaa -1,x ; Load the next character into A
cmpa #NULL ; Compare A to NULL
- bne badSeconds ; If A != ':', badSeconds
+ lbne badSeconds ; If A != ':', badSeconds
clra ; Set A to 0
staa counter ; Clear Counter
cli ; Enable interrupts
puld ; Restore D from the stack
puld ; Restore D from the stack
puld ; Restore D from the stack
- bra ecDone ; Branch to ecDone
+ lbra ecDone ; Branch to ecDone
isH cmpa #'h' ; Compare A to 'h'
bne isM ; If A != 'h', branch to isM
ldab 1,x+ ; Load next character into B
cmpb #NULL ; Compare B to NULL
- bne badCommand ; If B != CR, bad command
+ lbne badCommand ; If B != CR, bad command
staa outputBuf ; Store A into outputBuf
- bra ecDone ; Branch to ecDone
+ lbra ecDone ; Branch to ecDone
isM cmpa #'m' ; Compare A to 'm'
bne isS ; If A != 'm', branch to isS
ldab 1,x+ ; Load next character into B
cmpb #NULL ; Compare B to NULL
- bne badCommand ; If B != CR, bad command
+ lbne badCommand ; If B != CR, bad command
staa outputBuf ; Store A into outputBuf
- bra ecDone ; Branch to ecDone
+ lbra ecDone ; Branch to ecDone
isS cmpa #'s' ; Compare A to 's'
bne isQ ; If A != 's', branch to isQ
ldab 1,x+ ; Load next character into B
cmpb #NULL ; Compare B to NULL
- bne badCommand ; If B != CR, bad command
+ lbne badCommand ; If B != CR, bad command
staa outputBuf ; Store A into outputBuf
- bra ecDone ; Branch to ecDone
+ lbra ecDone ; Branch to ecDone
isQ cmpa #'q' ; Compare A to 'q'
- bne isEquation ; If A != 'q', branch to isEquation
+ bne isGw ; If A != 'q', branch to isGw
ldab 1,x+ ; Load next character into B
cmpb #NULL ; Compare B to NULL
- bne badCommand ; If B != NULL, branch to ecDone
+ lbne badCommand ; If B != NULL, branch to ecDone
jmp TypeWrite ; Jump to TypeWrite
-isEquation dex ; Decrement X by 1
- jsr VerifyInput ; Verify input is valid equation
- beq badCommand ; If Z == 1, badCommand
- jsr Solve ; Jump to Solve to solve equation
- bra ecDone ; Branch always to ecDone
+isGw cmpa #'g' ; Compare A to 'g'
+ lbne badCommand ; If A != 'g', branch to badCommand
+ ldaa 1,x+ ; Load next character into B
+ cmpa #'w' ; Compare A to 'w'
+ bne isGt ; If A != 'w', branch to isGt
+ ldab 1,x+ ; Load next charater into B
+ cmpb #NULL ; Compare B to NULL
+ bne isGw2 ; If B != NULL, branch to isGw2
+ ldx #swMsg ; Load address of sawtooth message
+ jsr WriteString ; Write string
+ ldaa #'S' ; Load 'S' for sawtooth
+ staa waveType ; Save A to waveType
+ jsr GenWave ; Jump to GenWave
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
+isGw2 cmpb #'2' ; Compare B to '2'
+ lbne badCommand ; If B != '2', bad
+ ldab 1,x+ ; Load next character into B
+ cmpb #NULL ; Compare to NULL
+ lbne badCommand ; Not NULL? bad
+ ldx #sw2Msg ; Load address of sawtooth 125Hz message
+ jsr WriteString ; Write string
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
+isGt cmpa #'t' ; Compare A to 't'
+ bne isGq ; If A != 't', branch to isGq
+ ldab 1,x+ ; Load next character into B
+ cmpb #NULL ; Compare to NULL
+ lbne badCommand ; A != NULL? bad
+ ldx #tMsg ; Load address of triangle message
+ jsr WriteString ; Write string
+ ldaa #'T' ; Load 'T' for triangle
+ staa waveType ; Save A to waveType
+ jsr GenWave ; Jump to GenWave
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
+isGq cmpa #'q' ; Compare A to 'q'
+ lbne badCommand ; A != 'q'? bad
+ ldab 1,x+ ; Load next character into B
+ cmpb #NULL ; Compare B to NULL
+ bne isGq2 ; B != NULL? isGq2
+ ldx #sqMsg ; Load address of square message
+ jsr WriteString ; Write string
+ ldaa #'q' ; Load 'q' for square
+ staa waveType ; Save A to waveType
+ jsr GenWave ; Jump to GenWave
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
+isGq2 cmpb #'2' ; Compare B to '2'
+ lbne badCommand ; B != '2'? bad
+ ldab 1,x+ ; Load next character into B
+ cmpb #NULL ; Compare B to NULL
+ bne badCommand ; B != NULL? bad
+ ldx #sq2Msg ; Load address of square 125Hz message
+ jsr WriteString ; Write string
+ ldx #doneWave ; Load the address of doneWave
+ jsr WriteString ; Write string
+ lbra ecDone ; Branch always to ecDone
badSeconds puld ; Restore Seconds from the stack
std seconds ; Restore seconds before change
badMinutes puld ; Restore minutes from the stack
@@ -593,13 +643,6 @@ badHours puld ; Restore hours from the stack
std hours ; Restore hours before change
cli ; Reenable interrupts
badCommand 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
jsr WriteString ; Jump to WriteString
pulx ; Restore X from the stack
@@ -608,182 +651,6 @@ ecDone puly ; Restore Y from the stack
rts ; Return to caller
;*************************************************************************
-; Solve subroutine
-;
-; This subroutine will solve the math equation in the given string.
-;
-; Input: Address of null terminated string in X.
-; Output: No Output, Control flow changed to proper subroutine.
-; Registers in use: X for the address of the string, A & B to read characters from
-; from the string.
-; Memory locations in use: Memory Address for serial line, address of the string, numBuf word
-;
-; Comments: This subroutine EXPECTS the input to be valid. RUN VerifyInput BEFORE
-; TO MAKE SURE THE STRING IS VALID, OTHERWISE THERE WILL BE ERRORS.
-;
-
-Solve
- pshy ; Save Y to the stack
- pshd ; Save D to the stack
- pshx ; Save X to the stack
- jsr ReadDecimal ; Read First number
- pshy ; Save Y to the stack
- ldaa -1,x ; Read operator from X and save to A
- jsr ReadDecimal ; Read First number
- cmpa #'+' ; Compare A to '+'
- beq sAdd ; Jump to sAdd to add the numbers
- cmpa #'-' ; Compare A to '-'
- beq sSub ; Jump to sSub to add the numbers
- cmpa #'*' ; Compare A to '*'
- beq sMul ; Jump to sMul to add the numbers
- exg y,x ; Exchange X and Y
- puly ; Restore Y from the stack
- exg y,d ; Exchange Y and D
- idiv ; Divide D/X => X
- exg x,d ; Exchange X & D
- bra sDone ; Jump to sDone
-sAdd sty numBuf ; Save Y to numBuf
- puly ; Restore Y from the stack
- exg y,d ; Exchange Y and D
- addd numBuf ; Add D and numBuf
- bra sDone ; Jump to sDone
-sSub sty numBuf ; Save Y to numBuf
- puly ; Restore Y from the stack
- exg y,d ; Exchange Y and D
- subd numBuf ; Subtract D and numBuf
- bra sDone ; Jump to sDone
-sMul exg y,d ; Exchange Y and D
- puly ; Restore Y from the stack
- emul ; Multiply Y*D => Y:D
- cpy #0 ; Compare Y to 0
- bne sOverflow ; If Y != 0, Overflow
-sDone cpd #9999 ; Compare D to 9999 (Max output)
- bgt sOverflow ; Branch to sOverflow if D > 9999
- cpd #-9999 ; Compare D to -9999 (Min output)
- blt sOverflow ; Branch to sOverflow if D < -9999
- sei ; Disable Interrupts
- jsr PrintTime ; Print Time to serial
- psha ; Save A to the stack
- ldaa #' ' ; Load the space character into A
- jsr putchar ; Print the space character to the serial console
- jsr putchar ; Print the space character to the serial console
- jsr putchar ; Print the space character to the serial console
- jsr putchar ; Print the space character to the serial console
- pula ; Restore A from the stack
- pulx ; Restore X from the stack
- pshx ; Save X to the stack
- jsr WriteString ; Write original equation to serial console
- pulx ; Restore X from the stack
- ldy lenInput ; Load the length of the input buffer into Y
- jsr Zeros ; Clear input buffer
- psha ; Save A to the stack
- ldaa #'=' ; Load '=' into A
- jsr putchar ; Print '=' to serial console
- pula ; Restore A from the stack
- ldy #buffer ; Load address of buffer into Y
- jsr PrintDecimalWord; Print the answer to the Serial console
- clra ; Clear A
- staa operator ; Clear operator
- jsr PrintTime ; Print the time to the serial console
- ldx #spacer ; Load the address of spacer into X
- jsr WriteString ; Write the spacer string to the output
- jsr PrintPrompt ; Write CMD prompt to serial
- cli ; Enable Interrupts
- puld ; Restore D from the stack
- puly ; Restore Y from the stack
- rts ; Return to caller
-sOverflow ldaa #' ' ; Load a 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 ; Write original string to serial console
- ldaa #' ' ; Load a space character into A
- jsr putchar ; Jump to putchar to write space character
- ldx #overflow ; Load address of overflow string into X
- jsr WriteString ; Write overflow string to serial
- pulx ; Restore X from the stack
- puld ; Restore D from the stack
- puly ; Restore Y from the stack
- rts ; Return to caller
-
-;*************************************************************************
-; VerifyInput subroutine
-;
-; This subroutine will verify the user input is valid.
-;
-; Input: An address of a Null terminated string in register X.
-; Output: If valid Zero bit = 0 in CCR, if invalid, Zero bit = 1
-; and the string is outputed up to the error on the serial
-; console with an error message.
-; Registers in use: X for the address of the string, A for reading characters.
-; Y to count the number of digits in a number, & B to count the number of numbers
-; Memory locations in use: Memory Address for serial line, address of the string, 1 byte for operator
-;
-; Comments: This subroutine will modify the user string if invalid.
-;
-
-VerifyInput
- pshy ; Save Y to the stack
- pshd ; Save D to the stack
- pshx ; Save X to the stack
- clrb ; Set B to Zero
- stab operator ; Clear operator
- ldy #0 ; Load Zero into Y
-vNumLoop ldaa 1,x+ ; Load character from X into A
- cmpa #'9' ; Compare A to '9'
- bhi vInvalid ; If A > '9', not valid string
- cmpa #'0' ; Compare A to '0'
- blt vIsOp ; If A < '0', check if operator
- iny ; Increment Y by 1 to count numbers
- cpy #4 ; Compare Y to 4
- bhi vInvalid ; If greater than 4, invalid
- bra vNumLoop ; Loop back to check for more digits
-vIsOp cmpa #'+' ; Compare A to '+'
- beq vOp ; This is an operator
- cmpa #'-' ; Compare A to '-'
- beq vOp ; This is an operator
- cmpa #'*' ; Compare A to '*'
- beq vOp ; This is an operator
- cmpa #'/' ; Compare A to '/'
- beq vOp ; This is an operator
- cmpa #NULL ; Compare A to NULL character
- beq vEndOfLine ; Check if end of line
-vInvalid clra ; Set A to zero
- staa 0,X ; Write Null terminator to X
- ldaa #4 ; Load 4 into A to set zero bit
- tap ; Transfer A to CCR
- pulx ; Restore X from the stack
- puld ; Restore D from the stack
- puly ; Restore Y from the stack
- rts ; Return to caller
-vOp staa operator ; Store operator in operator buffer
- ldaa -2,x ; Load previous character into A
- cmpa #'0' ; Compare A to '0'
- blt vInvalid ; Invalid string since previous is not number
- cmpa #'9' ; Compare A to '9'
- bhi vInvalid ; Invalid string since previous is not number
- addb #1 ; Increment B by 1
- cmpb #1 ; Compare B to 1
- bhi vInvalid ; Invalid string since B > 1 and we have another operator
- ldy #0 ; Set Y to 0
- bra vNumLoop ; Check for next number
-vEndOfLine ldaa -2,x ; Load previous character into A
- cmpa #'0' ; Compare A to '0'
- blt vInvalid ; Invalid string since previous is not number
- cmpa #'9' ; Compare A to '9'
- bhi vInvalid ; Invalid string since previous is not number
- ldaa operator ; Load operator character from buffer
- beq vInvalid ; If operator buffer is zero, invalid
- clra ; Set A to zero
- tap ; Transfer A to CCR
- pulx ; Restore X from the stack
- puld ; Restore D from the stack
- puly ; Restore Y from the stack
- rts ; Return to caller
-
-;*************************************************************************
; ReadDecimal subroutine
;
; This subroutine will read an ASCII string of a number in decimal and convert it to
@@ -1031,7 +898,11 @@ 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 pulx ; Restore X from the stack
+doneRead ldaa #CR ; Load CR into A
+ jsr putchar ; Print to serial
+ ldaa #LF ; Load LF into A
+ jsr putchar ; Print to serial
+ pulx ; Restore X from the stack
pulY ; Restore Y from the stack
pula ; restore A from the stack
rts ; return to caller
@@ -1073,25 +944,28 @@ getchar7 clra ; Set A to 0
* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory
*
-clock dc.b 'Tcalc> ',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',NULL ; Invalid Input Prompt
-
-overflow dc.b 'Overflow Error',NULL ; Overflow error message
+badInput dc.b 'Invalid Input',CR,LF,NULL ; Invalid Input Prompt
; twMsg: welcome message for typewrite
twMsg dc.b CR,LF,'Clock stopped and Typewrite program started.',CR,LF
dc.b 'You may type below.',CR,LF,NULL
-; spacer: the white space between time and cmd prompt
-spacer dc.b ' ',NULL
+; Messages for different waveforms
+swMsg dc.b 'sawtooth wave generation...',CR,LF,NULL
+sw2Msg dc.b 'sawtooth wave 125Hz generation...',CR,LF,NULL
+tMsg dc.b 'triangle wave generation...',CR,LF,NULL
+sqMsg dc.b 'square wave generation...',CR,LF,NULL
+sq2Msg dc.b 'square wave 125Hz generation...',CR,LF,NULL
+
+doneWave dc.b 'Done generating wave.',CR,LF,NULL
; msg: this is the main option menu string
msg dc.b 'Commands:',CR,LF
+ dc.b 'gw: generate sawtooth wave, printing 0 through 255, repeated for total 2048 points',CR,LF
+ dc.b 'gw2: generate sawtooth wave of 125Hz, wave repeated for total 2048 points',CR,LF
+ dc.b 'gt: generate triangle wave, printing 0 through 255, then 255 down to 0, repeated for total 2048 points',CR,LF
+ dc.b 'gq: generate square wave, printing 0 for 255 times, then print 255 for 255 times, then repeated for total 2048 points',CR,LF
+ dc.b 'gq2: generate square wave of 125Hz, wave repeated for total 2048 points',CR,LF
dc.b 't: Set the time in format HH:MM:SS',CR,LF
dc.b 'h: Display the hours on the 7 segment displays',CR,LF
dc.b 'm: Display the minutes on the 7 segment displays',CR,LF
diff --git a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.o
index 6b1437f..d36595c 100644
--- a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.o
+++ b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.o
Binary files differ
diff --git a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.sx
index 3a1ae49..6f57e4b 100644
--- a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.sx
+++ b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.sx
@@ -1,61 +1,76 @@
S0860000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E343732687731305F4D63446F6E6E656C6C5C636D70656E343732687731305F4D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726D75
S123300000000000000000000000000000000000000010000000000000000000000000009C
S123302000000000001000000000000000000000000000000000000000000000000000007C
-S1103040000010730000000BB808000071C0
-S105FFF0316B6F
-S105FFE431BC2A
-S1233100CF310086F15A03860C5ACBCC00015CC8CE36CB1636054C3B194C38804C378086E2
-S1233120FF5A0310EFCE3030FD3041163611CC00007C30457A30441632C4B6304B27FB87A6
-S12331407A304B1631DDFC3045BC304925EC1632E320D214104D3880CE366E163605163646
-S1233160329727FA5A0116362B20F34C378010EFFE302C087E302C8E00C8263FCE00007E37
-S1233180302CFE302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C26189B
-S12331A0CE00007E3028FE3026087E30268E00182606CE00007E30261632E90BFC3047D341
-S12331C05A5C5A4C4E2086017A304BFC3045C300017C3045BC304925031632E30B3B35B6C6
-S12331E0304C81541827008A8174182700AC81511827002B81711827005087F63044CD3026
-S12332000016358736860D16362B860A16362B32C300018C0100182600A4C71820009F8707
-S1233220C6FFCD300016358736860D16362B860A16362B3287F63044C300018C01001826FD
-S1233240007CC786717A304C207487C7CD300016358736860D16362B860A16362B3287F693
-S12332603044C300018C01002654C786517A304C204C87F63044CD300016358736860D166C
-S1233280362B860A16362B32C300018C0100262E86747A304C830001202487F63044CD3045
-S12332A00016358736860D16362B860A16362B328300018CFFFF260686547A304CC77B3043
-S12332C044313A3D3B86205A405A4C86805A4686005A4DCC0BB8D3445C5A4C4E2086205AF4
-S12332E04C3A3D36875A4C323D3BB6304381682605FC3026200C816D2605FC30282003FCB3
-S1233300302A1633163A3D34CE3643163605CE3030163605303D3B34CE000A181037B7D490
-S1233320CE000A58585858EAB05B01303A3D3B35A630182700E08174266DA620812027FA3F
-S12333401410FC30263B163534B7E48C0018182400A28C0000182D009B7C3026A61F813A5E
-S123336018260090FC30283B163534B7E48C003C247E8C00002D797C3028A61F813A26704C
-S1233380FC302A3B163534B7E48C003C245E8C00002D597C302AA61F81002650877A302C33
-S12333A010EF3A3A3A206F8168260BE630C10026497A30432060816D260BE630C100263AAA
-S12333C07A304320518173260BE630C100262B7A3043204281712609E630C100261C06317E
-S12333E053091634CB2713163419202A3A7C302A3A7C30283A7C302610EF34862016362BF7
-S123340016362B16362B16362BCE3649163605CE365116360530313A3D353B3416353435CF
-S1233420A61F163534812B2713812D271A812A2721B7E531B7E41810B7D4201F7D302E3116
-S1233440B7E4F3302E20147D302E31B7E4B3302E2009B7E431138D0000264D8C270F2E4850
-S12334608CD8F12D4314101632E936862016362B16362B16362B16362B323034163605305F
-S1233480FD30411635F636863D16362B32CD3000163587877A302F1632E9CE36B41636056E
-S12334A016330710EF3A313D862016362B16362B16362B16362BCE364916360586201636FF
-S12334C02BCE365F163605303A313D353B34C77B302FCD0000A6308139222081302D080265
-S12334E08D0004221620EE812B271B812D2717812A2713812F270F81002723876A00860406
-S1233500B702303A313D7A302FA61E81302DEC813922E8CB01C10122E2CD000020B7A61EF1
-S123352081302DD7813922D3B6302F27CE87B702303A313D3BCD0000E630272EC12B272A51
-S1233540C12D2726C12A2722C12F271EC13A271AC1202716C1302D17C1392213C03037CC12
-S1233560000A13B7C63319ED20CE87B7023A3D8604B7023A3D343536A67F27056A3020F873
-S1233580876A303231303D34353B8C0000274C2D533635348630CE3013CD00051635FF3061
-S12335A031876A4032CE000A18108E00002708CB306B60B7D420EE8C000026F3B6302F811C
-S12335C02D26026A60CE3013163575163605FD3024CE30131635F63A31303D863016362BFE
-S12335E03A31303D36862D7A302F3240800150C001C30001209B36876A300436FB323D6A45
-S1233600300436FB3D36A630270516362B20F7323D36353416363227FB810D270A6A301621
-S1233620362B03270220ED3031323D4FCC80FC5ACF3D4FCC200396CF3D873D5463616C6394
-S12336403E2000434D443E20004572726F723E2000496E76616C696420496E707574004F28
-S1233660766572666C6F77204572726F72000D0A436C6F636B2073746F7070656420616E06
-S123368064205479706577726974652070726F6772616D20737461727465642E0D0A596F99
-S12336A075206D617920747970652062656C6F772E0D0A002020202020202020202020204A
-S12336C02020202020202020202000436F6D6D616E64733A0D0A743A2053657420746865C8
-S12336E02074696D6520696E20666F726D61742048483A4D4D3A53530D0A683A20446973FA
-S1233700706C61792074686520686F757273206F6E207468652037207365676D656E742055
-S1233720646973706C6179730D0A6D3A20446973706C617920746865206D696E75746573E2
-S1233740206F6E207468652037207365676D656E7420646973706C6179730D0A733A2044EC
-S12337606973706C617920746865207365636F6E6473206F6E207468652037207365676DC2
-S1233780656E7420646973706C6179730D0A713A2053746F702074686520636C6F636B2020
-S11A37A0616E6420656E74657220747970657772697465720D0A0007
+S1103040000010730000000BB808000053DE
+S105FFF0316179
+S105FFE431B234
+S1233100CF310086F15A03860C5ACBCC00015CC8CE36EC1635A04C3B194C38804C37808627
+S1233120FF5A0310EF863E1635D086201635D0CE3030FD30411635ACCE303016333BCE304D
+S123314030FD304116359120DC14104D3880CE35F01635A01635D79727FA5A011635D0207E
+S1233160F34C378010EFFE302C087E302C8E00C8263FCE00007E302CFE302A087E302A8EF1
+S1233180003C262ACE00007E302AFE3028087E30288E003C2618CE00007E3028FE302608BD
+S12331A07E30268E00182606CE00007E30261633050BFC3047D35A5C5A4C4E2086017A3029
+S12331C04BFC3045C300017C3045BC304925031632D90B3B35B6304C81541827008A8174BC
+S12331E0182700AC81511827002B81711827005087F63044CD300016352236860D1635D0E4
+S1233200860A1635D032C300018C0100182600A4C71820009F87C6FFCD300016352236868A
+S12332200D1635D0860A1635D03287F63044C300018C01001826007CC786717A304C207441
+S123324087C7CD300016352236860D1635D0860A1635D03287F63044C300018C0100265435
+S1233260C786517A304C204C87F63044CD300016352236860D1635D0860A1635D032C3006B
+S1233280018C0100262E86747A304C830001202487F63044CD300016352236860D1635D051
+S12332A0860A1635D0328300018CFFFF260686547A304CC77B3044313A3D3B86205A405AF0
+S12332C04C86805A4686005A4DCC0BB8D3445C5A4C4E2086205A4C3A3D36875A4C323D3BE5
+S12332E0CC00007C30457A30441632BAB6304B27FB877A304B1631D3FC3045BC304925EC7D
+S12333001632D93A3D3BB6304381682605FC3026200C816D2605FC30282003FC302A1633EC
+S1233320233A3D3B34CE000A181037B7D4CE000A58585858EAB05B01303A3D3B35A630188B
+S12333402701898174267BA620812027FA1410FC30263B1634CFB7E48C00181824015F8C69
+S12333600000182D01587C3026A61F813A1826014DFC30283B1634CFB7E48C003C18240185
+S1233380398C0000182D01327C3028A61F813A18260127FC302A3B1634CFB7E48C003C180D
+S12333A02401138C0000182D010C7C302AA61F810018260101877A302C10EF3A3A3A182055
+S12333C0010A8168260FE630C100182600F67A3043182000F7816D260FE630C10018260061
+S12333E0E37A3043182000E48173260FE630C100182600D07A3043182000D18171260BE6D0
+S123340030C100182600BD0631498167182600B4A6308177263CE630C1002618CE363616CD
+S123342035A086537A304C1632DFCE36D41635A018200098C1321826008AE630C10018265A
+S12334400082CE36541635A0CE36D41635A01820007A81742620E630C10018260066CE3674
+S1233460781635A086547A304C1632DFCE36D41635A018200056817118260048E630C1004E
+S12334802618CE36961635A086717A304C1632DFCE36D41635A018200032C13218260024CF
+S12334A0E630C100261ECE36B21635A0CE36D41635A0182000163A7C302A3A7C30283A7C67
+S12334C0302610EF34CE35E01635A030313A3D3BCD0000E630272EC12B272AC12D2726C10D
+S12334E02A2722C12F271EC13A271AC1202716C1302D17C1392213C03037CC000A13B7C6D5
+S12335003319ED20CE87B7023A3D8604B7023A3D343536A67F27056A3020F8876A303231E9
+S1233520303D34353B8C0000274C2D533635348630CE3013CD000516359A3031876A403216
+S1233540CE000A18108E00002708CB306B60B7D420EE8C000026F3B6302F812D26026A60F1
+S1233560CE30131635101635A0FD3024CE30131635913A31303D86301635D03A31303D36FB
+S1233580862D7A302F3240800150C001C30001209B36876A300436FB323D6A300436FB3D11
+S12335A036A63027051635D020F7323D3635341635D727FB810D270A6A301635D0032702AB
+S12335C020ED860D1635D0860A1635D03031323D4FCC80FC5ACF3D4FCC200396CF3D873D10
+S12335E0496E76616C696420496E7075740D0A000D0A436C6F636B2073746F707065642077
+S1233600616E64205479706577726974652070726F6772616D20737461727465642E0D0A12
+S1233620596F75206D617920747970652062656C6F772E0D0A00736177746F6F7468207772
+S12336406176652067656E65726174696F6E2E2E2E0D0A00736177746F6F74682077617656
+S12336606520313235487A2067656E65726174696F6E2E2E2E0D0A00747269616E676C6524
+S123368020776176652067656E65726174696F6E2E2E2E0D0A007371756172652077617667
+S12336A0652067656E65726174696F6E2E2E2E0D0A007371756172652077617665203132CD
+S12336C035487A2067656E65726174696F6E2E2E2E0D0A00446F6E652067656E6572617476
+S12336E0696E6720776176652E0D0A00436F6D6D616E64733A0D0A67773A2067656E6572A4
+S123370061746520736177746F6F746820776176652C207072696E74696E672030207468FC
+S1233720726F756768203235352C20726570656174656420666F7220746F74616C203230E1
+S1233740343820706F696E74730D0A6777323A2067656E657261746520736177746F6F743F
+S1233760682077617665206F6620313235487A2C20776176652072657065617465642066AC
+S12337806F7220746F74616C203230343820706F696E74730D0A67743A2067656E65726197
+S12337A0746520747269616E676C6520776176652C207072696E74696E672030207468726E
+S12337C06F756768203235352C207468656E2032353520646F776E20746F20302C20726571
+S12337E070656174656420666F7220746F74616C203230343820706F696E74730D0A67710D
+S12338003A2067656E65726174652073717561726520776176652C207072696E74696E67C4
+S1233820203020666F72203235352074696D65732C207468656E207072696E7420323535CB
+S123384020666F72203235352074696D65732C207468656E20726570656174656420666FA5
+S12338607220746F74616C203230343820706F696E74730D0A6771323A2067656E657261F6
+S12338807465207371756172652077617665206F6620313235487A2C207761766520726562
+S12338A070656174656420666F7220746F74616C203230343820706F696E74730D0A743A76
+S12338C020536574207468652074696D6520696E20666F726D61742048483A4D4D3A535364
+S12338E00D0A683A20446973706C61792074686520686F757273206F6E207468652037208E
+S12339007365676D656E7420646973706C6179730D0A6D3A20446973706C61792074686512
+S1233920206D696E75746573206F6E207468652037207365676D656E7420646973706C61F9
+S123394079730D0A733A20446973706C617920746865207365636F6E6473206F6E20746854
+S1233960652037207365676D656E7420646973706C6179730D0A713A2053746F7020746867
+S12239806520636C6F636B20616E6420656E74657220747970657772697465720D0A006C
S9033100CB
diff --git a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/TargetDataWindows.tdt
index d623bdd..2d38aef 100644
--- a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/TargetDataWindows.tdt
+++ b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/TargetDataWindows.tdt
Binary files differ