summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2025-02-03 18:15:22 -0500
committerJacob McDonnell <jacob@jacobmcdonnell.com>2025-02-03 18:15:22 -0500
commitdab0e17cf2d1b2a1da9493235c571a9821ee8f97 (patch)
tree0ba2ba9fdc703a7187723a1d12b1d77b405f3d76
parentf88257c06ad029e9e3585d291be983da7ae9c137 (diff)
Probably Done
-rw-r--r--cmpen472hw3McDonnell/Full_Chip_Simulation.ini4
-rw-r--r--cmpen472hw3McDonnell/Sources/main.asm77
-rw-r--r--cmpen472hw3McDonnell/bin/Project.absbin3214 -> 3358 bytes
-rw-r--r--cmpen472hw3McDonnell/bin/Project.abs.phy2
-rw-r--r--cmpen472hw3McDonnell/bin/Project.abs.s1911
-rw-r--r--cmpen472hw3McDonnell/bin/main.dbg179
-rw-r--r--cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.obin3214 -> 3358 bytes
-rw-r--r--cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx11
-rw-r--r--cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdtbin61856 -> 62658 bytes
9 files changed, 146 insertions, 138 deletions
diff --git a/cmpen472hw3McDonnell/Full_Chip_Simulation.ini b/cmpen472hw3McDonnell/Full_Chip_Simulation.ini
index b9b9983..9f0ca55 100644
--- a/cmpen472hw3McDonnell/Full_Chip_Simulation.ini
+++ b/cmpen472hw3McDonnell/Full_Chip_Simulation.ini
@@ -43,7 +43,7 @@ DISPLAYTIME=0
[Recent Layout File List]
-File0=ASM_layout.hwl
-File1=
+File0=Full_Chip_Simulation.hwl
+File1=ASM_layout.hwl
File2=
File3=
diff --git a/cmpen472hw3McDonnell/Sources/main.asm b/cmpen472hw3McDonnell/Sources/main.asm
index bdbd7d5..a7b67f7 100644
--- a/cmpen472hw3McDonnell/Sources/main.asm
+++ b/cmpen472hw3McDonnell/Sources/main.asm
@@ -1,9 +1,54 @@
**************************************************************************
+*
+* Title: LED Light Dimmer
+*
+* Objective: CMPEN 472 Homework 3
+*
+* Revision: V1.0
+*
+* Date: Feb. 5, 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
+*
+* Register Use: A: LED Light on/off state and Switch 1 on/off state
+* X: Delay loop counter
+*
+* Memory Use: RAM Locations from $3000 for data,
+* RAM Locations from $3100 for program
+*
+* Input: Parameters hard-coded in the program - PORTB
+* Switch 1 at PORTB bit 0
+* Switch 2 at PORTB bit 1
+* Switch 3 at PORTB bit 2
+* Switch 4 at PORTB bit 3
+*
+* Output: LED 1 at PORTB bit 4
+* LED 2 at PORTB bit 5
+* 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.
+*
+* Note: ON CSM-12C128 board,
+* Switch 1 is at PORTB bit 0, and
+* LED 4 is at PORTB bit 7.
+*
+* Comments: This program is developed and simulated using CodeWarrior
+* development software and targeted for Axion
+* Manufacturing's CSM-12C128 board running at 24MHz.
+*
+**************************************************************************
* Parameter Declearation Section
*
* Export Symbols
- xdef pgstart ; export 'pgstart' symbol
- absentry pgstart ; for assembly entry point
+ xdef pgstart ; export 'pgstart' symbol
+ absentry pgstart ; for assembly entry point
* Symbols and Macros
PORTA equ $0000 ; i/o port A addresses
@@ -18,6 +63,9 @@ DDRB equ $0003 ; data direction register for PORTB
; for Data for CMPEN 472 class
Counter dc.w $0039 ; X register count number for time Delay
; loop for 10 useconds
+ ; The work to calculate this number is in
+ ; the comments for the delay10usec subroutine.
+
ONN dc.b $0005 ; Counter for how long LED should be on for
OFF dc.b $005f ; Counter for how long LED should be off for
@@ -77,17 +125,17 @@ p15LED4
dimmer
bset PORTB,%10000000 ; Turn LED4 on
psha ; Save A to the stack
-loop1 ldaa ONN ; Load counter ONN into A
- bne loop2 ; if zero jump to loop2 for off
+onDelay ldaa ONN ; Load counter ONN into A
+ beq skipToOff ; if zero jump to loop2 for off
jsr delay10usec ; delay for 10 microseconds
dec ONN ; decrement counter ONN by 1
- bra loop1 ; jump back to loop1 always
- bclr PORTB,%10000000 ; Turn off LED4
-loop2 ldaa OFF ; load counter OFF into A
- bne doneRunner ; if 0, skip loop
+ bra onDelay ; jump back to loop1 always
+skipToOff bclr PORTB,%10000000 ; Turn off LED4
+offDelay ldaa OFF ; load counter OFF into A
+ beq doneRunner ; if 0, skip loop
jsr delay10usec ; delay 10 microseconds
dec OFF ; decrement counter OFF by 1
- bra loop2 ; jump back to loop2 always
+ bra offDelay ; jump back to loop2 always
doneRunner pula ; restore A from the stack
rts ; return to caller
@@ -101,7 +149,14 @@ doneRunner pula ; restore A from the stack
; Registers in use: X register, as counter
; Memory locations in use: a 16bit input number at 'Counter'
;
-; Comments: Code relies on counter being $39 to be exactly 10 usec
+; Comments: Code relies on counter being $39 to be exactly 10 usec work is below
+; Given: freq = 24MHz = 24000000 sec = 10 usec = 0.00001
+; freq = cycles / seconds
+;
+; cycles = freq * seconds = 24000000Hz * 0.00001 = 240
+;
+; This sub routine is 12 + 4 * 'Counter' cycles long, solving for 'Counter'
+; the result is found to be 57.
;
delay10usec
@@ -113,5 +168,5 @@ innerLoop dex ; decrement register x by 1
nop ; extra nop to make exactly 10 usec
rts ; return to caller
- done
+ end ; last line of the file
diff --git a/cmpen472hw3McDonnell/bin/Project.abs b/cmpen472hw3McDonnell/bin/Project.abs
index 38dfc39..057d92f 100644
--- a/cmpen472hw3McDonnell/bin/Project.abs
+++ b/cmpen472hw3McDonnell/bin/Project.abs
Binary files differ
diff --git a/cmpen472hw3McDonnell/bin/Project.abs.phy b/cmpen472hw3McDonnell/bin/Project.abs.phy
index 7351f80..3d79e92 100644
--- a/cmpen472hw3McDonnell/bin/Project.abs.phy
+++ b/cmpen472hw3McDonnell/bin/Project.abs.phy
@@ -1,2 +1,2 @@
-S04A0000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C636D70656E3437326877334D63446F6E6E656C6C5C62696E5C50726F6A6563742E6162731F
+S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AD
S9030000FC
diff --git a/cmpen472hw3McDonnell/bin/Project.abs.s19 b/cmpen472hw3McDonnell/bin/Project.abs.s19
index 59324e5..aec3e53 100644
--- a/cmpen472hw3McDonnell/bin/Project.abs.s19
+++ b/cmpen472hw3McDonnell/bin/Project.abs.s19
@@ -1,7 +1,6 @@
-S04A0000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C636D70656E3437326877334D63446F6E6E656C6C5C62696E5C50726F6A6563742E6162731F
-S1073000008F000C2D
-S1233100CF310086F15A0386005A0196018401262016315D16315D16315116315116315184
-S123312016315116315116315116315116315120DA16315D16315D16315D16315D16315D65
-S123314016315D16315D16315D16315116315120BA36867F94015A01163169323D368680EF
-S12231609A015A01163169323D35FD30021631750326FA313D34FE3000A70926FC303DE5
+S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AD
+S10730000039055F2B
+S1233100CF310086F15A0386005A0196018401260F86057A3002865F7A300316312F20EB5B
+S1233120860F7A300286557A300316312F20DC4C018036B63002270816315273300220F3E5
+S11F31404D0180B63003270816315273300320F3323D34FE30000926FD30A73D26
S9030000FC
diff --git a/cmpen472hw3McDonnell/bin/main.dbg b/cmpen472hw3McDonnell/bin/main.dbg
index 592bf1b..9ea0717 100644
--- a/cmpen472hw3McDonnell/bin/main.dbg
+++ b/cmpen472hw3McDonnell/bin/main.dbg
@@ -2,8 +2,8 @@
* Parameter Declearation Section
*
* Export Symbols
- xdef pgstart ; export 'pgstart' symbol
- absentry pgstart ; for assembly entry point
+ xdef pgstart ; export 'pgstart' symbol
+ absentry pgstart ; for assembly entry point
* Symbols and Macros
PORTA equ $0000 ; i/o port A addresses
@@ -16,10 +16,11 @@ DDRB equ $0003 ; data direction register for PORTB
*
org $3000 ; Reserved RAM memory starting address
; for Data for CMPEN 472 class
-Counter1 dc.w $008f ; X register count number for time Delay
- ; inner loop for msec
-Counter2 dc.w $000c ; Y register count number for time delay
- ; output loop for sec
+Counter dc.w $0039 ; X register count number for time Delay
+ ; loop for 10 useconds
+ONN dc.b $0005 ; Counter for how long LED should be on for
+
+OFF dc.b $005f ; Counter for how long LED should be off for
*
**************************************************************************
* Program Section: address used [ $3100 to $3FFF ] RAM Memory
@@ -29,132 +30,86 @@ pgstart lds #$3100 ; initialize the stack pointer
ldaa #%11110001 ; LED 1,2,3,4 at PORTB bit 4,5,6,7
staa DDRB ; set PORTB bit 4,5,6,7 as output
-
-
+
+
ldaa #%00000000
staa PORTB ; clear all bits of PORTB
-
+
mainLoop
ldaa PORTB ; check bit 0 of PORTB, switch 1
anda #%00000001 ; if 0, run blinkLED4 20% light level
- bne p80LED4 ; if 1, run blinkLED4 80% light level
-
-p20LED4
- jsr LED4on ; 20% light level (duty cycle)
- jsr LED4on
- jsr LED4off
- jsr LED4off
- jsr LED4off
- jsr LED4off
- jsr LED4off
- jsr LED4off
- jsr LED4off
- jsr LED4off
- bra mainLoop ; check switch, loop forever
-
-p80LED4
- jsr LED4on ; 80% light level (duty cycle)
- jsr LED4on
- jsr LED4on
- jsr LED4on
- jsr LED4on
- jsr LED4on
- jsr LED4on
- jsr LED4on
- jsr LED4off
- jsr LED4off
- bra mainLoop ; check switch, loop forever
-
+ bne p15LED4 ; if 1, run blinkLED4 80% light level
+
+p05LED4
+ ldaa #5 ; load 5 into accumulator A
+ staa ONN ; store A in counter ONN
+ ldaa #95 ; load 95 into accumulator A
+ staa OFF ; store A in counter OFF
+ jsr dimmer ; jump to dimmer subroutine
+ bra mainLoop ; loop to mainLoop to check switch
+
+p15LED4
+ ldaa #15 ; load 15 into accumulator A
+ staa ONN ; store A in counter ONN
+ ldaa #85 ; load 85 into accumulator A
+ staa OFF ; store A in counter OFF
+ jsr dimmer ; jump to dimmer subroutine
+ bra mainLoop ; loop to mainLoop to check switch
+
**************************************************************************
* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory
*
;*************************************************************************
-; LED4off subroutine
-;
-; This subroutine will turn LED4 off and delay for 1 second
-;
-; Input: no input, parameters are hardcoded
-; Output: LED4 off and delay for 1 second, wasted cycles
-; Registers in use: A accumulator to turn LED4 off
-; Memory locations in use: A 16bit address parameter for PORTB
-;
-; Comments: This subroutine requires delay1sec subroutine
-;
-LED4off
- psha ; save A register to the stack
- ldaa #%01111111 ; turn off LED 4 at PORTB bit 7
- anda PORTB
- staa PORTB
- jsr delay1sec ; wait for 1 second
- pula ; restore A from the stack
- rts ; return to caller
-
-;*************************************************************************
-; LED4on subroutine
+; dimmer subroutine
;
-; This subroutine will turn LED4 on and delay for 1 second
+; This subroutine will dim LED4 to a given level
;
-; Input: no input, parameters are hardcoded
-; Output: LED4 on and delay for 1 second, wasted cycles
-; Registers in use: A accumulator to turn LED4 on
-; Memory locations in use: A 16bit address parameter for PORTB
+; Input: Two 1 byte counters, ONN and OFF, for how many times
+; LED4 should be on and off for.
+; Output: LED4 dimmed to a given level, wasted cycles
+; Registers in use: A accumulator to counter number of times looped
+; Memory locations in use: Two bytes ONN and OFF used to dim the LED4 to a given level
;
-; Comments: This subroutine requires delay1sec subroutine
+; Comments: This subroutine requires delay10usec subroutine
;
-LED4on
- psha ; save A register to the stack
- ldaa #%10000000 ; turn on LED 4 at PORTB bit 7
- oraa PORTB
- staa PORTB
- jsr delay1sec ; wait for 1 second
- pula ; restore A from the stack
+
+dimmer
+ bset PORTB,%10000000 ; Turn LED4 on
+ psha ; Save A to the stack
+loop1 ldaa ONN ; Load counter ONN into A
+ beq skipToOff ; if zero jump to loop2 for off
+ jsr delay10usec ; delay for 10 microseconds
+ dec ONN ; decrement counter ONN by 1
+ bra loop1 ; jump back to loop1 always
+skipToOff bclr PORTB,%10000000 ; Turn off LED4
+loop2 ldaa OFF ; load counter OFF into A
+ beq doneRunner ; if 0, skip loop
+ jsr delay10usec ; delay 10 microseconds
+ dec OFF ; decrement counter OFF by 1
+ bra loop2 ; jump back to loop2 always
+doneRunner pula ; restore A from the stack
rts ; return to caller
-
-;*************************************************************************
-; delay1sec subroutine
-;
-; This subroutine will delay for 1 second
-;
-; Input: a 16 bit count number in 'Counter2'
-; Output: time delay of 1 second, cpu cycles wasted
-; Registers in use: Y register as counter
-; Memory locations in use: a 16bit input number at 'Counter2'
-;
-; Comments: This subroutine requires delayMS subroutine
-;
-delay1sec
- pshy ; save Y to the stack
- ldy Counter2 ; long delay by the value of Counter2
-
-dly1Loop jsr delayMS ; total time delay = Y * delayMS
- dey
- bne dly1Loop
-
- puly ; restore y from the stack
- rts ; return
-
;*************************************************************************
-; delayMS subroutine
+; delay10usec subroutine
;
-; This subroutine causes a few msec. Delay
+; This subroutine causes a 10 usec. delay
;
-; Input: a 16bit count number in 'Counter1'
+; Input: a 16bit count number in 'Counter'
; Output: time delay, cpu cycle wasted
; Registers in use: X register, as counter
-; Memory locations in use: a 16bit input number at 'Counter1'
-;
-; Comments: one can add more NOP instructions to lengthen the delay time.
+; Memory locations in use: a 16bit input number at 'Counter'
+;
+; Comments: Code relies on counter being $39 to be exactly 10 usec
;
-delayMS
- pshx ; save X to the stack
- ldx Counter1 ; short Delay
-
-dlyMSLoop nop ; total time delay = X * NOP
- dex
- bne dlyMSLoop
-
- pulx ; restore X
- rts ; return
+delay10usec
+ pshx ; Save register x to the stack
+ ldx Counter ; load counter into register x
+innerLoop dex ; decrement register x by 1
+ bne innerLoop ; loop while register x is not 0
+ pulx ; restore register x from the stack
+ nop ; extra nop to make exactly 10 usec
+ rts ; return to caller
+
diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o
index 38dfc39..057d92f 100644
--- a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o
+++ b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o
Binary files differ
diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx
index 942adfa..ffb691f 100644
--- a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx
+++ b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx
@@ -1,7 +1,6 @@
-S0750000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C636D70656E3437326877334D63446F6E6E656C6C5C636D70656E3437326877334D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726D05
-S1073000008F000C2D
-S1233100CF310086F15A0386005A0196018401262016315D16315D16315116315116315184
-S123312016315116315116315116315116315120DA16315D16315D16315D16315D16315D65
-S123314016315D16315D16315D16315116315120BA36867F94015A01163169323D368680EF
-S12231609A015A01163169323D35FD30021631750326FA313D34FE3000A70926FC303DE5
+S0820000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C636D70656E3437326877334D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726D93
+S10730000039055F2B
+S1233100CF310086F15A0386005A0196018401260F86057A3002865F7A300316312F20EB5B
+S1233120860F7A300286557A300316312F20DC4C018036B63002270816315273300220F3E5
+S11F31404D0180B63003270816315273300320F3323D34FE30000926FD30A73D26
S9033100CB
diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt
index bcd0560..a198002 100644
--- a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt
+++ b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt
Binary files differ