summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2025-04-07 13:49:40 -0400
committerJacob McDonnell <jacob@jacobmcdonnell.com>2025-04-07 13:49:40 -0400
commit9b8d7d6fc21b4627973a100c73eca46e8f8524ed (patch)
tree3d6073ea49b011a1f562c57e1db19c458707542b
parent0f186fcaa044dcd15fe17ef660f5ea3e03de20a7 (diff)
HW10: Fixed Square Wave
-rw-r--r--cmpen472hw10_McDonnell/Sources/main.asm31
1 files changed, 24 insertions, 7 deletions
diff --git a/cmpen472hw10_McDonnell/Sources/main.asm b/cmpen472hw10_McDonnell/Sources/main.asm
index 245ce86..48b407b 100644
--- a/cmpen472hw10_McDonnell/Sources/main.asm
+++ b/cmpen472hw10_McDonnell/Sources/main.asm
@@ -101,7 +101,9 @@ outputCnt dc.w $0000 ; Used to track how many values have bee
interval dc.w $3000 ; Used to set the timer module based on clock cycles
waveType dc.b 'S' ; Used to track wave type 'T' for increasing triangle,
- ; 't' for decreasing triangle, 'Q' for square
+ ; 't' for decreasing triangle,
+ ; 'Q' for square high
+ ; 'q' for square low
; 'S' for sawtooth
*
@@ -264,7 +266,9 @@ PrintWave
cmpa #'t' ; Compare A to 't'
beq TriangleDec ; If A == 't', triangle wave decreasing
cmpa #'Q' ; Compare A to 'Q'
- beq SquareWave ; If A == 'Q', square wave
+ beq SquareWaveH ; If A == 'Q', square wave high
+ cmpa #'q' ; Compare A to 'q'
+ beq SquareWaveL ; If A == 'q', square wave low
SawToothWav clra ; Clear A
ldab outputVal ; Load the output value into B
jsr PrintDecimalWord; Print the lower byte of the output value;
@@ -273,14 +277,27 @@ SawToothWav clra ; Clear A
bne DonePrint ; If D != 256, Done
clrb ; Reset to Zero
bra DonePrint ; Branch to DonePrint
-SquareWave clra ; Clear A
+SquareWaveH clra ; Clear A
+ ldab #255 ; Load 255 into B
+ jsr PrintDecimalWord; Print the lower byte of the output value;
ldab outputVal ; Load the output value into B
+ addb #1 ; Add 1 to B
+ cmpb #255 ; Compare B to 255
+ bnq DonePrint ; If B != 255, done
+ clrb ; Reset B to zero
+ ldaa #'q' ; Load 'q' into A
+ staa waveType ; Update wave type to square wave low
+ bra DonePrint ; Branch to DonePrint
+SquareWaveL clra ; Clear A
+ clrb ; Reset B to zero
jsr PrintDecimalWord; Print the lower byte of the output value;
+ ldab outputVal ; Load the output value into B
+ addb #1 ; Add 1 to B
cmpb #255 ; Compare B to 255
- beq SquareIsHi ; If B == 255, branch to SquareIsHi
- ldab #255 ; Load 255 into B
- bra DonePrint ; Branch always to DonePrint
-SquareIsHi clrb ; Reset B to zero
+ bnq DonePrint ; If B != 255, done
+ clrb ; Reset B to zero
+ ldaa #'Q' ; Load 'Q' into A
+ staa waveType ; Update wave type to square wave low
bra DonePrint ; Branch to DonePrint
TriangleInc clra ; Clear A
ldab outputVal ; Load the output value into B