summaryrefslogtreecommitdiff
path: root/cmpen472hw4_McDonnell/bin/main.dbg
diff options
context:
space:
mode:
Diffstat (limited to 'cmpen472hw4_McDonnell/bin/main.dbg')
-rw-r--r--cmpen472hw4_McDonnell/bin/main.dbg86
1 files changed, 43 insertions, 43 deletions
diff --git a/cmpen472hw4_McDonnell/bin/main.dbg b/cmpen472hw4_McDonnell/bin/main.dbg
index 4154ae3..853722f 100644
--- a/cmpen472hw4_McDonnell/bin/main.dbg
+++ b/cmpen472hw4_McDonnell/bin/main.dbg
@@ -1,22 +1,22 @@
**************************************************************************
*
-* Title: LED Light Dimmer
+* Title: LED Light Dimmer Loop
*
-* Objective: CMPEN 472 Homework 3
+* Objective: CMPEN 472 Homework 4
*
* Revision: V1.0
*
-* Date: Feb. 5, 2025
+* Date: Feb. 14, 2025
*
* Programmer: Jacob McDonnell
*
* Company: The Pennsylvania State University
* Department of Computer Science and Engineering
*
-* Algorithm: Simple Parallel I/O use and time delay-loop demo
+* Algorithm: Simple Parallel I/O use, time delay-loop, and PWM control
*
-* Register Use: A: LED Light on/off state and Switch 1 on/off state
-* X: Delay loop counter
+* Register Use: A to control LEDS initially and for Light Level
+* X to hold the counter in the loop.
*
* Memory Use: RAM Locations from $3000 for data,
* RAM Locations from $3100 for program
@@ -32,8 +32,9 @@
* LED 3 at PORTB bit 6
* LED 4 at PORTB bit 7
*
-* Observation: This program will dim the LED4 to either 5% when the
-* switch is not pressed and 15% when the switch is pressed.
+* Observation: This program will decrease LED 4 from 100% to 0% in 400ms
+* and then increase LED 4 from 0% to 100% in 400ms. The program
+* will loop forever.
*
* Note: ON CSM-12C128 board,
* Switch 1 is at PORTB bit 0, and
@@ -83,25 +84,24 @@ pgstart lds #$3100 ; initialize the stack pointer
staa PORTB ; Turn on only LEDs 1 & 3 on PORTB
mainLoop
- ldaa #100 ; 1 ; load 100 into accumulator A
- ldab #100 ; 1 ; load 100 into accumulator B
-decrease tbeq A,increase ; 3 ; Test if A == 0, skip loop if so
- staa LEVEL ; 3 ; store A in counter LEVEL
- jsr dimmer ; 4 + 25,135 ; jump to dimmer subroutine
- jsr dimmer ; 4 + 25,135 ; jump to dimmer subroutine
- jsr dimmer ; 4 + 25,135 ; jump to dimmer subroutine
- jsr dimmer ; 4 + 25,135 ; jump to dimmer subroutine
- deca ; 1 ; decrement accumulator A by 1
- bra decrease ; 3 ; loop to decrease always
-increase tbeq B,mainLoop ; 3 ; Test if B == 0, go back to mainLoop if so
- staa LEVEL ; 3 ; store A in counter LEVEL
- jsr dimmer ; 4 + 25,135 ; jump to dimmer subroutine
- jsr dimmer ; 4 + 25,135 ; jump to dimmer subroutine
- jsr dimmer ; 4 + 25,135 ; jump to dimmer subroutine
- jsr dimmer ; 4 + 25,135 ; jump to dimmer subroutine
- inca ; 1 ; increment accumulator A by 1
- decb ; 1 ; decrement accumulator B by 1
- bra increase ; 3 ; loop to increase always
+ ldaa #100 ; load 100 into accumulator A
+decrease tbeq A,increase ; Test if A == 0, skip loop if so
+ staa LEVEL ; store A in counter LEVEL
+ jsr dimmer ; jump to dimmer subroutine
+ jsr dimmer ; jump to dimmer subroutine
+ jsr dimmer ; jump to dimmer subroutine
+ jsr dimmer ; jump to dimmer subroutine
+ deca ; decrement accumulator A by 1
+ bra decrease ; loop to decrease always
+increase cmpa #100 ; Compare A to 100
+ beq mainLoop ; Test if A == 100, jump to mainLoop
+ staa LEVEL ; store A in counter LEVEL
+ jsr dimmer ; jump to dimmer subroutine
+ jsr dimmer ; jump to dimmer subroutine
+ jsr dimmer ; jump to dimmer subroutine
+ jsr dimmer ; jump to dimmer subroutine
+ inca ; increment accumulator A by 1
+ bra increase ; loop to increase always
**************************************************************************
* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory
@@ -122,22 +122,22 @@ increase tbeq B,mainLoop ; 3 ; Test if B == 0, go back to mainLoo
;
dimmer
- bset PORTB,%10000000 ; 6 ; Turn LED4 on
- psha ; 2 ; Save A to the stack
- ldaa LEVEL ; 3 ; Load the light level into accumulator A
-onDelay tbeq A, skipToOff ; 3 ; Test if A == 0, skip loop if so
- jsr delay10usec ; 244 ; delay for 10 microseconds
- deca ; 1 ; decrement accumulator A by 1
- bra onDelay ; 3, 1; jump back to onDelay always
-skipToOff bclr PORTB,%10000000 ; 6 ; Turn off LED4
- ldaa #100 ; 1 ; load 100 into accumulator A
- suba LEVEL ; 3 ; Subtract LEVEL to get off count
-offDelay tbeq A,doneLoop ; 3 ; Test if A == 0, skip loop if so
- jsr delay10usec ; 244 ; delay 10 microseconds
- deca ; 1 ; decrement accumulator A by 1
- bra offDelay ; 3, 1; jump back to offDelay always
-doneLoop pula ; 3 ; restore A from the stack
- rts ; 5 ; return to caller
+ bset PORTB,%10000000 ; Turn LED4 on
+ psha ; Save A to the stack
+ ldaa LEVEL ; Load the light level into accumulator A
+onDelay tbeq A, skipToOff ; Test if A == 0, skip loop if so
+ jsr delay10usec ; delay for 10 microseconds
+ deca ; decrement accumulator A by 1
+ bra onDelay ; jump back to onDelay always
+skipToOff bclr PORTB,%10000000 ; Turn off LED4
+ ldaa #100 ; load 100 into accumulator A
+ suba LEVEL ; Subtract LEVEL to get off count
+offDelay tbeq A,doneLoop ; Test if A == 0, skip loop if so
+ jsr delay10usec ; delay 10 microseconds
+ deca ; decrement accumulator A by 1
+ bra offDelay ; jump back to offDelay always
+doneLoop pula ; restore A from the stack
+ rts ; return to caller
;*************************************************************************
; delay10usec subroutine