From fd3d5b220e20b5279a453739b42aae8becd69ca9 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Tue, 1 Apr 2025 18:21:56 -0400 Subject: HW9: Initial glue of 7 & 8 --- HW1/ASM_layout.hwl | 18 - HW1/CMPEN472HW1McDonnell.mcp | Bin 57065 -> 0 bytes .../CWSettingsWindows.stg | Bin 4263 -> 0 bytes .../Standard/ObjectCode/main.asm.o | Bin 2998 -> 0 bytes .../Standard/ObjectCode/main.asm.sx | 11 - .../Standard/TargetDataWindows.tdt | Bin 62658 -> 0 bytes HW1/Default.mem | Bin 285 -> 0 bytes HW1/Full_Chip_Simulation.ini | 27 - HW1/Sources/cmpen472hw1_McDonnell.asm | 63 -- HW1/Sources/derivative.inc | 10 - HW1/Sources/main.asm | 63 -- HW1/bin/Project.abs | Bin 2998 -> 0 bytes HW1/bin/Project.abs.phy | 2 - HW1/bin/Project.abs.s19 | 11 - HW1/bin/main.dbg | 62 -- HW1/cmd/Full_Chip_Simulation_Postload.cmd | 1 - HW1/cmd/Full_Chip_Simulation_Preload.cmd | 1 - HW1/cmd/Full_Chip_Simulation_Reset.cmd | 1 - HW1/cmd/Full_Chip_Simulation_SetCPU.cmd | 1 - HW1/cmd/Full_Chip_Simulation_Startup.cmd | 1 - HW1/prm/burner.bbl | 157 ---- cmpen472_hw8McDonnell/ASM_layout.hwl | 27 - cmpen472_hw8McDonnell/Default.mem | Bin 285 -> 0 bytes cmpen472_hw8McDonnell/Full_Chip_Simulation.hwc | 1 - cmpen472_hw8McDonnell/Full_Chip_Simulation.ini | 42 - .../Sources/cmpen472hw8_McDonnell.asm | 764 ----------------- cmpen472_hw8McDonnell/Sources/derivative.inc | 10 - cmpen472_hw8McDonnell/Sources/main.asm | 764 ----------------- cmpen472_hw8McDonnell/bin/Project.abs | Bin 8176 -> 0 bytes cmpen472_hw8McDonnell/bin/Project.abs.phy | 3 - cmpen472_hw8McDonnell/bin/Project.abs.s19 | 44 - cmpen472_hw8McDonnell/bin/main.dbg | 763 ----------------- .../cmd/Full_Chip_Simulation_Postload.cmd | 1 - .../cmd/Full_Chip_Simulation_Preload.cmd | 1 - .../cmd/Full_Chip_Simulation_Reset.cmd | 1 - .../cmd/Full_Chip_Simulation_SetCPU.cmd | 1 - .../cmd/Full_Chip_Simulation_Startup.cmd | 1 - cmpen472_hw8McDonnell/cmpen472_hw8McDonnell.mcp | Bin 57065 -> 0 bytes .../CWSettingsWindows.stg | Bin 4263 -> 0 bytes .../Standard/ObjectCode/main.asm.o | Bin 8176 -> 0 bytes .../Standard/ObjectCode/main.asm.sx | 44 - .../Standard/TargetDataWindows.tdt | Bin 65147 -> 0 bytes cmpen472_hw8McDonnell/prm/burner.bbl | 157 ---- cmpen472hw1_McDonnell/ASM_layout.hwl | 18 + cmpen472hw1_McDonnell/CMPEN472HW1McDonnell.mcp | Bin 0 -> 57065 bytes .../CWSettingsWindows.stg | Bin 0 -> 4263 bytes .../Standard/ObjectCode/main.asm.o | Bin 0 -> 2998 bytes .../Standard/ObjectCode/main.asm.sx | 11 + .../Standard/TargetDataWindows.tdt | Bin 0 -> 62658 bytes cmpen472hw1_McDonnell/Default.mem | Bin 0 -> 285 bytes cmpen472hw1_McDonnell/Full_Chip_Simulation.ini | 27 + .../Sources/cmpen472hw1_McDonnell.asm | 63 ++ cmpen472hw1_McDonnell/Sources/derivative.inc | 10 + cmpen472hw1_McDonnell/Sources/main.asm | 63 ++ cmpen472hw1_McDonnell/bin/Project.abs | Bin 0 -> 2998 bytes cmpen472hw1_McDonnell/bin/Project.abs.phy | 2 + cmpen472hw1_McDonnell/bin/Project.abs.s19 | 11 + cmpen472hw1_McDonnell/bin/main.dbg | 62 ++ .../cmd/Full_Chip_Simulation_Postload.cmd | 1 + .../cmd/Full_Chip_Simulation_Preload.cmd | 1 + .../cmd/Full_Chip_Simulation_Reset.cmd | 1 + .../cmd/Full_Chip_Simulation_SetCPU.cmd | 1 + .../cmd/Full_Chip_Simulation_Startup.cmd | 1 + cmpen472hw1_McDonnell/prm/burner.bbl | 157 ++++ cmpen472hw2McDonnell/ASM_layout.hwl | 26 - cmpen472hw2McDonnell/Default.mem | Bin 285 -> 0 bytes cmpen472hw2McDonnell/Full_Chip_Simulation.hwc | 1 - cmpen472hw2McDonnell/Full_Chip_Simulation.ini | 49 -- .../Sources/cmpen472hw2_McDonnell.asm | 202 ----- cmpen472hw2McDonnell/Sources/derivative.inc | 10 - cmpen472hw2McDonnell/Sources/main.asm | 202 ----- cmpen472hw2McDonnell/bin/Project.abs | Bin 3286 -> 0 bytes cmpen472hw2McDonnell/bin/Project.abs.phy | 2 - cmpen472hw2McDonnell/bin/Project.abs.s19 | 6 - cmpen472hw2McDonnell/bin/main.dbg | 169 ---- .../cmd/Full_Chip_Simulation_Postload.cmd | 1 - .../cmd/Full_Chip_Simulation_Preload.cmd | 1 - .../cmd/Full_Chip_Simulation_Reset.cmd | 1 - .../cmd/Full_Chip_Simulation_SetCPU.cmd | 1 - .../cmd/Full_Chip_Simulation_Startup.cmd | 1 - cmpen472hw2McDonnell/cmpen472hw2McDonnell.mcp | Bin 57065 -> 0 bytes .../CWSettingsWindows.stg | Bin 4263 -> 0 bytes .../Standard/ObjectCode/main.asm.o | Bin 3286 -> 0 bytes .../Standard/ObjectCode/main.asm.sx | 6 - .../Standard/TargetDataWindows.tdt | Bin 62658 -> 0 bytes cmpen472hw2McDonnell/debuggerlayout.hwl | 26 - cmpen472hw2McDonnell/debuggerlayout.ini | 42 - cmpen472hw2McDonnell/prm/burner.bbl | 157 ---- cmpen472hw2_McDonnell/ASM_layout.hwl | 26 + cmpen472hw2_McDonnell/Default.mem | Bin 0 -> 285 bytes cmpen472hw2_McDonnell/Full_Chip_Simulation.hwc | 1 + cmpen472hw2_McDonnell/Full_Chip_Simulation.ini | 49 ++ .../Sources/cmpen472hw2_McDonnell.asm | 202 +++++ cmpen472hw2_McDonnell/Sources/derivative.inc | 10 + cmpen472hw2_McDonnell/Sources/main.asm | 202 +++++ cmpen472hw2_McDonnell/bin/Project.abs | Bin 0 -> 3286 bytes cmpen472hw2_McDonnell/bin/Project.abs.phy | 2 + cmpen472hw2_McDonnell/bin/Project.abs.s19 | 6 + cmpen472hw2_McDonnell/bin/main.dbg | 169 ++++ .../cmd/Full_Chip_Simulation_Postload.cmd | 1 + .../cmd/Full_Chip_Simulation_Preload.cmd | 1 + .../cmd/Full_Chip_Simulation_Reset.cmd | 1 + .../cmd/Full_Chip_Simulation_SetCPU.cmd | 1 + .../cmd/Full_Chip_Simulation_Startup.cmd | 1 + cmpen472hw2_McDonnell/cmpen472hw2McDonnell.mcp | Bin 0 -> 57065 bytes .../CWSettingsWindows.stg | Bin 0 -> 4263 bytes .../Standard/ObjectCode/main.asm.o | Bin 0 -> 3286 bytes .../Standard/ObjectCode/main.asm.sx | 6 + .../Standard/TargetDataWindows.tdt | Bin 0 -> 62658 bytes cmpen472hw2_McDonnell/debuggerlayout.hwl | 26 + cmpen472hw2_McDonnell/debuggerlayout.ini | 42 + cmpen472hw2_McDonnell/prm/burner.bbl | 157 ++++ cmpen472hw3McDonnell/ASM_layout.hwl | 18 - cmpen472hw3McDonnell/Default.mem | Bin 285 -> 0 bytes cmpen472hw3McDonnell/Full_Chip_Simulation.hwc | 1 - cmpen472hw3McDonnell/Full_Chip_Simulation.hwl | 26 - cmpen472hw3McDonnell/Full_Chip_Simulation.ini | 49 -- .../Sources/cmpen472hw3_McDonnell.asm | 173 ---- cmpen472hw3McDonnell/Sources/derivative.inc | 10 - cmpen472hw3McDonnell/Sources/main.asm | 173 ---- cmpen472hw3McDonnell/bin/Project.abs | Bin 3358 -> 0 bytes cmpen472hw3McDonnell/bin/Project.abs.phy | 2 - cmpen472hw3McDonnell/bin/Project.abs.s19 | 6 - cmpen472hw3McDonnell/bin/main.dbg | 171 ---- .../cmd/Full_Chip_Simulation_Postload.cmd | 1 - .../cmd/Full_Chip_Simulation_Preload.cmd | 1 - .../cmd/Full_Chip_Simulation_Reset.cmd | 1 - .../cmd/Full_Chip_Simulation_SetCPU.cmd | 1 - .../cmd/Full_Chip_Simulation_Startup.cmd | 1 - cmpen472hw3McDonnell/cmpen472hw3McDonnell.mcp | Bin 57065 -> 0 bytes .../CWSettingsWindows.stg | Bin 4263 -> 0 bytes .../Standard/ObjectCode/main.asm.o | Bin 3358 -> 0 bytes .../Standard/ObjectCode/main.asm.sx | 6 - .../Standard/TargetDataWindows.tdt | Bin 62658 -> 0 bytes cmpen472hw3McDonnell/prm/burner.bbl | 157 ---- cmpen472hw3_McDonnell/ASM_layout.hwl | 18 + cmpen472hw3_McDonnell/Default.mem | Bin 0 -> 285 bytes cmpen472hw3_McDonnell/Full_Chip_Simulation.hwc | 1 + cmpen472hw3_McDonnell/Full_Chip_Simulation.hwl | 26 + cmpen472hw3_McDonnell/Full_Chip_Simulation.ini | 49 ++ .../Sources/cmpen472hw3_McDonnell.asm | 173 ++++ cmpen472hw3_McDonnell/Sources/derivative.inc | 10 + cmpen472hw3_McDonnell/Sources/main.asm | 173 ++++ cmpen472hw3_McDonnell/bin/Project.abs | Bin 0 -> 3358 bytes cmpen472hw3_McDonnell/bin/Project.abs.phy | 2 + cmpen472hw3_McDonnell/bin/Project.abs.s19 | 6 + cmpen472hw3_McDonnell/bin/main.dbg | 171 ++++ .../cmd/Full_Chip_Simulation_Postload.cmd | 1 + .../cmd/Full_Chip_Simulation_Preload.cmd | 1 + .../cmd/Full_Chip_Simulation_Reset.cmd | 1 + .../cmd/Full_Chip_Simulation_SetCPU.cmd | 1 + .../cmd/Full_Chip_Simulation_Startup.cmd | 1 + cmpen472hw3_McDonnell/cmpen472hw3McDonnell.mcp | Bin 0 -> 57065 bytes .../CWSettingsWindows.stg | Bin 0 -> 4263 bytes .../Standard/ObjectCode/main.asm.o | Bin 0 -> 3358 bytes .../Standard/ObjectCode/main.asm.sx | 6 + .../Standard/TargetDataWindows.tdt | Bin 0 -> 62658 bytes cmpen472hw3_McDonnell/prm/burner.bbl | 157 ++++ cmpen472hw8_McDonnell/ASM_layout.hwl | 27 + cmpen472hw8_McDonnell/Default.mem | Bin 0 -> 285 bytes cmpen472hw8_McDonnell/Full_Chip_Simulation.hwc | 1 + cmpen472hw8_McDonnell/Full_Chip_Simulation.ini | 42 + .../Sources/cmpen472hw8_McDonnell.asm | 764 +++++++++++++++++ cmpen472hw8_McDonnell/Sources/derivative.inc | 10 + cmpen472hw8_McDonnell/Sources/main.asm | 764 +++++++++++++++++ cmpen472hw8_McDonnell/bin/Project.abs | Bin 0 -> 8176 bytes cmpen472hw8_McDonnell/bin/Project.abs.phy | 3 + cmpen472hw8_McDonnell/bin/Project.abs.s19 | 44 + cmpen472hw8_McDonnell/bin/main.dbg | 763 +++++++++++++++++ .../cmd/Full_Chip_Simulation_Postload.cmd | 1 + .../cmd/Full_Chip_Simulation_Preload.cmd | 1 + .../cmd/Full_Chip_Simulation_Reset.cmd | 1 + .../cmd/Full_Chip_Simulation_SetCPU.cmd | 1 + .../cmd/Full_Chip_Simulation_Startup.cmd | 1 + cmpen472hw8_McDonnell/cmpen472_hw8McDonnell.mcp | Bin 0 -> 57065 bytes .../CWSettingsWindows.stg | Bin 0 -> 4263 bytes .../Standard/ObjectCode/main.asm.o | Bin 0 -> 8176 bytes .../Standard/ObjectCode/main.asm.sx | 44 + .../Standard/TargetDataWindows.tdt | Bin 0 -> 65147 bytes cmpen472hw8_McDonnell/prm/burner.bbl | 157 ++++ cmpen472hw9_McDonnell/ASM_layout.hwl | 27 + cmpen472hw9_McDonnell/Default.mem | Bin 0 -> 285 bytes cmpen472hw9_McDonnell/Full_Chip_Simulation.hwc | 1 + cmpen472hw9_McDonnell/Full_Chip_Simulation.ini | 42 + cmpen472hw9_McDonnell/Sources/derivative.inc | 10 + cmpen472hw9_McDonnell/Sources/main.asm | 929 +++++++++++++++++++++ cmpen472hw9_McDonnell/bin/Project.abs | Bin 0 -> 9172 bytes cmpen472hw9_McDonnell/bin/Project.abs.phy | 3 + cmpen472hw9_McDonnell/bin/Project.abs.s19 | 52 ++ cmpen472hw9_McDonnell/bin/main.dbg | 928 ++++++++++++++++++++ .../cmd/Full_Chip_Simulation_Postload.cmd | 1 + .../cmd/Full_Chip_Simulation_Preload.cmd | 1 + .../cmd/Full_Chip_Simulation_Reset.cmd | 1 + .../cmd/Full_Chip_Simulation_SetCPU.cmd | 1 + .../cmd/Full_Chip_Simulation_Startup.cmd | 1 + cmpen472hw9_McDonnell/cmpen472hw9_McDonnell.mcp | Bin 0 -> 57065 bytes .../CWSettingsWindows.stg | Bin 0 -> 2004 bytes .../Standard/ObjectCode/main.asm.o | Bin 0 -> 9172 bytes .../Standard/ObjectCode/main.asm.sx | 52 ++ .../Standard/TargetDataWindows.tdt | Bin 0 -> 61908 bytes cmpen472hw9_McDonnell/prm/burner.bbl | 157 ++++ exam2prep/ASM_layout.hwl | 27 + exam2prep/Default.mem | Bin 0 -> 285 bytes exam2prep/Full_Chip_Simulation.hwc | 1 + exam2prep/Full_Chip_Simulation.ini | 42 + exam2prep/Sources/cmpen472hw8_McDonnell.asm | 764 +++++++++++++++++ exam2prep/Sources/derivative.inc | 10 + exam2prep/Sources/main.asm | 640 ++++++++++++++ exam2prep/bin/Project.abs | Bin 0 -> 7524 bytes exam2prep/bin/Project.abs.phy | 3 + exam2prep/bin/Project.abs.s19 | 36 + exam2prep/bin/main.dbg | 639 ++++++++++++++ exam2prep/cmd/Full_Chip_Simulation_Postload.cmd | 1 + exam2prep/cmd/Full_Chip_Simulation_Preload.cmd | 1 + exam2prep/cmd/Full_Chip_Simulation_Reset.cmd | 1 + exam2prep/cmd/Full_Chip_Simulation_SetCPU.cmd | 1 + exam2prep/cmd/Full_Chip_Simulation_Startup.cmd | 1 + exam2prep/cmpen472_hw8McDonnell.mcp | Bin 0 -> 57065 bytes .../CWSettingsWindows.stg | Bin 0 -> 4263 bytes .../Standard/ObjectCode/main.asm.o | Bin 0 -> 7524 bytes .../Standard/ObjectCode/main.asm.sx | 36 + .../Standard/TargetDataWindows.tdt | Bin 0 -> 64906 bytes exam2prep/prm/burner.bbl | 157 ++++ 223 files changed, 9319 insertions(+), 4753 deletions(-) delete mode 100644 HW1/ASM_layout.hwl delete mode 100644 HW1/CMPEN472HW1McDonnell.mcp delete mode 100644 HW1/CMPEN472HW1McDonnell_Data/CWSettingsWindows.stg delete mode 100644 HW1/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.o delete mode 100644 HW1/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.sx delete mode 100644 HW1/CMPEN472HW1McDonnell_Data/Standard/TargetDataWindows.tdt delete mode 100644 HW1/Default.mem delete mode 100644 HW1/Full_Chip_Simulation.ini delete mode 100644 HW1/Sources/cmpen472hw1_McDonnell.asm delete mode 100644 HW1/Sources/derivative.inc delete mode 100644 HW1/Sources/main.asm delete mode 100644 HW1/bin/Project.abs delete mode 100644 HW1/bin/Project.abs.phy delete mode 100644 HW1/bin/Project.abs.s19 delete mode 100644 HW1/bin/main.dbg delete mode 100644 HW1/cmd/Full_Chip_Simulation_Postload.cmd delete mode 100644 HW1/cmd/Full_Chip_Simulation_Preload.cmd delete mode 100644 HW1/cmd/Full_Chip_Simulation_Reset.cmd delete mode 100644 HW1/cmd/Full_Chip_Simulation_SetCPU.cmd delete mode 100644 HW1/cmd/Full_Chip_Simulation_Startup.cmd delete mode 100644 HW1/prm/burner.bbl delete mode 100644 cmpen472_hw8McDonnell/ASM_layout.hwl delete mode 100644 cmpen472_hw8McDonnell/Default.mem delete mode 100644 cmpen472_hw8McDonnell/Full_Chip_Simulation.hwc delete mode 100644 cmpen472_hw8McDonnell/Full_Chip_Simulation.ini delete mode 100644 cmpen472_hw8McDonnell/Sources/cmpen472hw8_McDonnell.asm delete mode 100644 cmpen472_hw8McDonnell/Sources/derivative.inc delete mode 100644 cmpen472_hw8McDonnell/Sources/main.asm delete mode 100644 cmpen472_hw8McDonnell/bin/Project.abs delete mode 100644 cmpen472_hw8McDonnell/bin/Project.abs.phy delete mode 100644 cmpen472_hw8McDonnell/bin/Project.abs.s19 delete mode 100644 cmpen472_hw8McDonnell/bin/main.dbg delete mode 100644 cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Postload.cmd delete mode 100644 cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Preload.cmd delete mode 100644 cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Reset.cmd delete mode 100644 cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd delete mode 100644 cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Startup.cmd delete mode 100644 cmpen472_hw8McDonnell/cmpen472_hw8McDonnell.mcp delete mode 100644 cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg delete mode 100644 cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o delete mode 100644 cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx delete mode 100644 cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt delete mode 100644 cmpen472_hw8McDonnell/prm/burner.bbl create mode 100644 cmpen472hw1_McDonnell/ASM_layout.hwl create mode 100644 cmpen472hw1_McDonnell/CMPEN472HW1McDonnell.mcp create mode 100644 cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/CWSettingsWindows.stg create mode 100644 cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.o create mode 100644 cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.sx create mode 100644 cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/TargetDataWindows.tdt create mode 100644 cmpen472hw1_McDonnell/Default.mem create mode 100644 cmpen472hw1_McDonnell/Full_Chip_Simulation.ini create mode 100644 cmpen472hw1_McDonnell/Sources/cmpen472hw1_McDonnell.asm create mode 100644 cmpen472hw1_McDonnell/Sources/derivative.inc create mode 100644 cmpen472hw1_McDonnell/Sources/main.asm create mode 100644 cmpen472hw1_McDonnell/bin/Project.abs create mode 100644 cmpen472hw1_McDonnell/bin/Project.abs.phy create mode 100644 cmpen472hw1_McDonnell/bin/Project.abs.s19 create mode 100644 cmpen472hw1_McDonnell/bin/main.dbg create mode 100644 cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd create mode 100644 cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd create mode 100644 cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd create mode 100644 cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd create mode 100644 cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd create mode 100644 cmpen472hw1_McDonnell/prm/burner.bbl delete mode 100644 cmpen472hw2McDonnell/ASM_layout.hwl delete mode 100644 cmpen472hw2McDonnell/Default.mem delete mode 100644 cmpen472hw2McDonnell/Full_Chip_Simulation.hwc delete mode 100644 cmpen472hw2McDonnell/Full_Chip_Simulation.ini delete mode 100644 cmpen472hw2McDonnell/Sources/cmpen472hw2_McDonnell.asm delete mode 100644 cmpen472hw2McDonnell/Sources/derivative.inc delete mode 100644 cmpen472hw2McDonnell/Sources/main.asm delete mode 100644 cmpen472hw2McDonnell/bin/Project.abs delete mode 100644 cmpen472hw2McDonnell/bin/Project.abs.phy delete mode 100644 cmpen472hw2McDonnell/bin/Project.abs.s19 delete mode 100644 cmpen472hw2McDonnell/bin/main.dbg delete mode 100644 cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Postload.cmd delete mode 100644 cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Preload.cmd delete mode 100644 cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Reset.cmd delete mode 100644 cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd delete mode 100644 cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Startup.cmd delete mode 100644 cmpen472hw2McDonnell/cmpen472hw2McDonnell.mcp delete mode 100644 cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/CWSettingsWindows.stg delete mode 100644 cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.o delete mode 100644 cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.sx delete mode 100644 cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/TargetDataWindows.tdt delete mode 100644 cmpen472hw2McDonnell/debuggerlayout.hwl delete mode 100644 cmpen472hw2McDonnell/debuggerlayout.ini delete mode 100644 cmpen472hw2McDonnell/prm/burner.bbl create mode 100644 cmpen472hw2_McDonnell/ASM_layout.hwl create mode 100644 cmpen472hw2_McDonnell/Default.mem create mode 100644 cmpen472hw2_McDonnell/Full_Chip_Simulation.hwc create mode 100644 cmpen472hw2_McDonnell/Full_Chip_Simulation.ini create mode 100644 cmpen472hw2_McDonnell/Sources/cmpen472hw2_McDonnell.asm create mode 100644 cmpen472hw2_McDonnell/Sources/derivative.inc create mode 100644 cmpen472hw2_McDonnell/Sources/main.asm create mode 100644 cmpen472hw2_McDonnell/bin/Project.abs create mode 100644 cmpen472hw2_McDonnell/bin/Project.abs.phy create mode 100644 cmpen472hw2_McDonnell/bin/Project.abs.s19 create mode 100644 cmpen472hw2_McDonnell/bin/main.dbg create mode 100644 cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd create mode 100644 cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd create mode 100644 cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd create mode 100644 cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd create mode 100644 cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd create mode 100644 cmpen472hw2_McDonnell/cmpen472hw2McDonnell.mcp create mode 100644 cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/CWSettingsWindows.stg create mode 100644 cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.o create mode 100644 cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.sx create mode 100644 cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/TargetDataWindows.tdt create mode 100644 cmpen472hw2_McDonnell/debuggerlayout.hwl create mode 100644 cmpen472hw2_McDonnell/debuggerlayout.ini create mode 100644 cmpen472hw2_McDonnell/prm/burner.bbl delete mode 100644 cmpen472hw3McDonnell/ASM_layout.hwl delete mode 100644 cmpen472hw3McDonnell/Default.mem delete mode 100644 cmpen472hw3McDonnell/Full_Chip_Simulation.hwc delete mode 100644 cmpen472hw3McDonnell/Full_Chip_Simulation.hwl delete mode 100644 cmpen472hw3McDonnell/Full_Chip_Simulation.ini delete mode 100644 cmpen472hw3McDonnell/Sources/cmpen472hw3_McDonnell.asm delete mode 100644 cmpen472hw3McDonnell/Sources/derivative.inc delete mode 100644 cmpen472hw3McDonnell/Sources/main.asm delete mode 100644 cmpen472hw3McDonnell/bin/Project.abs delete mode 100644 cmpen472hw3McDonnell/bin/Project.abs.phy delete mode 100644 cmpen472hw3McDonnell/bin/Project.abs.s19 delete mode 100644 cmpen472hw3McDonnell/bin/main.dbg delete mode 100644 cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Postload.cmd delete mode 100644 cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Preload.cmd delete mode 100644 cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Reset.cmd delete mode 100644 cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd delete mode 100644 cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Startup.cmd delete mode 100644 cmpen472hw3McDonnell/cmpen472hw3McDonnell.mcp delete mode 100644 cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/CWSettingsWindows.stg delete mode 100644 cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o delete mode 100644 cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx delete mode 100644 cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt delete mode 100644 cmpen472hw3McDonnell/prm/burner.bbl create mode 100644 cmpen472hw3_McDonnell/ASM_layout.hwl create mode 100644 cmpen472hw3_McDonnell/Default.mem create mode 100644 cmpen472hw3_McDonnell/Full_Chip_Simulation.hwc create mode 100644 cmpen472hw3_McDonnell/Full_Chip_Simulation.hwl create mode 100644 cmpen472hw3_McDonnell/Full_Chip_Simulation.ini create mode 100644 cmpen472hw3_McDonnell/Sources/cmpen472hw3_McDonnell.asm create mode 100644 cmpen472hw3_McDonnell/Sources/derivative.inc create mode 100644 cmpen472hw3_McDonnell/Sources/main.asm create mode 100644 cmpen472hw3_McDonnell/bin/Project.abs create mode 100644 cmpen472hw3_McDonnell/bin/Project.abs.phy create mode 100644 cmpen472hw3_McDonnell/bin/Project.abs.s19 create mode 100644 cmpen472hw3_McDonnell/bin/main.dbg create mode 100644 cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd create mode 100644 cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd create mode 100644 cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd create mode 100644 cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd create mode 100644 cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd create mode 100644 cmpen472hw3_McDonnell/cmpen472hw3McDonnell.mcp create mode 100644 cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/CWSettingsWindows.stg create mode 100644 cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o create mode 100644 cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx create mode 100644 cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt create mode 100644 cmpen472hw3_McDonnell/prm/burner.bbl create mode 100644 cmpen472hw8_McDonnell/ASM_layout.hwl create mode 100644 cmpen472hw8_McDonnell/Default.mem create mode 100644 cmpen472hw8_McDonnell/Full_Chip_Simulation.hwc create mode 100644 cmpen472hw8_McDonnell/Full_Chip_Simulation.ini create mode 100644 cmpen472hw8_McDonnell/Sources/cmpen472hw8_McDonnell.asm create mode 100644 cmpen472hw8_McDonnell/Sources/derivative.inc create mode 100644 cmpen472hw8_McDonnell/Sources/main.asm create mode 100644 cmpen472hw8_McDonnell/bin/Project.abs create mode 100644 cmpen472hw8_McDonnell/bin/Project.abs.phy create mode 100644 cmpen472hw8_McDonnell/bin/Project.abs.s19 create mode 100644 cmpen472hw8_McDonnell/bin/main.dbg create mode 100644 cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd create mode 100644 cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd create mode 100644 cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd create mode 100644 cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd create mode 100644 cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd create mode 100644 cmpen472hw8_McDonnell/cmpen472_hw8McDonnell.mcp create mode 100644 cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg create mode 100644 cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o create mode 100644 cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx create mode 100644 cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt create mode 100644 cmpen472hw8_McDonnell/prm/burner.bbl create mode 100644 cmpen472hw9_McDonnell/ASM_layout.hwl create mode 100644 cmpen472hw9_McDonnell/Default.mem create mode 100644 cmpen472hw9_McDonnell/Full_Chip_Simulation.hwc create mode 100644 cmpen472hw9_McDonnell/Full_Chip_Simulation.ini create mode 100644 cmpen472hw9_McDonnell/Sources/derivative.inc create mode 100644 cmpen472hw9_McDonnell/Sources/main.asm create mode 100644 cmpen472hw9_McDonnell/bin/Project.abs create mode 100644 cmpen472hw9_McDonnell/bin/Project.abs.phy create mode 100644 cmpen472hw9_McDonnell/bin/Project.abs.s19 create mode 100644 cmpen472hw9_McDonnell/bin/main.dbg create mode 100644 cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd create mode 100644 cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd create mode 100644 cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd create mode 100644 cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd create mode 100644 cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd create mode 100644 cmpen472hw9_McDonnell/cmpen472hw9_McDonnell.mcp create mode 100644 cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/CWSettingsWindows.stg create mode 100644 cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/ObjectCode/main.asm.o create mode 100644 cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/ObjectCode/main.asm.sx create mode 100644 cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/TargetDataWindows.tdt create mode 100644 cmpen472hw9_McDonnell/prm/burner.bbl create mode 100644 exam2prep/ASM_layout.hwl create mode 100644 exam2prep/Default.mem create mode 100644 exam2prep/Full_Chip_Simulation.hwc create mode 100644 exam2prep/Full_Chip_Simulation.ini create mode 100644 exam2prep/Sources/cmpen472hw8_McDonnell.asm create mode 100644 exam2prep/Sources/derivative.inc create mode 100644 exam2prep/Sources/main.asm create mode 100644 exam2prep/bin/Project.abs create mode 100644 exam2prep/bin/Project.abs.phy create mode 100644 exam2prep/bin/Project.abs.s19 create mode 100644 exam2prep/bin/main.dbg create mode 100644 exam2prep/cmd/Full_Chip_Simulation_Postload.cmd create mode 100644 exam2prep/cmd/Full_Chip_Simulation_Preload.cmd create mode 100644 exam2prep/cmd/Full_Chip_Simulation_Reset.cmd create mode 100644 exam2prep/cmd/Full_Chip_Simulation_SetCPU.cmd create mode 100644 exam2prep/cmd/Full_Chip_Simulation_Startup.cmd create mode 100644 exam2prep/cmpen472_hw8McDonnell.mcp create mode 100644 exam2prep/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg create mode 100644 exam2prep/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o create mode 100644 exam2prep/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx create mode 100644 exam2prep/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt create mode 100644 exam2prep/prm/burner.bbl diff --git a/HW1/ASM_layout.hwl b/HW1/ASM_layout.hwl deleted file mode 100644 index 3600632..0000000 --- a/HW1/ASM_layout.hwl +++ /dev/null @@ -1,18 +0,0 @@ -OPEN source 0 0 60 42 -Source < attributes MARKS off -OPEN assembly 60 0 40 30 -Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,TOPPC 0xF800 -OPEN procedure 60 60 40 17 -Procedure < attributes VALUES on,TYPES off -OPEN register 60 30 40 30 -Register < attributes FORMAT AUTO,COMPLEMENT None -OPEN memory 60 77 40 23 -Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,ADDRESS 0x80 -OPEN data 0 42 60 28 -Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,UPDATERATE 10,NAMEWIDTH 16 -OPEN command 0 70 60 30 -Command < attributes CACHESIZE 1000 -bckcolor 50331647 -font 'Courier New' 9 BLACK -AUTOSIZE on -ACTIVATE Assembly Memory Register Command Data Source Procedure diff --git a/HW1/CMPEN472HW1McDonnell.mcp b/HW1/CMPEN472HW1McDonnell.mcp deleted file mode 100644 index 3426ce8..0000000 Binary files a/HW1/CMPEN472HW1McDonnell.mcp and /dev/null differ diff --git a/HW1/CMPEN472HW1McDonnell_Data/CWSettingsWindows.stg b/HW1/CMPEN472HW1McDonnell_Data/CWSettingsWindows.stg deleted file mode 100644 index af68d57..0000000 Binary files a/HW1/CMPEN472HW1McDonnell_Data/CWSettingsWindows.stg and /dev/null differ diff --git a/HW1/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.o b/HW1/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.o deleted file mode 100644 index f706514..0000000 Binary files a/HW1/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.o and /dev/null differ diff --git a/HW1/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.sx b/HW1/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.sx deleted file mode 100644 index 1771e8c..0000000 --- a/HW1/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.sx +++ /dev/null @@ -1,11 +0,0 @@ -S0750000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E3437324857314D63446F6E6E656C6C5C434D50454E3437324857314D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726DC9 -S12330000000000000000000000000000000000000000000000000000000000000000000AC -S123302000000000000000000000000000000000000000000000000000000000000000008C -S123304000000000000000000000000000000000000000000000000000000000000000006C -S123306000000000000000000000000000000000000000000000000000000000000000004C -S123308000000000000000000000000000000000000000000000000000000000000000002C -S12330A000000000000000000000000000000000000000000000000000000000000000000C -S12330C00000000000000000000000000000000000000000000000000000000000000000EC -S10530E000E109 -S1133100862AF630E1CE30006A00085326FA20FE03 -S9033100CB diff --git a/HW1/CMPEN472HW1McDonnell_Data/Standard/TargetDataWindows.tdt b/HW1/CMPEN472HW1McDonnell_Data/Standard/TargetDataWindows.tdt deleted file mode 100644 index a3ebd6d..0000000 Binary files a/HW1/CMPEN472HW1McDonnell_Data/Standard/TargetDataWindows.tdt and /dev/null differ diff --git a/HW1/Default.mem b/HW1/Default.mem deleted file mode 100644 index bf49148..0000000 Binary files a/HW1/Default.mem and /dev/null differ diff --git a/HW1/Full_Chip_Simulation.ini b/HW1/Full_Chip_Simulation.ini deleted file mode 100644 index b41d59e..0000000 --- a/HW1/Full_Chip_Simulation.ini +++ /dev/null @@ -1,27 +0,0 @@ -[Environment Variables] -GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib -LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include -OBJPATH={Project}bin -TEXTPATH={Project}bin -ABSPATH={Project}bin - -[HI-WAVE] -Target=sim -Layout=ASM_layout.hwl -LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD -CPU=HC12 -MainFrame=0,1,-1,-1,-1,-1,211,107,2131,1130 -TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 - - - -[Simulator] -CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" - -[Simulator HC12] -CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" -CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" -CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" -CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" -HCS12_SUPPORT=1 -FCS=MC9S12C32 diff --git a/HW1/Sources/cmpen472hw1_McDonnell.asm b/HW1/Sources/cmpen472hw1_McDonnell.asm deleted file mode 100644 index 31da964..0000000 --- a/HW1/Sources/cmpen472hw1_McDonnell.asm +++ /dev/null @@ -1,63 +0,0 @@ -********************************************************************************************** -* -* Title: Star Fill (In Memory) Homework #1 -* -* Objective: CMPEN472 Homework #1 demonstration program. Fill 225 bytes of memory with '*'. -* -* Revision: V1.0 -* -* Date: Jan. 22, 2025 -* -* Programmer: Jacob McDonnell -* -* Company: The Pennsylvania State Universtiy -* Electrical Engineering and Computer Science -* -* Algorithm: While Loop demo of HCS12 Assembly -* -* Register Use: A accumulator: character to be placed in memory -* B accumulator: counter of filled memory locations -* X register: pointer to memory location to fill -* -* Memory use: RAM locations $3000 to $30E1 -* -* Input: No input, data and parameters are hard coded. -* -* Output: Memory locations $3000 to $30E1 are filled with '*' character. -* -* Observation: This program is designed for instruction purpose. -* This program can be a template for other loop based code. -* -* Comments: This program is developed and simulated using CodeWarrior Development Software. -* -********************************************************************************************** -* Parameter Declaration Section -* -* Export Symbols - xdef pgstart ; export 'pgstart' symbol - absentry pgstart ; for assembly entry point -* Symbols and Macros -porta equ $0000 ; i/o port address -portb equ $0001 -ddra equ $0002 -ddrb equ $0003 -********************************************************************************************** -* Data Section -* - org $3000 ; reserved memory starting address -here ds.b $e1 ; 225 memory locations reserved -count dc.b $e1 ; constant counter for stars = 225 -* -********************************************************************************************** -* Program Section -* - org $3100 ; Program Start Address in RAM -pgstart ldaa #'*' ; Load '*' into accumulator A - ldab count ; Load count of stars into B - ldx #here ; Load address pointer into X -loop staa 0,x ; Put a start at this memory location - inx ; Go to the next memory location - decb ; Decrement the counter - bne loop ; Loop if not done -done bra done ; Task finished - end ; Last line of a file \ No newline at end of file diff --git a/HW1/Sources/derivative.inc b/HW1/Sources/derivative.inc deleted file mode 100644 index 9320da5..0000000 --- a/HW1/Sources/derivative.inc +++ /dev/null @@ -1,10 +0,0 @@ - - ; Note: This file is recreated by the project wizard whenever the MCU is - ; changed and should not be edited by hand - ; - - ; include derivative specific macros - INCLUDE 'mc9s12c32.inc' - - - diff --git a/HW1/Sources/main.asm b/HW1/Sources/main.asm deleted file mode 100644 index 31da964..0000000 --- a/HW1/Sources/main.asm +++ /dev/null @@ -1,63 +0,0 @@ -********************************************************************************************** -* -* Title: Star Fill (In Memory) Homework #1 -* -* Objective: CMPEN472 Homework #1 demonstration program. Fill 225 bytes of memory with '*'. -* -* Revision: V1.0 -* -* Date: Jan. 22, 2025 -* -* Programmer: Jacob McDonnell -* -* Company: The Pennsylvania State Universtiy -* Electrical Engineering and Computer Science -* -* Algorithm: While Loop demo of HCS12 Assembly -* -* Register Use: A accumulator: character to be placed in memory -* B accumulator: counter of filled memory locations -* X register: pointer to memory location to fill -* -* Memory use: RAM locations $3000 to $30E1 -* -* Input: No input, data and parameters are hard coded. -* -* Output: Memory locations $3000 to $30E1 are filled with '*' character. -* -* Observation: This program is designed for instruction purpose. -* This program can be a template for other loop based code. -* -* Comments: This program is developed and simulated using CodeWarrior Development Software. -* -********************************************************************************************** -* Parameter Declaration Section -* -* Export Symbols - xdef pgstart ; export 'pgstart' symbol - absentry pgstart ; for assembly entry point -* Symbols and Macros -porta equ $0000 ; i/o port address -portb equ $0001 -ddra equ $0002 -ddrb equ $0003 -********************************************************************************************** -* Data Section -* - org $3000 ; reserved memory starting address -here ds.b $e1 ; 225 memory locations reserved -count dc.b $e1 ; constant counter for stars = 225 -* -********************************************************************************************** -* Program Section -* - org $3100 ; Program Start Address in RAM -pgstart ldaa #'*' ; Load '*' into accumulator A - ldab count ; Load count of stars into B - ldx #here ; Load address pointer into X -loop staa 0,x ; Put a start at this memory location - inx ; Go to the next memory location - decb ; Decrement the counter - bne loop ; Loop if not done -done bra done ; Task finished - end ; Last line of a file \ No newline at end of file diff --git a/HW1/bin/Project.abs b/HW1/bin/Project.abs deleted file mode 100644 index f706514..0000000 Binary files a/HW1/bin/Project.abs and /dev/null differ diff --git a/HW1/bin/Project.abs.phy b/HW1/bin/Project.abs.phy deleted file mode 100644 index f804bef..0000000 --- a/HW1/bin/Project.abs.phy +++ /dev/null @@ -1,2 +0,0 @@ -S04A0000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E3437324857314D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627301 -S9030000FC diff --git a/HW1/bin/Project.abs.s19 b/HW1/bin/Project.abs.s19 deleted file mode 100644 index 329468c..0000000 --- a/HW1/bin/Project.abs.s19 +++ /dev/null @@ -1,11 +0,0 @@ -S04A0000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E3437324857314D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627301 -S12330000000000000000000000000000000000000000000000000000000000000000000AC -S123302000000000000000000000000000000000000000000000000000000000000000008C -S123304000000000000000000000000000000000000000000000000000000000000000006C -S123306000000000000000000000000000000000000000000000000000000000000000004C -S123308000000000000000000000000000000000000000000000000000000000000000002C -S12330A000000000000000000000000000000000000000000000000000000000000000000C -S12330C00000000000000000000000000000000000000000000000000000000000000000EC -S10530E000E109 -S1133100862AF630E1CE30006A00085326FA20FE03 -S9030000FC diff --git a/HW1/bin/main.dbg b/HW1/bin/main.dbg deleted file mode 100644 index 5e71d01..0000000 --- a/HW1/bin/main.dbg +++ /dev/null @@ -1,62 +0,0 @@ -********************************************************************************************** -* -* Title: Star Fill (In Memory) Homework #1 -* -* Objective: CMPEN472 Homework #1 demonstration program. Fill 225 bytes of memory with '*'. -* -* Revision: V1.0 -* -* Date: Jan. 22, 2025 -* -* Programmer: Jacob McDonnell -* -* Company: The Pennsylvania State Universtiy -* Electrical Engineering and Computer Science -* -* Algorithm: While Loop demo of HCS12 Assembly -* -* Register Use: A accumulator: character to be placed in memory -* B accumulator: counter of filled memory locations -* X register: pointer to memory location to fill -* -* Memory use: RAM locations $3000 to $30E1 -* -* Input: No input, data and parameters are hard coded. -* -* Output: Memory locations $3000 to $30E1 are filled with '*' character. -* -* Observation: This program is designed for instruction purpose. -* This program can be a template for other loop based code. -* -* Comments: This program is developed and simulated using CodeWarrior Development Software. -* -********************************************************************************************** -* Parameter Declaration Section -* -* Export Symbols - xdef pgstart ; export 'pgstart' symbol - absentry pgstart ; for assembly entry point -* Symbols and Macros -porta equ $0000 ; i/o port address -portb equ $0001 -ddra equ $0002 -ddrb equ $0003 -********************************************************************************************** -* Data Section -* - org $3000 ; reserved memory starting address -here ds.b $e1 ; 225 memory locations reserved -count dc.b $e1 ; constant counter for stars = 225 -* -********************************************************************************************** -* Program Section -* - org $3100 ; Program Start Address in RAM -pgstart ldaa #'*' ; Load '*' into accumulator A - ldab count ; Load count of stars into B - ldx #here ; Load address pointer into X -loop staa 0,x ; Put a start at this memory location - inx ; Go to the next memory location - decb ; Decrement the counter - bne loop ; Loop if not done -done bra done ; Task finished diff --git a/HW1/cmd/Full_Chip_Simulation_Postload.cmd b/HW1/cmd/Full_Chip_Simulation_Postload.cmd deleted file mode 100644 index eb00f37..0000000 --- a/HW1/cmd/Full_Chip_Simulation_Postload.cmd +++ /dev/null @@ -1 +0,0 @@ -// After load the commands written below will be executed diff --git a/HW1/cmd/Full_Chip_Simulation_Preload.cmd b/HW1/cmd/Full_Chip_Simulation_Preload.cmd deleted file mode 100644 index 691c5ee..0000000 --- a/HW1/cmd/Full_Chip_Simulation_Preload.cmd +++ /dev/null @@ -1 +0,0 @@ -// Before load the commands written below will be executed diff --git a/HW1/cmd/Full_Chip_Simulation_Reset.cmd b/HW1/cmd/Full_Chip_Simulation_Reset.cmd deleted file mode 100644 index f0fc874..0000000 --- a/HW1/cmd/Full_Chip_Simulation_Reset.cmd +++ /dev/null @@ -1 +0,0 @@ -// After reset the commands written below will be executed diff --git a/HW1/cmd/Full_Chip_Simulation_SetCPU.cmd b/HW1/cmd/Full_Chip_Simulation_SetCPU.cmd deleted file mode 100644 index 5f2b5a5..0000000 --- a/HW1/cmd/Full_Chip_Simulation_SetCPU.cmd +++ /dev/null @@ -1 +0,0 @@ -// At startup the commands written below will be executed diff --git a/HW1/cmd/Full_Chip_Simulation_Startup.cmd b/HW1/cmd/Full_Chip_Simulation_Startup.cmd deleted file mode 100644 index 5f2b5a5..0000000 --- a/HW1/cmd/Full_Chip_Simulation_Startup.cmd +++ /dev/null @@ -1 +0,0 @@ -// At startup the commands written below will be executed diff --git a/HW1/prm/burner.bbl b/HW1/prm/burner.bbl deleted file mode 100644 index 42c21ed..0000000 --- a/HW1/prm/burner.bbl +++ /dev/null @@ -1,157 +0,0 @@ -/* logical s-record file */ -OPENFILE "%ABS_FILE%.s19" -format=motorola -busWidth=1 -origin=0 -len=0x1000000 -destination=0 -SRECORD=Sx -SENDBYTE 1 "%ABS_FILE%" -CLOSE - - -/* physical s-record file */ -OPENFILE "%ABS_FILE%.phy" -format = motorola -busWidth = 1 -len = 0x4000 - -/* logical non banked flash at $4000 and $C000 to physical */ -origin = 0x004000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" - -origin = 0x00C000 -destination = 0x0FC000 -SENDBYTE 1 "%ABS_FILE%" - -/* physical FTS512K flash window to physical -origin = 0x008000 -destination = 0x080000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS256K parts flash window to physical -origin = 0x008000 -destination = 0x0C0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS128K parts flash window to physical -origin = 0x008000 -destination = 0x0E0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS64K parts flash window to physical -origin = 0x008000 -destination = 0x0F0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS32K parts flash window to physical -origin = 0x008000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* logical 512 kB banked flash to physical */ -origin = 0x208000 -destination = 0x080000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x218000 -destination = 0x084000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x228000 -destination = 0x088000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x238000 -destination = 0x08C000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x248000 -destination = 0x090000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x258000 -destination = 0x094000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x268000 -destination = 0x098000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x278000 -destination = 0x09C000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x288000 -destination = 0x0A0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x298000 -destination = 0x0A4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2A8000 -destination = 0x0A8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2B8000 -destination = 0x0AC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2C8000 -destination = 0x0B0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2D8000 -destination = 0x0B4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2E8000 -destination = 0x0B8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2F8000 -destination = 0x0BC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x308000 -destination = 0x0C0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x318000 -destination = 0x0C4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x328000 -destination = 0x0C8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x338000 -destination = 0x0CC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x348000 -destination = 0x0D0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x358000 -destination = 0x0D4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x368000 -destination = 0x0D8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x378000 -destination = 0x0DC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x388000 -destination = 0x0E0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x398000 -destination = 0x0E4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3A8000 -destination = 0x0E8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3B8000 -destination = 0x0EC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3C8000 -destination = 0x0F0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3D8000 -destination = 0x0F4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3E8000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3F8000 -destination = 0x0FC000 -SENDBYTE 1 "%ABS_FILE%" - -CLOSE - diff --git a/cmpen472_hw8McDonnell/ASM_layout.hwl b/cmpen472_hw8McDonnell/ASM_layout.hwl deleted file mode 100644 index 22795c3..0000000 --- a/cmpen472_hw8McDonnell/ASM_layout.hwl +++ /dev/null @@ -1,27 +0,0 @@ -OPEN source 0 0 60 42 -Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off -OPEN assembly 60 0 40 30 -Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0x3100 -OPEN procedure 60 60 40 17 -Procedure < attributes VALUES on,TYPES off -OPEN register 60 30 40 30 -Register < attributes FORMAT AUTO,COMPLEMENT None -OPEN memory 60 77 40 23 -Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 -OPEN data 0 42 60 28 -Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 -OPEN command 0 70 60 30 -Command < attributes CACHESIZE 1000 -OPEN Terminal 10 20 40 69 -Terminal < attributes CACHESIZE 1000 -Terminal < attributes SCI_DEFAULT_TEXT "Virtual SCI",SCI_CONNECTION 0,1,SCI_CONNECTION 1,0,SCI_CONNECTION 1,3,SCI_CONNECTION 3,1,SCI_PORT COM1,SCI_BAUD 9600,SCI_SHOW_PROTOCOL OFF,SCI_VIRTUAL_IN "Sci:2.SerialOutput",SCI_VIRTUAL_OUT "Sci:2.SerialInput",SCI_FILENAME_IN "",SCI_FILENAME_OUT "" -OPEN Visualizationtool 76 37 11 29 -VisualizationTool< Attributes [stEditM="0",swRefresh="3",refCycles="1"] -VisualizationTool< LoadInstrument Seg7[BoundX="26",BoundY="12",Port="0x1",swDM="2"] -VisualizationTool< LoadInstrument Seg7[BoundX="67",BoundY="14",Port="0x1",swDM="1"] -VisualizationTool< LoadInstrument DILSwitch[BoundX="25",BoundY="106",Port="0x1"] -VisualizationTool< ResetVT Undo -bckcolor 50331647 -font 'Courier New' 9 BLACK -AUTOSIZE on -ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Source" "Procedure" "Terminal" "VisualizationTool" diff --git a/cmpen472_hw8McDonnell/Default.mem b/cmpen472_hw8McDonnell/Default.mem deleted file mode 100644 index bf49148..0000000 Binary files a/cmpen472_hw8McDonnell/Default.mem and /dev/null differ diff --git a/cmpen472_hw8McDonnell/Full_Chip_Simulation.hwc b/cmpen472_hw8McDonnell/Full_Chip_Simulation.hwc deleted file mode 100644 index f3ce7c9..0000000 --- a/cmpen472_hw8McDonnell/Full_Chip_Simulation.hwc +++ /dev/null @@ -1 +0,0 @@ -LOADMEM default.mem diff --git a/cmpen472_hw8McDonnell/Full_Chip_Simulation.ini b/cmpen472_hw8McDonnell/Full_Chip_Simulation.ini deleted file mode 100644 index b56906d..0000000 --- a/cmpen472_hw8McDonnell/Full_Chip_Simulation.ini +++ /dev/null @@ -1,42 +0,0 @@ -[Environment Variables] -GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib -LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include -OBJPATH={Project}bin -TEXTPATH={Project}bin -ABSPATH={Project}bin - -[HI-WAVE] -Target=sim -Layout=ASM_layout.hwl -LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD -CPU=HC12 -MainFrame=0,1,-1,-1,-1,-1,854,150,1955,1166 -Configuration=Full_Chip_Simulation.hwc -Statusbar=1 -ShowToolbar=1 -Smallborder=0 -Hideheadline=0 -Hidetitle=0 -TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 - - - - - - - - - -[Simulator] -CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" - -[Simulator HC12] -CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" -CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" -CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" -CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" -HCS12_SUPPORT=1 -FCS=MC9S12C32 -ZEROTIMEATRESET=1 -OSCFREQUENCY=48000000 -DISPLAYTIME=0 diff --git a/cmpen472_hw8McDonnell/Sources/cmpen472hw8_McDonnell.asm b/cmpen472_hw8McDonnell/Sources/cmpen472hw8_McDonnell.asm deleted file mode 100644 index cbfe22a..0000000 --- a/cmpen472_hw8McDonnell/Sources/cmpen472hw8_McDonnell.asm +++ /dev/null @@ -1,764 +0,0 @@ -************************************************************************** -* -* Title: Calculator -* -* Objective: CMPEN 472 Homework 8 -* -* Revision: V1.0 -* -* Date: Mar. 24, 2025 -* -* Programmer: Jacob McDonnell -* -* Company: The Pennsylvania State University -* Department of Computer Science and Engineering -* -* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking -* -* Register Use: A & B to current byte, etc, -* X & Y holds address of strings and length of string, -* D to hold data for printing, reading, and updating time. -* -* Memory Use: RAM Locations from $3000 for data, -* RAM Locations from $3100 for program -* -* Input: Serial Port for User Input -* -* Output: Serial Port for String Output -* -* Observation: The HC12 will output the time and a command prompt every second. -* The user can input commands and the program will output a response -* based on the input. -* -* Note: ON CSM-12C128 board, -* -* 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 - -* Symbols and Macros -PORTA equ $0000 ; i/o port A addresses -DDRA equ $0002 ; data direction register for PORTA -PORTB equ $0001 ; i/o port B addresses -DDRB equ $0003 ; data direction register for PORTB - -SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H -SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L -SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 -SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 -SCIDRL equ $00CF ; Serial port (SCI) Data Register - -CRGFLG EQU $0037 ; Clock and Reset Generator Flags -CRGINT EQU $0038 ; Clock and Reset Generator Interrupts -RTICTL EQU $003B ; Real Time Interrupt Control - -CR equ $0d ; carriage return, ASCII 'Return' key -LF equ $0a ; line feed, ASCII 'next line' character -NULL equ $00 ; NULL Terminator character - -************************************************************************** -* Data Section: address used [ $3000 to $30FF ] RAM Memory -* - org $3000 ; Reserved RAM memory starting address - ; for Data for CMPEN 472 class -buffer ds.b $0010 ; Array of 16 bytes to read a string - dc.b NULL ; NULL terminated -lenBuf dc.w $0010 ; Length of buffer array - -buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal - dc.b NULL ; NULL terminated -lenBuf2 dc.w $0010 ; length of buffer2 - -hours dc.w $0000 ; Buffer to hold the hours of the time - -minutes dc.w $0000 ; Buffer to hold the minutes of the time - -seconds dc.w $0000 ; Buffer to hold the seconds of the time - -counter dc.w $0000 ; Counter for RTI ISR for 1 second - -numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers - -operator dc.b $0000 ; Used by ReadDecimal for reading numbers - -inputBuffer ds.b $0010 ; Input Buffer Length - -lenInput dc.w $0010 ; Length of the Input Buffer - -outputBuf dc.b 'h' ; Used to control what to output on 7 segment display - -* -* There is a section Data Section at the end of the file -************************************************************************** -* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory -* - org $FFF0 ; Memory location for RTI interrupt vector section for simulator - dc.w rtiisr ; Real Time Interrupt vector -* -************************************************************************** -* Program Section: address used [ $3100 to $3FFF ] RAM Memory -* - org $3100 ; Program start address, in RAM -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 #$0C ; Enable SCI port Tx and Rx units - staa SCICR2 ; disable SCI interrupts - - ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) - std SCIBDH ; SCI port baud rate change - - ldx #msg ; Load the address of the welcome message into X - jsr WriteString ; Write the string to the serial console - - bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board - ; 4MHz quartz oscillator clock - 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 - cli ; Enable interrupts - jsr PrintTime ; Jump to PrintTime to write to serial console -mainLoop - 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 - - ldx #inputBuffer ; Load the address of inputBuffer into X - jsr ExecuteCommand ; Jump to ExecuteCommand - - ldx #inputBuffer ; Load the address of inputBuffer into X - ldy lenInput ; Load the length of inputBuffer into Y - jsr Zeros ; Zero out inputBuffer - - sei ; Disable interrupts - jsr PrintTime ; Jump to PrintTime to print new time - cli ; Enable interrupts - - bra mainLoop ; Loop back to mainLoop always - -TypeWrite - sei ; Disable Interrupts - bclr CRGINT,%10000000; Disable RTI interrupt - ldx #twMsg ; Load the address of twMsg into X - jsr WriteString ; Write the string to the serial console -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 - -************************************************************************** -* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory -* - -;************************************************************************* -; rtiisr subroutine -; -; This subroutine will increment the counter, seconds, minutes, & hours counters -; to track the time. This subroutine will be called ~400 times a second. -; -; Input: No input other than the timer to call the isr. -; Output: The counter, seconds, minutes, & hours buffers will -; be updated to track the time, the time & prompt will be -; printed every second. -; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. -; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, -; Buffer words for counters, seconds, minutes, & hours buffers. -; -; Comments: The counter buffer should be compared to 400, but for the simulator, -; the counter is compared to 200 to better simulate 1 second on my computer. -; - -rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag - ldx counter ; Load counter into X - inx ; Increment counter by 1 - stx counter ; Save X to counter - 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 - inx ; Increment the seconds by 1 - stx seconds ; Save the new seconds to the location - cpx #60 ; Compare X to 60 - bne rtidone ; If X != 60, exit isr - ldx #0 ; Reset the seconds - stx seconds ; Save the new seconds to the location - ldx minutes ; load the minutes into X - inx ; Increment the minutes by 1 - stx minutes ; Save the updated minutes - cpx #60 ; Compare the minutes to 60 - bne rtidone ; If X != 60, exit isr - ldx #0 ; Reset the minutes - stx minutes ; Save the updated minutes - ldx hours ; Load the hours into X - inx ; Increment the hours by 1 - stx hours ; Save the updated hours - cpx #24 ; Compare the hours to 24 - bne rtidone ; If X != 24, exit the isr - ldx #0 ; Reset the hours - stx hours ; Save the updated hours -rtidone jsr PrintTime ; Jump to PrintTime -rtiSkip RTI ; Return from RTI ISR - -;************************************************************************* -; PrintTime subroutine -; -; This subroutine will print the time, command prompt, and maybe an error prompt. -; -; Input: No input. -; Output: The time prompt, time, command prompt, the current input, -; and/or an error on the serial console. -; Registers in use: A for the characters to print, X for buffer addresses, -; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB -; Memory locations in use: Memory Address for serial line, Buffer words for counters, -; seconds, minutes, & hours buffers, and buffer to print time, -; outputBuf for tracking what to output on PORTB. -; -; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine -; will print the current user input if its not finished. -; - -PrintTime - pshd ; Save D to the stack - pshy ; Save Y to the stack - pshx ; Save X to the stack - ldaa #CR ; Load the character CR into A - jsr putchar ; Write the character to the serial - ldaa #LF ; Load the character LF into A - jsr putchar ; Write the character to the serial - ldx #clock ; Load the address of the clock prompt into X - jsr WriteString ; Write the string to serial - ldd hours ; Load the hours into D - cpd #10 ; Compare D to 10 - bhs goodHours ; If D >= goodHours - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodHours ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #':' ; Load the character ':' into A - jsr putchar ; Write the character to the serial - ldd minutes ; Load the minutes into D - cpd #10 ; Compare D to 10 - bhs goodMins ; If D >= goodMins - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodMins ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #':' ; Load the character ':' into A - jsr putchar ; Write the character to the serial - ldd seconds ; Load the seconds into D - cpd #10 ; Compare D to 10 - bhs goodSecs ; If D >= goodSecs - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodSecs ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #' ' ; Load ' ' character into A - jsr putchar ; Write the character to the serial console - jsr putchar ; Write the character to the serial console - jsr putchar ; Write the character to the serial console - jsr putchar ; Write the character to the serial console - 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 - 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 subroutine -; -; This subroutine will output the time given on on PORTB for two seven segment displays. -; -; Input: Two Digit Decimal number in register D. -; Output: The given two digit decimal number on PORTB for two 7 segment displays. -; Registers in use: D for the input, and for math to split the digits, X for math to split digits. -; Memory locations in use: PORTB memory location. -; -; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal -; numbers (leading zeros will be added). -; - -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 subroutine -; -; This subroutine will parse user input and execute the proper command or error out. -; -; Input: An address of a NULL terminated string in X. -; Output: The output of the proper command or an error message. -; Registers in use: X for the address of the user input, A for individual characters, -; D & Y for numbers read from user input. -; Memory locations in use: Serial console memory locations. -; -; Comments: This subroutine will disable interrupts while setting the time and will -; reenable them after setting the time. -; - -ExecuteCommand - pshd ; Save D to the stack - pshy ; Save Y to the stack - ldaa 1,x+ ; Load the character from X into A - lbeq ecDone ; If A == 0, jump to ecDone - cmpa #'t' ; Compare A to 't' - bne isH ; If A != 't', branch to isH -skipSpaces ldaa 1,+x ; Load the next character into X - cmpa #' ' ; Compare A to ' ' character - beq skipSpaces ; If A == ' ', loop to skipSpaces - sei ; Disable interrupts - ldd hours ; Load hours into D - pshd ; Save hours to the stack - jsr ReadDecimal ; Read Hour number - exg y,d ; Exchange Y and D - cpd #24 ; Compare D to 24 - lbhs badHours ; If D >= 24, badHours - cpd #0 ; Compare D to 0 - lblt badHours ; If D < 0, badHours - std hours ; Save D to hours - ldaa -1,x ; Load the next character into A - cmpa #':' ; Compare A to ':' - lbne badHours ; If A != ':', badHours - ldd minutes ; Load minutes into D - pshd ; Save minutes to the stack - jsr ReadDecimal ; Read minute number - exg y,d ; Exchange Y and D - cpd #60 ; Compare D to 60 - bhs badMinutes ; If D >= 60, badMinutes - cpd #0 ; Compare D to 0 - blt 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 - 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 - cpd #0 ; Compare D to 0 - blt 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 - 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 -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 - staa outputBuf ; Store A into outputBuf - bra 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 - staa outputBuf ; Store A into outputBuf - bra 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 - staa outputBuf ; Store A into outputBuf - bra ecDone ; Branch to ecDone -isQ cmpa #'q' ; Compare A to 'q' - bne badCommand ; If A != 'q', branch to badCommand - ldab 1,x+ ; Load next character into B - cmpb #NULL ; Compare B to NULL - bne badCommand ; If B != NULL, branch to ecDone - jmp TypeWrite ; Jump to TypeWrite -badSeconds puld ; Restore Seconds from the stack - std seconds ; Restore seconds before change -badMinutes puld ; Restore minutes from the stack - std minutes ; Restore minutes before change -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 -ecDone puly ; Restore Y from the stack - puld ; Restore D 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 -; its value. -; -; Input: A memory address in register X. -; Output: The value of the number in the Y register, and any errors printed -; to the serial line. Zero bit is set if error occurs. -; Registers in use: X for the address of the contents and for a buffer while printing, -; D for multiplication, B for the character, Y for output value. -; Memory locations in use: Memory Address for serial line, address of the string -; -; Comments: This subroutine will return the value in the Y register, and if an error occurs, -; the Zero bit in the CCR will be set. -; - -ReadDecimal - pshd ; Save D to the stack - ldy #0 ; Clear Y register -dHLoop ldab 1,x+ ; Read Next character from X - beq dHDone ; If B == 0, exit loop - cmpb #'+' ; Compare B to '+' - beq dHDone ; If B == '+', end of number - cmpb #'-' ; Compare B to '-' - beq dHDone ; If B == '-', end of number - cmpb #'*' ; Compare B to '*' - beq dHDone ; If B == '+', end of number - cmpb #'/' ; Compare B to '/' - beq dHDone ; If B == '-', end of number - cmpb #':' ; Compare B to ':' - beq dHDone ; If B == '-', end of number - cmpb #' ' ; Compare B to space character - beq dHDone ; If B == ' ', exit loop - cmpb #'0' ; Compare B to '0' character - blt dHError ; If B < '0', bad address, exit loop - cmpb #'9' ; Compare B to '9' character - bhi dHError ; If B > '9', check if 'A'-'F' characters - subb #'0' ; Subtract '0' from B to get true value - pshb ; Save B to the stack - ldd #10 ; load 10 into D - emul ; Multiply Y and D - exg d,y ; Transfer data from D to Y - pulb ; Restore b from the stack - aby ; Add B to Y - bra dHLoop ; Branch always to rHLoop -dHDone clra ; clear A accumulator - tap ; Transfer A into CCR to clear zero bit - puld ; Restore D from the stack - rts ; Return to caller -dHError ldaa #4 ; Load 4 into A to set zero bit in CCR - tap ; Transfer A into CCR to set zero bit and warn error - puld ; Restore D from the stack - rts ; Return to caller - -;************************************************************************* -; strrev subroutine -; -; This subroutine will reverse a string from one buffer into another. -; -; Input: Address of null terminated string in X, address of a large enough -; buffer in Y. -; Output: The string in X reversed in Y. -; Registers in use: X for the address of the string, Y for the address of the buffer, -; A to read characters from the string. -; Memory locations in use: Memory Address for serial line, address of the string & buffer -; -; Comments: This subroutine will not check that the output buffer is large enough, that -; is the job of the caller. -; - -strrev - pshx ; Save X to the stack - pshy ; Save Y to the stack - psha ; Save A to the stack -revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y - beq revDone ; If Character is 0, exit loop - staa 1,x+ ; Save character in address in X, increment X - bra revLoop ; Loop back always - clra ; Set A to Zero -revDone staa 1,x+ ; Copy Null terminator into new string - pula ; Restore A from the stack - puly ; Restore Y from the stack - pulx ; Restore X from the stack - rts ; Return to caller - -;************************************************************************* -; PrintDecimalWord subroutine -; -; This subroutine will print a given word of data to the serial in binary. -; -; Input: 1 word of data in register D, Buffer Address in Y -; Output: Decimal representation of the data on the serial console -; Registers in use: Y for the address of the buffer, X to count the number of bits -; written and for division, D for the input, A for characters. -; Memory locations in use: Memory addresses for serial, and operator to hold sign -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -PrintDecimalWord - pshx ; Save X to the stack - pshy ; Save Y to the stack - pshd ; Save D (A:B) to the stack - cpd #0 ; Compare D to zero - beq dIsZero ; Branch to hIsZero - blt dIsNegative ; If D < 0, Jump to dIsNegative -dAfterNeg psha ; Save A to the stack - pshy ; Save Y to the stack - pshx ; Save x to the stack - ldaa #'0' ; Load the '0' character into A - ldx #buffer2 ; Load the address of buffer2 into X - ldy #5 ; Load 5 into Y - jsr memset ; Write '0' to the first 5 bytes in buffer2 - pulx ; Restore X from the stack - puly ; Restore Y from the stack - clra ; Set A to zero - staa 0,y ; Load Zero into Y for Null Terminator - pula ; Restore A from the stack -dPrintLoop ldx #10 ; Load 10 in X for division - idiv ; Divide D / 10 to get Hex Digit - cpx #0 ; Compare X to 0 - beq dCheck ; If X == 0, branch to check D is zero -dDNotZero addb #'0' ; Add '0' to B to get ASCII Character - stab 1,+y ; Save character from B to Y - exg X,D ; Swap values in X and D - bra dPrintLoop ; Loop to hPrintLoop -dCheck cpd #0 ; Compare D to 0 - bne dDNotZero ; If D != 0, branch back to hDNotZero -dPrintDone ldaa operator ; Load operator into A to see if negative - cmpa #'-' ; Compare A to '-' - bne dNotNeg ; If A != '-', jump to dNotNeg - staa 1,+y ; Save '-' into buffer -dNotNeg ldx #buffer2 ; Load the address of buffer2 in X - jsr strrev ; Reverse string in Y in buffer in X - jsr WriteString ; Jump to write string to write the number - ldy lenBuf2 ; Load the length of buffer2 into Y - ldx #buffer2 ; Load the address of buffer2 into X - jsr Zeros ; Fill buffer2 with zeros - puld ; Restore D (A:B) from the stack - puly ; Restore Y from the stack - pulx ; Restore X from the stack - rts ; Return to caller -dIsZero ldaa #'0' ; Load '0' character into A - jsr putchar ; Print character to the screen - puld ; Restore D (A:B) from the stack - puly ; Restore Y from the stack - pulx ; Restore X from the stack - rts ; Return to caller -dIsNegative psha ; Save A to the stack - ldaa #'-' ; Load '-' into A - staa operator ; Save '-' to operator buffer - pula ; Restore A from the stack - nega ; Two's complement of A - suba #1 ; Subtract 1 from A - negb ; Two'complement of B - subb #1 ; Subtract 1 from B - addd #1 ; Add 1 to D - bra dAfterNeg ; Jump back to dAfterNeg - -;************************************************************************* -; Zeros subroutine -; -; This subroutine will write zeros to every byte in a given array. -; -; Input: Address of an array in X and its length in Y -; Output: Zeros in every byte of an array. -; Registers in use: X for the address of the array, Y for the length, and A for 0 -; Memory locations in use: Memory Address of the array -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -Zeros - psha ; Save A to the Stack - clra ; Clear A -zerosLoop staa 1,x+ ; Load A into byte at X - dbne y,zerosLoop ; Decrement Y and loop if Y != 0 - pula ; Restore A from the stack - rts ; Return to caller - -;************************************************************************* -; memset subroutine -; -; This subroutine will write a given byte to every byte in a given array. -; -; Input: Address of an array in X and its length in Y, the byte in A -; Output: The given byte in every byte of an array. -; Registers in use: X for the address of the array, Y for the length, and A for the given byte -; Memory locations in use: Memory Address of the array -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -memset - staa 1,x+ ; Load A into byte at X - dbne y,memset ; Decrement Y and loop if Y != 0 - rts ; Return to caller - -;************************************************************************* -; WriteString subroutine -; -; This subroutine will write a given null terminated string to the serial. -; -; Input: Address of null terminated string in X -; Output: Null terminated string written to serial -; Registers in use: X for the address of the string and A for the current byte -; Memory locations in use: Memory Address for serial line, address of the string -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -WriteString - psha ; Save A to the stack -writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 - beq doneWrite ; if A == 0, branch to doneWrite - jsr putchar ; Jump to putchar to write byte to serial - bra writeLoop ; branch always to writeLoop -doneWrite pula ; restore A from the stack - rts ; return to caller - -;************************************************************************* -; ReadString subroutine -; -; This subroutine will read a string from the serial line to a given address. -; -; Input: Address of an array in X -; Output: Null terminated string in the given array -; Registers in use: X for the address of the string Y for the length of the string, -; and A for the current byte -; Memory locations in use: Memory Address for serial line, address of the string -; -; Comments: This subroutine requires serial to be setup and getchar subroutine. -; - -ReadString - psha ; Save accumulator A to the stack - pshy ; Save Y to the stack - pshx ; Save X to the stack -readLoop jsr getchar ; Jump to putchar to write byte to serial - beq readLoop ; While A == 0, loop - cmpa #CR ; If A == CR, exit loop - beq doneRead ; Branch to doneRead if A == CR - staa 1,x+ ; Save the byte to the addr in X, then add 1 - jsr putchar ; Write Character back to the terminal - 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 - pulY ; Restore Y from the stack - pula ; restore A from the stack - rts ; return to caller - -;************************************************************************* -; putchar subroutine -; -; This subroutine writes a single byte to a serial line -; -; Input: A single ASCII byte in accumulator A -; Output: Sends one character to SCI port -; Registers in use: Accumulator A with input byte -; Memory locations in use: SCISR1 and SCIDRL status and data registers -; - -putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty - staa SCIDRL ; send a character - rts ; Return to caller - -;************************************************************************* -; putchar subroutine -; -; This subroutine reads one byte from the SCI port -; -; Input: One byte from the SCI port -; Output: One byte in accumulator A -; Registers in use: Accumulator A for output byte -; Memory locations in use: SCISR1 and SCIDRL status and data registers -; - -getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 - ldaa SCIDRL ; Read one byte from SCI port into A - rts ; Return to caller -getchar7 clra ; Set A to 0 - rts ; Return to caller - -* -************************************************************************** -* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory -* - -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',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 - -; msg: this is the main option menu string -msg dc.b 'Commands:',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 - dc.b 's: Display the seconds on the 7 segment displays',CR,LF - dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL - - end ; last line of the file diff --git a/cmpen472_hw8McDonnell/Sources/derivative.inc b/cmpen472_hw8McDonnell/Sources/derivative.inc deleted file mode 100644 index 988343b..0000000 --- a/cmpen472_hw8McDonnell/Sources/derivative.inc +++ /dev/null @@ -1,10 +0,0 @@ - - ; Note: This file is recreated by the project wizard whenever the MCU is - ; changed and should not be edited by hand - ; - - ; include derivative specific macros - INCLUDE 'mc9s12c32.inc' - - - diff --git a/cmpen472_hw8McDonnell/Sources/main.asm b/cmpen472_hw8McDonnell/Sources/main.asm deleted file mode 100644 index cbfe22a..0000000 --- a/cmpen472_hw8McDonnell/Sources/main.asm +++ /dev/null @@ -1,764 +0,0 @@ -************************************************************************** -* -* Title: Calculator -* -* Objective: CMPEN 472 Homework 8 -* -* Revision: V1.0 -* -* Date: Mar. 24, 2025 -* -* Programmer: Jacob McDonnell -* -* Company: The Pennsylvania State University -* Department of Computer Science and Engineering -* -* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking -* -* Register Use: A & B to current byte, etc, -* X & Y holds address of strings and length of string, -* D to hold data for printing, reading, and updating time. -* -* Memory Use: RAM Locations from $3000 for data, -* RAM Locations from $3100 for program -* -* Input: Serial Port for User Input -* -* Output: Serial Port for String Output -* -* Observation: The HC12 will output the time and a command prompt every second. -* The user can input commands and the program will output a response -* based on the input. -* -* Note: ON CSM-12C128 board, -* -* 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 - -* Symbols and Macros -PORTA equ $0000 ; i/o port A addresses -DDRA equ $0002 ; data direction register for PORTA -PORTB equ $0001 ; i/o port B addresses -DDRB equ $0003 ; data direction register for PORTB - -SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H -SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L -SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 -SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 -SCIDRL equ $00CF ; Serial port (SCI) Data Register - -CRGFLG EQU $0037 ; Clock and Reset Generator Flags -CRGINT EQU $0038 ; Clock and Reset Generator Interrupts -RTICTL EQU $003B ; Real Time Interrupt Control - -CR equ $0d ; carriage return, ASCII 'Return' key -LF equ $0a ; line feed, ASCII 'next line' character -NULL equ $00 ; NULL Terminator character - -************************************************************************** -* Data Section: address used [ $3000 to $30FF ] RAM Memory -* - org $3000 ; Reserved RAM memory starting address - ; for Data for CMPEN 472 class -buffer ds.b $0010 ; Array of 16 bytes to read a string - dc.b NULL ; NULL terminated -lenBuf dc.w $0010 ; Length of buffer array - -buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal - dc.b NULL ; NULL terminated -lenBuf2 dc.w $0010 ; length of buffer2 - -hours dc.w $0000 ; Buffer to hold the hours of the time - -minutes dc.w $0000 ; Buffer to hold the minutes of the time - -seconds dc.w $0000 ; Buffer to hold the seconds of the time - -counter dc.w $0000 ; Counter for RTI ISR for 1 second - -numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers - -operator dc.b $0000 ; Used by ReadDecimal for reading numbers - -inputBuffer ds.b $0010 ; Input Buffer Length - -lenInput dc.w $0010 ; Length of the Input Buffer - -outputBuf dc.b 'h' ; Used to control what to output on 7 segment display - -* -* There is a section Data Section at the end of the file -************************************************************************** -* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory -* - org $FFF0 ; Memory location for RTI interrupt vector section for simulator - dc.w rtiisr ; Real Time Interrupt vector -* -************************************************************************** -* Program Section: address used [ $3100 to $3FFF ] RAM Memory -* - org $3100 ; Program start address, in RAM -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 #$0C ; Enable SCI port Tx and Rx units - staa SCICR2 ; disable SCI interrupts - - ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) - std SCIBDH ; SCI port baud rate change - - ldx #msg ; Load the address of the welcome message into X - jsr WriteString ; Write the string to the serial console - - bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board - ; 4MHz quartz oscillator clock - 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 - cli ; Enable interrupts - jsr PrintTime ; Jump to PrintTime to write to serial console -mainLoop - 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 - - ldx #inputBuffer ; Load the address of inputBuffer into X - jsr ExecuteCommand ; Jump to ExecuteCommand - - ldx #inputBuffer ; Load the address of inputBuffer into X - ldy lenInput ; Load the length of inputBuffer into Y - jsr Zeros ; Zero out inputBuffer - - sei ; Disable interrupts - jsr PrintTime ; Jump to PrintTime to print new time - cli ; Enable interrupts - - bra mainLoop ; Loop back to mainLoop always - -TypeWrite - sei ; Disable Interrupts - bclr CRGINT,%10000000; Disable RTI interrupt - ldx #twMsg ; Load the address of twMsg into X - jsr WriteString ; Write the string to the serial console -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 - -************************************************************************** -* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory -* - -;************************************************************************* -; rtiisr subroutine -; -; This subroutine will increment the counter, seconds, minutes, & hours counters -; to track the time. This subroutine will be called ~400 times a second. -; -; Input: No input other than the timer to call the isr. -; Output: The counter, seconds, minutes, & hours buffers will -; be updated to track the time, the time & prompt will be -; printed every second. -; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. -; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, -; Buffer words for counters, seconds, minutes, & hours buffers. -; -; Comments: The counter buffer should be compared to 400, but for the simulator, -; the counter is compared to 200 to better simulate 1 second on my computer. -; - -rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag - ldx counter ; Load counter into X - inx ; Increment counter by 1 - stx counter ; Save X to counter - 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 - inx ; Increment the seconds by 1 - stx seconds ; Save the new seconds to the location - cpx #60 ; Compare X to 60 - bne rtidone ; If X != 60, exit isr - ldx #0 ; Reset the seconds - stx seconds ; Save the new seconds to the location - ldx minutes ; load the minutes into X - inx ; Increment the minutes by 1 - stx minutes ; Save the updated minutes - cpx #60 ; Compare the minutes to 60 - bne rtidone ; If X != 60, exit isr - ldx #0 ; Reset the minutes - stx minutes ; Save the updated minutes - ldx hours ; Load the hours into X - inx ; Increment the hours by 1 - stx hours ; Save the updated hours - cpx #24 ; Compare the hours to 24 - bne rtidone ; If X != 24, exit the isr - ldx #0 ; Reset the hours - stx hours ; Save the updated hours -rtidone jsr PrintTime ; Jump to PrintTime -rtiSkip RTI ; Return from RTI ISR - -;************************************************************************* -; PrintTime subroutine -; -; This subroutine will print the time, command prompt, and maybe an error prompt. -; -; Input: No input. -; Output: The time prompt, time, command prompt, the current input, -; and/or an error on the serial console. -; Registers in use: A for the characters to print, X for buffer addresses, -; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB -; Memory locations in use: Memory Address for serial line, Buffer words for counters, -; seconds, minutes, & hours buffers, and buffer to print time, -; outputBuf for tracking what to output on PORTB. -; -; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine -; will print the current user input if its not finished. -; - -PrintTime - pshd ; Save D to the stack - pshy ; Save Y to the stack - pshx ; Save X to the stack - ldaa #CR ; Load the character CR into A - jsr putchar ; Write the character to the serial - ldaa #LF ; Load the character LF into A - jsr putchar ; Write the character to the serial - ldx #clock ; Load the address of the clock prompt into X - jsr WriteString ; Write the string to serial - ldd hours ; Load the hours into D - cpd #10 ; Compare D to 10 - bhs goodHours ; If D >= goodHours - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodHours ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #':' ; Load the character ':' into A - jsr putchar ; Write the character to the serial - ldd minutes ; Load the minutes into D - cpd #10 ; Compare D to 10 - bhs goodMins ; If D >= goodMins - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodMins ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #':' ; Load the character ':' into A - jsr putchar ; Write the character to the serial - ldd seconds ; Load the seconds into D - cpd #10 ; Compare D to 10 - bhs goodSecs ; If D >= goodSecs - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodSecs ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #' ' ; Load ' ' character into A - jsr putchar ; Write the character to the serial console - jsr putchar ; Write the character to the serial console - jsr putchar ; Write the character to the serial console - jsr putchar ; Write the character to the serial console - 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 - 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 subroutine -; -; This subroutine will output the time given on on PORTB for two seven segment displays. -; -; Input: Two Digit Decimal number in register D. -; Output: The given two digit decimal number on PORTB for two 7 segment displays. -; Registers in use: D for the input, and for math to split the digits, X for math to split digits. -; Memory locations in use: PORTB memory location. -; -; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal -; numbers (leading zeros will be added). -; - -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 subroutine -; -; This subroutine will parse user input and execute the proper command or error out. -; -; Input: An address of a NULL terminated string in X. -; Output: The output of the proper command or an error message. -; Registers in use: X for the address of the user input, A for individual characters, -; D & Y for numbers read from user input. -; Memory locations in use: Serial console memory locations. -; -; Comments: This subroutine will disable interrupts while setting the time and will -; reenable them after setting the time. -; - -ExecuteCommand - pshd ; Save D to the stack - pshy ; Save Y to the stack - ldaa 1,x+ ; Load the character from X into A - lbeq ecDone ; If A == 0, jump to ecDone - cmpa #'t' ; Compare A to 't' - bne isH ; If A != 't', branch to isH -skipSpaces ldaa 1,+x ; Load the next character into X - cmpa #' ' ; Compare A to ' ' character - beq skipSpaces ; If A == ' ', loop to skipSpaces - sei ; Disable interrupts - ldd hours ; Load hours into D - pshd ; Save hours to the stack - jsr ReadDecimal ; Read Hour number - exg y,d ; Exchange Y and D - cpd #24 ; Compare D to 24 - lbhs badHours ; If D >= 24, badHours - cpd #0 ; Compare D to 0 - lblt badHours ; If D < 0, badHours - std hours ; Save D to hours - ldaa -1,x ; Load the next character into A - cmpa #':' ; Compare A to ':' - lbne badHours ; If A != ':', badHours - ldd minutes ; Load minutes into D - pshd ; Save minutes to the stack - jsr ReadDecimal ; Read minute number - exg y,d ; Exchange Y and D - cpd #60 ; Compare D to 60 - bhs badMinutes ; If D >= 60, badMinutes - cpd #0 ; Compare D to 0 - blt 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 - 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 - cpd #0 ; Compare D to 0 - blt 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 - 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 -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 - staa outputBuf ; Store A into outputBuf - bra 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 - staa outputBuf ; Store A into outputBuf - bra 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 - staa outputBuf ; Store A into outputBuf - bra ecDone ; Branch to ecDone -isQ cmpa #'q' ; Compare A to 'q' - bne badCommand ; If A != 'q', branch to badCommand - ldab 1,x+ ; Load next character into B - cmpb #NULL ; Compare B to NULL - bne badCommand ; If B != NULL, branch to ecDone - jmp TypeWrite ; Jump to TypeWrite -badSeconds puld ; Restore Seconds from the stack - std seconds ; Restore seconds before change -badMinutes puld ; Restore minutes from the stack - std minutes ; Restore minutes before change -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 -ecDone puly ; Restore Y from the stack - puld ; Restore D 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 -; its value. -; -; Input: A memory address in register X. -; Output: The value of the number in the Y register, and any errors printed -; to the serial line. Zero bit is set if error occurs. -; Registers in use: X for the address of the contents and for a buffer while printing, -; D for multiplication, B for the character, Y for output value. -; Memory locations in use: Memory Address for serial line, address of the string -; -; Comments: This subroutine will return the value in the Y register, and if an error occurs, -; the Zero bit in the CCR will be set. -; - -ReadDecimal - pshd ; Save D to the stack - ldy #0 ; Clear Y register -dHLoop ldab 1,x+ ; Read Next character from X - beq dHDone ; If B == 0, exit loop - cmpb #'+' ; Compare B to '+' - beq dHDone ; If B == '+', end of number - cmpb #'-' ; Compare B to '-' - beq dHDone ; If B == '-', end of number - cmpb #'*' ; Compare B to '*' - beq dHDone ; If B == '+', end of number - cmpb #'/' ; Compare B to '/' - beq dHDone ; If B == '-', end of number - cmpb #':' ; Compare B to ':' - beq dHDone ; If B == '-', end of number - cmpb #' ' ; Compare B to space character - beq dHDone ; If B == ' ', exit loop - cmpb #'0' ; Compare B to '0' character - blt dHError ; If B < '0', bad address, exit loop - cmpb #'9' ; Compare B to '9' character - bhi dHError ; If B > '9', check if 'A'-'F' characters - subb #'0' ; Subtract '0' from B to get true value - pshb ; Save B to the stack - ldd #10 ; load 10 into D - emul ; Multiply Y and D - exg d,y ; Transfer data from D to Y - pulb ; Restore b from the stack - aby ; Add B to Y - bra dHLoop ; Branch always to rHLoop -dHDone clra ; clear A accumulator - tap ; Transfer A into CCR to clear zero bit - puld ; Restore D from the stack - rts ; Return to caller -dHError ldaa #4 ; Load 4 into A to set zero bit in CCR - tap ; Transfer A into CCR to set zero bit and warn error - puld ; Restore D from the stack - rts ; Return to caller - -;************************************************************************* -; strrev subroutine -; -; This subroutine will reverse a string from one buffer into another. -; -; Input: Address of null terminated string in X, address of a large enough -; buffer in Y. -; Output: The string in X reversed in Y. -; Registers in use: X for the address of the string, Y for the address of the buffer, -; A to read characters from the string. -; Memory locations in use: Memory Address for serial line, address of the string & buffer -; -; Comments: This subroutine will not check that the output buffer is large enough, that -; is the job of the caller. -; - -strrev - pshx ; Save X to the stack - pshy ; Save Y to the stack - psha ; Save A to the stack -revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y - beq revDone ; If Character is 0, exit loop - staa 1,x+ ; Save character in address in X, increment X - bra revLoop ; Loop back always - clra ; Set A to Zero -revDone staa 1,x+ ; Copy Null terminator into new string - pula ; Restore A from the stack - puly ; Restore Y from the stack - pulx ; Restore X from the stack - rts ; Return to caller - -;************************************************************************* -; PrintDecimalWord subroutine -; -; This subroutine will print a given word of data to the serial in binary. -; -; Input: 1 word of data in register D, Buffer Address in Y -; Output: Decimal representation of the data on the serial console -; Registers in use: Y for the address of the buffer, X to count the number of bits -; written and for division, D for the input, A for characters. -; Memory locations in use: Memory addresses for serial, and operator to hold sign -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -PrintDecimalWord - pshx ; Save X to the stack - pshy ; Save Y to the stack - pshd ; Save D (A:B) to the stack - cpd #0 ; Compare D to zero - beq dIsZero ; Branch to hIsZero - blt dIsNegative ; If D < 0, Jump to dIsNegative -dAfterNeg psha ; Save A to the stack - pshy ; Save Y to the stack - pshx ; Save x to the stack - ldaa #'0' ; Load the '0' character into A - ldx #buffer2 ; Load the address of buffer2 into X - ldy #5 ; Load 5 into Y - jsr memset ; Write '0' to the first 5 bytes in buffer2 - pulx ; Restore X from the stack - puly ; Restore Y from the stack - clra ; Set A to zero - staa 0,y ; Load Zero into Y for Null Terminator - pula ; Restore A from the stack -dPrintLoop ldx #10 ; Load 10 in X for division - idiv ; Divide D / 10 to get Hex Digit - cpx #0 ; Compare X to 0 - beq dCheck ; If X == 0, branch to check D is zero -dDNotZero addb #'0' ; Add '0' to B to get ASCII Character - stab 1,+y ; Save character from B to Y - exg X,D ; Swap values in X and D - bra dPrintLoop ; Loop to hPrintLoop -dCheck cpd #0 ; Compare D to 0 - bne dDNotZero ; If D != 0, branch back to hDNotZero -dPrintDone ldaa operator ; Load operator into A to see if negative - cmpa #'-' ; Compare A to '-' - bne dNotNeg ; If A != '-', jump to dNotNeg - staa 1,+y ; Save '-' into buffer -dNotNeg ldx #buffer2 ; Load the address of buffer2 in X - jsr strrev ; Reverse string in Y in buffer in X - jsr WriteString ; Jump to write string to write the number - ldy lenBuf2 ; Load the length of buffer2 into Y - ldx #buffer2 ; Load the address of buffer2 into X - jsr Zeros ; Fill buffer2 with zeros - puld ; Restore D (A:B) from the stack - puly ; Restore Y from the stack - pulx ; Restore X from the stack - rts ; Return to caller -dIsZero ldaa #'0' ; Load '0' character into A - jsr putchar ; Print character to the screen - puld ; Restore D (A:B) from the stack - puly ; Restore Y from the stack - pulx ; Restore X from the stack - rts ; Return to caller -dIsNegative psha ; Save A to the stack - ldaa #'-' ; Load '-' into A - staa operator ; Save '-' to operator buffer - pula ; Restore A from the stack - nega ; Two's complement of A - suba #1 ; Subtract 1 from A - negb ; Two'complement of B - subb #1 ; Subtract 1 from B - addd #1 ; Add 1 to D - bra dAfterNeg ; Jump back to dAfterNeg - -;************************************************************************* -; Zeros subroutine -; -; This subroutine will write zeros to every byte in a given array. -; -; Input: Address of an array in X and its length in Y -; Output: Zeros in every byte of an array. -; Registers in use: X for the address of the array, Y for the length, and A for 0 -; Memory locations in use: Memory Address of the array -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -Zeros - psha ; Save A to the Stack - clra ; Clear A -zerosLoop staa 1,x+ ; Load A into byte at X - dbne y,zerosLoop ; Decrement Y and loop if Y != 0 - pula ; Restore A from the stack - rts ; Return to caller - -;************************************************************************* -; memset subroutine -; -; This subroutine will write a given byte to every byte in a given array. -; -; Input: Address of an array in X and its length in Y, the byte in A -; Output: The given byte in every byte of an array. -; Registers in use: X for the address of the array, Y for the length, and A for the given byte -; Memory locations in use: Memory Address of the array -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -memset - staa 1,x+ ; Load A into byte at X - dbne y,memset ; Decrement Y and loop if Y != 0 - rts ; Return to caller - -;************************************************************************* -; WriteString subroutine -; -; This subroutine will write a given null terminated string to the serial. -; -; Input: Address of null terminated string in X -; Output: Null terminated string written to serial -; Registers in use: X for the address of the string and A for the current byte -; Memory locations in use: Memory Address for serial line, address of the string -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -WriteString - psha ; Save A to the stack -writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 - beq doneWrite ; if A == 0, branch to doneWrite - jsr putchar ; Jump to putchar to write byte to serial - bra writeLoop ; branch always to writeLoop -doneWrite pula ; restore A from the stack - rts ; return to caller - -;************************************************************************* -; ReadString subroutine -; -; This subroutine will read a string from the serial line to a given address. -; -; Input: Address of an array in X -; Output: Null terminated string in the given array -; Registers in use: X for the address of the string Y for the length of the string, -; and A for the current byte -; Memory locations in use: Memory Address for serial line, address of the string -; -; Comments: This subroutine requires serial to be setup and getchar subroutine. -; - -ReadString - psha ; Save accumulator A to the stack - pshy ; Save Y to the stack - pshx ; Save X to the stack -readLoop jsr getchar ; Jump to putchar to write byte to serial - beq readLoop ; While A == 0, loop - cmpa #CR ; If A == CR, exit loop - beq doneRead ; Branch to doneRead if A == CR - staa 1,x+ ; Save the byte to the addr in X, then add 1 - jsr putchar ; Write Character back to the terminal - 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 - pulY ; Restore Y from the stack - pula ; restore A from the stack - rts ; return to caller - -;************************************************************************* -; putchar subroutine -; -; This subroutine writes a single byte to a serial line -; -; Input: A single ASCII byte in accumulator A -; Output: Sends one character to SCI port -; Registers in use: Accumulator A with input byte -; Memory locations in use: SCISR1 and SCIDRL status and data registers -; - -putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty - staa SCIDRL ; send a character - rts ; Return to caller - -;************************************************************************* -; putchar subroutine -; -; This subroutine reads one byte from the SCI port -; -; Input: One byte from the SCI port -; Output: One byte in accumulator A -; Registers in use: Accumulator A for output byte -; Memory locations in use: SCISR1 and SCIDRL status and data registers -; - -getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 - ldaa SCIDRL ; Read one byte from SCI port into A - rts ; Return to caller -getchar7 clra ; Set A to 0 - rts ; Return to caller - -* -************************************************************************** -* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory -* - -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',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 - -; msg: this is the main option menu string -msg dc.b 'Commands:',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 - dc.b 's: Display the seconds on the 7 segment displays',CR,LF - dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL - - end ; last line of the file diff --git a/cmpen472_hw8McDonnell/bin/Project.abs b/cmpen472_hw8McDonnell/bin/Project.abs deleted file mode 100644 index 452be23..0000000 Binary files a/cmpen472_hw8McDonnell/bin/Project.abs and /dev/null differ diff --git a/cmpen472_hw8McDonnell/bin/Project.abs.phy b/cmpen472_hw8McDonnell/bin/Project.abs.phy deleted file mode 100644 index 05d1923..0000000 --- a/cmpen472_hw8McDonnell/bin/Project.abs.phy +++ /dev/null @@ -1,3 +0,0 @@ -S0580000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437325F6877384D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627348 -S2060FFFF0316A60 -S9030000FC diff --git a/cmpen472_hw8McDonnell/bin/Project.abs.s19 b/cmpen472_hw8McDonnell/bin/Project.abs.s19 deleted file mode 100644 index 6af90b5..0000000 --- a/cmpen472_hw8McDonnell/bin/Project.abs.s19 +++ /dev/null @@ -1,44 +0,0 @@ -S0580000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437325F6877384D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627348 -S123300000000000000000000000000000000000000010000000000000000000000000009C -S123302000000000001000000000000000000000000000000000000000000000000000007C -S106304000106811 -S1233100CF310086F15A03860C5ACBCC00015CC8CE34B71634174C3B194C38804C378086E8 -S1233120FF5A03CE3030FD304016340810EF1631B9CE3030FD3040163423CE30301632665F -S1233140CE3030FD304016340814101631B910EF20DF14104D3880CE3471163417163444D1 -S12331609727FA5A0116343D20F34C3780FE302C087E302C8E00C8263FCE00007E302CFEFE -S1233180302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C2618CE000027 -S12331A07E3028FE3026087E30268E00182606CE00007E30261631B90B3B3534860D163405 -S12331C03D860A16343DCE344D163417FC30268C000A240736863016343D32CD30001633E9 -S12331E099863A16343DFC30288C000A240736863016343D32CD3000163399863A16343D0B -S1233200FC302A8C000A240736863016343D32CD3000163399862016343D16343D16343DD4 -S123322016343DCE3455163417CE3030163417B6304281682605FC3026200C816D2605FCED -S123324030282003FC302A16324E30313A3D3B34CE000A181037B7D4CE000A58585858EAD8 -S1233260B05B01303A3D3B35A630182700D58174266DA620812027FA1410FC30263B163333 -S123328046B7E48C0018182400978C0000182D00907C3026A61F813A18260085FC30283BCD -S12332A0163346B7E48C003C24738C00002D6E7C3028A61F813A2665FC302A3B163346B7A4 -S12332C0E48C003C24538C00002D4E7C302AA61F81002645877A302C10EF3A3A3A2064812A -S12332E068260BE630C100263E7A30422055816D260BE630C100262F7A30422046817326DE -S12333000BE630C10026207A3042203781712617E630C10026110631523A7C302A3A7C3082 -S1233320283A7C302610EF34862016343D16343D16343D16343DCE345B163417CE34631627 -S1233340341730313A3D3BCD0000E630272EC12B272AC12D2726C12A2722C12F271EC13AF7 -S1233360271AC1202716C1302D17C1392213C03037CC000A13B7C63319ED20CE87B7023A58 -S12333803D8604B7023A3D343536A67F27056A3020F8876A303231303D34353B8C00002748 -S12333A04C2D533635348630CE3013CD00051634113031876A4032CE000A18108E00002731 -S12333C008CB306B60B7D420EE8C000026F3B6302F812D26026A60CE3013163387163417E6 -S12333E0FD3024CE30131634083A31303D863016343D3A31303D36862D7A302F3240800173 -S123340050C001C30001209B36876A300436FB323D6A300436FB3D36A630270516343D2032 -S1233420F7323D36353416344427FB810D270A6A3016343D03270220ED3031323D4FCC804F -S1233440FC5ACF3D4FCC200396CF3D873D436C6F636B3E2000434D443E20004572726F72DC -S12334603E2000496E76616C696420496E707574000D0A436C6F636B2073746F70706564D1 -S123348020616E64205479706577726974652070726F6772616D20737461727465642E0D7E -S12334A00A596F75206D617920747970652062656C6F772E0D0A00436F6D6D616E64733A8E -S12334C00D0A743A20536574207468652074696D6520696E20666F726D61742048483A4DD0 -S12334E04D3A53530D0A683A20446973706C61792074686520686F757273206F6E20746841 -S1233500652037207365676D656E7420646973706C6179730D0A6D3A20446973706C61799B -S123352020746865206D696E75746573206F6E207468652037207365676D656E742064694C -S123354073706C6179730D0A733A20446973706C617920746865207365636F6E6473206F12 -S12335606E207468652037207365676D656E7420646973706C6179730D0A713A2053746F6D -S1233580702074686520636C6F636B20616E6420656E74657220747970657772697465721A -S10635A00D0A000D -S105FFF0316A70 -S9030000FC diff --git a/cmpen472_hw8McDonnell/bin/main.dbg b/cmpen472_hw8McDonnell/bin/main.dbg deleted file mode 100644 index 94da668..0000000 --- a/cmpen472_hw8McDonnell/bin/main.dbg +++ /dev/null @@ -1,763 +0,0 @@ -************************************************************************** -* -* Title: Calculator -* -* Objective: CMPEN 472 Homework 8 -* -* Revision: V1.0 -* -* Date: Mar. 24, 2025 -* -* Programmer: Jacob McDonnell -* -* Company: The Pennsylvania State University -* Department of Computer Science and Engineering -* -* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking -* -* Register Use: A & B to current byte, etc, -* X & Y holds address of strings and length of string, -* D to hold data for printing, reading, and updating time. -* -* Memory Use: RAM Locations from $3000 for data, -* RAM Locations from $3100 for program -* -* Input: Serial Port for User Input -* -* Output: Serial Port for String Output -* -* Observation: The HC12 will output the time and a command prompt every second. -* The user can input commands and the program will output a response -* based on the input. -* -* Note: ON CSM-12C128 board, -* -* 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 - -* Symbols and Macros -PORTA equ $0000 ; i/o port A addresses -DDRA equ $0002 ; data direction register for PORTA -PORTB equ $0001 ; i/o port B addresses -DDRB equ $0003 ; data direction register for PORTB - -SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H -SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L -SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 -SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 -SCIDRL equ $00CF ; Serial port (SCI) Data Register - -CRGFLG EQU $0037 ; Clock and Reset Generator Flags -CRGINT EQU $0038 ; Clock and Reset Generator Interrupts -RTICTL EQU $003B ; Real Time Interrupt Control - -CR equ $0d ; carriage return, ASCII 'Return' key -LF equ $0a ; line feed, ASCII 'next line' character -NULL equ $00 ; NULL Terminator character - -************************************************************************** -* Data Section: address used [ $3000 to $30FF ] RAM Memory -* - org $3000 ; Reserved RAM memory starting address - ; for Data for CMPEN 472 class -buffer ds.b $0010 ; Array of 16 bytes to read a string - dc.b NULL ; NULL terminated -lenBuf dc.w $0010 ; Length of buffer array - -buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal - dc.b NULL ; NULL terminated -lenBuf2 dc.w $0010 ; length of buffer2 - -hours dc.w $0000 ; Buffer to hold the hours of the time - -minutes dc.w $0000 ; Buffer to hold the minutes of the time - -seconds dc.w $0000 ; Buffer to hold the seconds of the time - -counter dc.w $0000 ; Counter for RTI ISR for 1 second - -numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers - -operator dc.b $0000 ; Used by ReadDecimal for reading numbers - -inputBuffer ds.b $0010 ; Input Buffer Length - -lenInput dc.w $0010 ; Length of the Input Buffer - -outputBuf dc.b 'h' ; Used to control what to output on 7 segment display - -* -* There is a section Data Section at the end of the file -************************************************************************** -* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory -* - org $FFF0 ; Memory location for RTI interrupt vector section for simulator - dc.w rtiisr ; Real Time Interrupt vector -* -************************************************************************** -* Program Section: address used [ $3100 to $3FFF ] RAM Memory -* - org $3100 ; Program start address, in RAM -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 #$0C ; Enable SCI port Tx and Rx units - staa SCICR2 ; disable SCI interrupts - - ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) - std SCIBDH ; SCI port baud rate change - - ldx #msg ; Load the address of the welcome message into X - jsr WriteString ; Write the string to the serial console - - bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board - ; 4MHz quartz oscillator clock - 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 - cli ; Enable interrupts - jsr PrintTime ; Jump to PrintTime to write to serial console -mainLoop - 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 - - ldx #inputBuffer ; Load the address of inputBuffer into X - jsr ExecuteCommand ; Jump to ExecuteCommand - - ldx #inputBuffer ; Load the address of inputBuffer into X - ldy lenInput ; Load the length of inputBuffer into Y - jsr Zeros ; Zero out inputBuffer - - sei ; Disable interrupts - jsr PrintTime ; Jump to PrintTime to print new time - cli ; Enable interrupts - - bra mainLoop ; Loop back to mainLoop always - -TypeWrite - sei ; Disable Interrupts - bclr CRGINT,%10000000; Disable RTI interrupt - ldx #twMsg ; Load the address of twMsg into X - jsr WriteString ; Write the string to the serial console -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 - -************************************************************************** -* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory -* - -;************************************************************************* -; rtiisr subroutine -; -; This subroutine will increment the counter, seconds, minutes, & hours counters -; to track the time. This subroutine will be called ~400 times a second. -; -; Input: No input other than the timer to call the isr. -; Output: The counter, seconds, minutes, & hours buffers will -; be updated to track the time, the time & prompt will be -; printed every second. -; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. -; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, -; Buffer words for counters, seconds, minutes, & hours buffers. -; -; Comments: The counter buffer should be compared to 400, but for the simulator, -; the counter is compared to 200 to better simulate 1 second on my computer. -; - -rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag - ldx counter ; Load counter into X - inx ; Increment counter by 1 - stx counter ; Save X to counter - 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 - inx ; Increment the seconds by 1 - stx seconds ; Save the new seconds to the location - cpx #60 ; Compare X to 60 - bne rtidone ; If X != 60, exit isr - ldx #0 ; Reset the seconds - stx seconds ; Save the new seconds to the location - ldx minutes ; load the minutes into X - inx ; Increment the minutes by 1 - stx minutes ; Save the updated minutes - cpx #60 ; Compare the minutes to 60 - bne rtidone ; If X != 60, exit isr - ldx #0 ; Reset the minutes - stx minutes ; Save the updated minutes - ldx hours ; Load the hours into X - inx ; Increment the hours by 1 - stx hours ; Save the updated hours - cpx #24 ; Compare the hours to 24 - bne rtidone ; If X != 24, exit the isr - ldx #0 ; Reset the hours - stx hours ; Save the updated hours -rtidone jsr PrintTime ; Jump to PrintTime -rtiSkip RTI ; Return from RTI ISR - -;************************************************************************* -; PrintTime subroutine -; -; This subroutine will print the time, command prompt, and maybe an error prompt. -; -; Input: No input. -; Output: The time prompt, time, command prompt, the current input, -; and/or an error on the serial console. -; Registers in use: A for the characters to print, X for buffer addresses, -; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB -; Memory locations in use: Memory Address for serial line, Buffer words for counters, -; seconds, minutes, & hours buffers, and buffer to print time, -; outputBuf for tracking what to output on PORTB. -; -; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine -; will print the current user input if its not finished. -; - -PrintTime - pshd ; Save D to the stack - pshy ; Save Y to the stack - pshx ; Save X to the stack - ldaa #CR ; Load the character CR into A - jsr putchar ; Write the character to the serial - ldaa #LF ; Load the character LF into A - jsr putchar ; Write the character to the serial - ldx #clock ; Load the address of the clock prompt into X - jsr WriteString ; Write the string to serial - ldd hours ; Load the hours into D - cpd #10 ; Compare D to 10 - bhs goodHours ; If D >= goodHours - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodHours ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #':' ; Load the character ':' into A - jsr putchar ; Write the character to the serial - ldd minutes ; Load the minutes into D - cpd #10 ; Compare D to 10 - bhs goodMins ; If D >= goodMins - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodMins ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #':' ; Load the character ':' into A - jsr putchar ; Write the character to the serial - ldd seconds ; Load the seconds into D - cpd #10 ; Compare D to 10 - bhs goodSecs ; If D >= goodSecs - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodSecs ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #' ' ; Load ' ' character into A - jsr putchar ; Write the character to the serial console - jsr putchar ; Write the character to the serial console - jsr putchar ; Write the character to the serial console - jsr putchar ; Write the character to the serial console - 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 - 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 subroutine -; -; This subroutine will output the time given on on PORTB for two seven segment displays. -; -; Input: Two Digit Decimal number in register D. -; Output: The given two digit decimal number on PORTB for two 7 segment displays. -; Registers in use: D for the input, and for math to split the digits, X for math to split digits. -; Memory locations in use: PORTB memory location. -; -; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal -; numbers (leading zeros will be added). -; - -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 subroutine -; -; This subroutine will parse user input and execute the proper command or error out. -; -; Input: An address of a NULL terminated string in X. -; Output: The output of the proper command or an error message. -; Registers in use: X for the address of the user input, A for individual characters, -; D & Y for numbers read from user input. -; Memory locations in use: Serial console memory locations. -; -; Comments: This subroutine will disable interrupts while setting the time and will -; reenable them after setting the time. -; - -ExecuteCommand - pshd ; Save D to the stack - pshy ; Save Y to the stack - ldaa 1,x+ ; Load the character from X into A - lbeq ecDone ; If A == 0, jump to ecDone - cmpa #'t' ; Compare A to 't' - bne isH ; If A != 't', branch to isH -skipSpaces ldaa 1,+x ; Load the next character into X - cmpa #' ' ; Compare A to ' ' character - beq skipSpaces ; If A == ' ', loop to skipSpaces - sei ; Disable interrupts - ldd hours ; Load hours into D - pshd ; Save hours to the stack - jsr ReadDecimal ; Read Hour number - exg y,d ; Exchange Y and D - cpd #24 ; Compare D to 24 - lbhs badHours ; If D >= 24, badHours - cpd #0 ; Compare D to 0 - lblt badHours ; If D < 0, badHours - std hours ; Save D to hours - ldaa -1,x ; Load the next character into A - cmpa #':' ; Compare A to ':' - lbne badHours ; If A != ':', badHours - ldd minutes ; Load minutes into D - pshd ; Save minutes to the stack - jsr ReadDecimal ; Read minute number - exg y,d ; Exchange Y and D - cpd #60 ; Compare D to 60 - bhs badMinutes ; If D >= 60, badMinutes - cpd #0 ; Compare D to 0 - blt 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 - 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 - cpd #0 ; Compare D to 0 - blt 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 - 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 -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 - staa outputBuf ; Store A into outputBuf - bra 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 - staa outputBuf ; Store A into outputBuf - bra 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 - staa outputBuf ; Store A into outputBuf - bra ecDone ; Branch to ecDone -isQ cmpa #'q' ; Compare A to 'q' - bne badCommand ; If A != 'q', branch to badCommand - ldab 1,x+ ; Load next character into B - cmpb #NULL ; Compare B to NULL - bne badCommand ; If B != NULL, branch to ecDone - jmp TypeWrite ; Jump to TypeWrite -badSeconds puld ; Restore Seconds from the stack - std seconds ; Restore seconds before change -badMinutes puld ; Restore minutes from the stack - std minutes ; Restore minutes before change -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 -ecDone puly ; Restore Y from the stack - puld ; Restore D 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 -; its value. -; -; Input: A memory address in register X. -; Output: The value of the number in the Y register, and any errors printed -; to the serial line. Zero bit is set if error occurs. -; Registers in use: X for the address of the contents and for a buffer while printing, -; D for multiplication, B for the character, Y for output value. -; Memory locations in use: Memory Address for serial line, address of the string -; -; Comments: This subroutine will return the value in the Y register, and if an error occurs, -; the Zero bit in the CCR will be set. -; - -ReadDecimal - pshd ; Save D to the stack - ldy #0 ; Clear Y register -dHLoop ldab 1,x+ ; Read Next character from X - beq dHDone ; If B == 0, exit loop - cmpb #'+' ; Compare B to '+' - beq dHDone ; If B == '+', end of number - cmpb #'-' ; Compare B to '-' - beq dHDone ; If B == '-', end of number - cmpb #'*' ; Compare B to '*' - beq dHDone ; If B == '+', end of number - cmpb #'/' ; Compare B to '/' - beq dHDone ; If B == '-', end of number - cmpb #':' ; Compare B to ':' - beq dHDone ; If B == '-', end of number - cmpb #' ' ; Compare B to space character - beq dHDone ; If B == ' ', exit loop - cmpb #'0' ; Compare B to '0' character - blt dHError ; If B < '0', bad address, exit loop - cmpb #'9' ; Compare B to '9' character - bhi dHError ; If B > '9', check if 'A'-'F' characters - subb #'0' ; Subtract '0' from B to get true value - pshb ; Save B to the stack - ldd #10 ; load 10 into D - emul ; Multiply Y and D - exg d,y ; Transfer data from D to Y - pulb ; Restore b from the stack - aby ; Add B to Y - bra dHLoop ; Branch always to rHLoop -dHDone clra ; clear A accumulator - tap ; Transfer A into CCR to clear zero bit - puld ; Restore D from the stack - rts ; Return to caller -dHError ldaa #4 ; Load 4 into A to set zero bit in CCR - tap ; Transfer A into CCR to set zero bit and warn error - puld ; Restore D from the stack - rts ; Return to caller - -;************************************************************************* -; strrev subroutine -; -; This subroutine will reverse a string from one buffer into another. -; -; Input: Address of null terminated string in X, address of a large enough -; buffer in Y. -; Output: The string in X reversed in Y. -; Registers in use: X for the address of the string, Y for the address of the buffer, -; A to read characters from the string. -; Memory locations in use: Memory Address for serial line, address of the string & buffer -; -; Comments: This subroutine will not check that the output buffer is large enough, that -; is the job of the caller. -; - -strrev - pshx ; Save X to the stack - pshy ; Save Y to the stack - psha ; Save A to the stack -revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y - beq revDone ; If Character is 0, exit loop - staa 1,x+ ; Save character in address in X, increment X - bra revLoop ; Loop back always - clra ; Set A to Zero -revDone staa 1,x+ ; Copy Null terminator into new string - pula ; Restore A from the stack - puly ; Restore Y from the stack - pulx ; Restore X from the stack - rts ; Return to caller - -;************************************************************************* -; PrintDecimalWord subroutine -; -; This subroutine will print a given word of data to the serial in binary. -; -; Input: 1 word of data in register D, Buffer Address in Y -; Output: Decimal representation of the data on the serial console -; Registers in use: Y for the address of the buffer, X to count the number of bits -; written and for division, D for the input, A for characters. -; Memory locations in use: Memory addresses for serial, and operator to hold sign -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -PrintDecimalWord - pshx ; Save X to the stack - pshy ; Save Y to the stack - pshd ; Save D (A:B) to the stack - cpd #0 ; Compare D to zero - beq dIsZero ; Branch to hIsZero - blt dIsNegative ; If D < 0, Jump to dIsNegative -dAfterNeg psha ; Save A to the stack - pshy ; Save Y to the stack - pshx ; Save x to the stack - ldaa #'0' ; Load the '0' character into A - ldx #buffer2 ; Load the address of buffer2 into X - ldy #5 ; Load 5 into Y - jsr memset ; Write '0' to the first 5 bytes in buffer2 - pulx ; Restore X from the stack - puly ; Restore Y from the stack - clra ; Set A to zero - staa 0,y ; Load Zero into Y for Null Terminator - pula ; Restore A from the stack -dPrintLoop ldx #10 ; Load 10 in X for division - idiv ; Divide D / 10 to get Hex Digit - cpx #0 ; Compare X to 0 - beq dCheck ; If X == 0, branch to check D is zero -dDNotZero addb #'0' ; Add '0' to B to get ASCII Character - stab 1,+y ; Save character from B to Y - exg X,D ; Swap values in X and D - bra dPrintLoop ; Loop to hPrintLoop -dCheck cpd #0 ; Compare D to 0 - bne dDNotZero ; If D != 0, branch back to hDNotZero -dPrintDone ldaa operator ; Load operator into A to see if negative - cmpa #'-' ; Compare A to '-' - bne dNotNeg ; If A != '-', jump to dNotNeg - staa 1,+y ; Save '-' into buffer -dNotNeg ldx #buffer2 ; Load the address of buffer2 in X - jsr strrev ; Reverse string in Y in buffer in X - jsr WriteString ; Jump to write string to write the number - ldy lenBuf2 ; Load the length of buffer2 into Y - ldx #buffer2 ; Load the address of buffer2 into X - jsr Zeros ; Fill buffer2 with zeros - puld ; Restore D (A:B) from the stack - puly ; Restore Y from the stack - pulx ; Restore X from the stack - rts ; Return to caller -dIsZero ldaa #'0' ; Load '0' character into A - jsr putchar ; Print character to the screen - puld ; Restore D (A:B) from the stack - puly ; Restore Y from the stack - pulx ; Restore X from the stack - rts ; Return to caller -dIsNegative psha ; Save A to the stack - ldaa #'-' ; Load '-' into A - staa operator ; Save '-' to operator buffer - pula ; Restore A from the stack - nega ; Two's complement of A - suba #1 ; Subtract 1 from A - negb ; Two'complement of B - subb #1 ; Subtract 1 from B - addd #1 ; Add 1 to D - bra dAfterNeg ; Jump back to dAfterNeg - -;************************************************************************* -; Zeros subroutine -; -; This subroutine will write zeros to every byte in a given array. -; -; Input: Address of an array in X and its length in Y -; Output: Zeros in every byte of an array. -; Registers in use: X for the address of the array, Y for the length, and A for 0 -; Memory locations in use: Memory Address of the array -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -Zeros - psha ; Save A to the Stack - clra ; Clear A -zerosLoop staa 1,x+ ; Load A into byte at X - dbne y,zerosLoop ; Decrement Y and loop if Y != 0 - pula ; Restore A from the stack - rts ; Return to caller - -;************************************************************************* -; memset subroutine -; -; This subroutine will write a given byte to every byte in a given array. -; -; Input: Address of an array in X and its length in Y, the byte in A -; Output: The given byte in every byte of an array. -; Registers in use: X for the address of the array, Y for the length, and A for the given byte -; Memory locations in use: Memory Address of the array -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -memset - staa 1,x+ ; Load A into byte at X - dbne y,memset ; Decrement Y and loop if Y != 0 - rts ; Return to caller - -;************************************************************************* -; WriteString subroutine -; -; This subroutine will write a given null terminated string to the serial. -; -; Input: Address of null terminated string in X -; Output: Null terminated string written to serial -; Registers in use: X for the address of the string and A for the current byte -; Memory locations in use: Memory Address for serial line, address of the string -; -; Comments: This subroutine requires serial to be setup and putchar subroutine. -; - -WriteString - psha ; Save A to the stack -writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 - beq doneWrite ; if A == 0, branch to doneWrite - jsr putchar ; Jump to putchar to write byte to serial - bra writeLoop ; branch always to writeLoop -doneWrite pula ; restore A from the stack - rts ; return to caller - -;************************************************************************* -; ReadString subroutine -; -; This subroutine will read a string from the serial line to a given address. -; -; Input: Address of an array in X -; Output: Null terminated string in the given array -; Registers in use: X for the address of the string Y for the length of the string, -; and A for the current byte -; Memory locations in use: Memory Address for serial line, address of the string -; -; Comments: This subroutine requires serial to be setup and getchar subroutine. -; - -ReadString - psha ; Save accumulator A to the stack - pshy ; Save Y to the stack - pshx ; Save X to the stack -readLoop jsr getchar ; Jump to putchar to write byte to serial - beq readLoop ; While A == 0, loop - cmpa #CR ; If A == CR, exit loop - beq doneRead ; Branch to doneRead if A == CR - staa 1,x+ ; Save the byte to the addr in X, then add 1 - jsr putchar ; Write Character back to the terminal - 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 - pulY ; Restore Y from the stack - pula ; restore A from the stack - rts ; return to caller - -;************************************************************************* -; putchar subroutine -; -; This subroutine writes a single byte to a serial line -; -; Input: A single ASCII byte in accumulator A -; Output: Sends one character to SCI port -; Registers in use: Accumulator A with input byte -; Memory locations in use: SCISR1 and SCIDRL status and data registers -; - -putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty - staa SCIDRL ; send a character - rts ; Return to caller - -;************************************************************************* -; putchar subroutine -; -; This subroutine reads one byte from the SCI port -; -; Input: One byte from the SCI port -; Output: One byte in accumulator A -; Registers in use: Accumulator A for output byte -; Memory locations in use: SCISR1 and SCIDRL status and data registers -; - -getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 - ldaa SCIDRL ; Read one byte from SCI port into A - rts ; Return to caller -getchar7 clra ; Set A to 0 - rts ; Return to caller - -* -************************************************************************** -* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory -* - -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',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 - -; msg: this is the main option menu string -msg dc.b 'Commands:',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 - dc.b 's: Display the seconds on the 7 segment displays',CR,LF - dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL - diff --git a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Postload.cmd b/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Postload.cmd deleted file mode 100644 index ac4d359..0000000 --- a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Postload.cmd +++ /dev/null @@ -1 +0,0 @@ -// After load the commands written below will be executed diff --git a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Preload.cmd b/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Preload.cmd deleted file mode 100644 index 0bed464..0000000 --- a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Preload.cmd +++ /dev/null @@ -1 +0,0 @@ -// Before load the commands written below will be executed diff --git a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Reset.cmd b/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Reset.cmd deleted file mode 100644 index bf55944..0000000 --- a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Reset.cmd +++ /dev/null @@ -1 +0,0 @@ -// After reset the commands written below will be executed diff --git a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd b/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd deleted file mode 100644 index 6a1549a..0000000 --- a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd +++ /dev/null @@ -1 +0,0 @@ -// At startup the commands written below will be executed diff --git a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Startup.cmd b/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Startup.cmd deleted file mode 100644 index 6a1549a..0000000 --- a/cmpen472_hw8McDonnell/cmd/Full_Chip_Simulation_Startup.cmd +++ /dev/null @@ -1 +0,0 @@ -// At startup the commands written below will be executed diff --git a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell.mcp b/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell.mcp deleted file mode 100644 index 9377caf..0000000 Binary files a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell.mcp and /dev/null differ diff --git a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg b/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg deleted file mode 100644 index d39991e..0000000 Binary files a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg and /dev/null differ diff --git a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o deleted file mode 100644 index 452be23..0000000 Binary files a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o and /dev/null differ diff --git a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx deleted file mode 100644 index 9fb3f9a..0000000 --- a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx +++ /dev/null @@ -1,44 +0,0 @@ -S0840000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437325F6877384D63446F6E6E656C6C5C636D70656E3437325F6877384D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726DC9 -S123300000000000000000000000000000000000000010000000000000000000000000009C -S123302000000000001000000000000000000000000000000000000000000000000000007C -S106304000106811 -S105FFF0316A70 -S1233100CF310086F15A03860C5ACBCC00015CC8CE34B71634174C3B194C38804C378086E8 -S1233120FF5A03CE3030FD304016340810EF1631B9CE3030FD3040163423CE30301632665F -S1233140CE3030FD304016340814101631B910EF20DF14104D3880CE3471163417163444D1 -S12331609727FA5A0116343D20F34C3780FE302C087E302C8E00C8263FCE00007E302CFEFE -S1233180302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C2618CE000027 -S12331A07E3028FE3026087E30268E00182606CE00007E30261631B90B3B3534860D163405 -S12331C03D860A16343DCE344D163417FC30268C000A240736863016343D32CD30001633E9 -S12331E099863A16343DFC30288C000A240736863016343D32CD3000163399863A16343D0B -S1233200FC302A8C000A240736863016343D32CD3000163399862016343D16343D16343DD4 -S123322016343DCE3455163417CE3030163417B6304281682605FC3026200C816D2605FCED -S123324030282003FC302A16324E30313A3D3B34CE000A181037B7D4CE000A58585858EAD8 -S1233260B05B01303A3D3B35A630182700D58174266DA620812027FA1410FC30263B163333 -S123328046B7E48C0018182400978C0000182D00907C3026A61F813A18260085FC30283BCD -S12332A0163346B7E48C003C24738C00002D6E7C3028A61F813A2665FC302A3B163346B7A4 -S12332C0E48C003C24538C00002D4E7C302AA61F81002645877A302C10EF3A3A3A2064812A -S12332E068260BE630C100263E7A30422055816D260BE630C100262F7A30422046817326DE -S12333000BE630C10026207A3042203781712617E630C10026110631523A7C302A3A7C3082 -S1233320283A7C302610EF34862016343D16343D16343D16343DCE345B163417CE34631627 -S1233340341730313A3D3BCD0000E630272EC12B272AC12D2726C12A2722C12F271EC13AF7 -S1233360271AC1202716C1302D17C1392213C03037CC000A13B7C63319ED20CE87B7023A58 -S12333803D8604B7023A3D343536A67F27056A3020F8876A303231303D34353B8C00002748 -S12333A04C2D533635348630CE3013CD00051634113031876A4032CE000A18108E00002731 -S12333C008CB306B60B7D420EE8C000026F3B6302F812D26026A60CE3013163387163417E6 -S12333E0FD3024CE30131634083A31303D863016343D3A31303D36862D7A302F3240800173 -S123340050C001C30001209B36876A300436FB323D6A300436FB3D36A630270516343D2032 -S1233420F7323D36353416344427FB810D270A6A3016343D03270220ED3031323D4FCC804F -S1233440FC5ACF3D4FCC200396CF3D873D436C6F636B3E2000434D443E20004572726F72DC -S12334603E2000496E76616C696420496E707574000D0A436C6F636B2073746F70706564D1 -S123348020616E64205479706577726974652070726F6772616D20737461727465642E0D7E -S12334A00A596F75206D617920747970652062656C6F772E0D0A00436F6D6D616E64733A8E -S12334C00D0A743A20536574207468652074696D6520696E20666F726D61742048483A4DD0 -S12334E04D3A53530D0A683A20446973706C61792074686520686F757273206F6E20746841 -S1233500652037207365676D656E7420646973706C6179730D0A6D3A20446973706C61799B -S123352020746865206D696E75746573206F6E207468652037207365676D656E742064694C -S123354073706C6179730D0A733A20446973706C617920746865207365636F6E6473206F12 -S12335606E207468652037207365676D656E7420646973706C6179730D0A713A2053746F6D -S1233580702074686520636C6F636B20616E6420656E74657220747970657772697465721A -S10635A00D0A000D -S9033100CB diff --git a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt deleted file mode 100644 index 3962bcd..0000000 Binary files a/cmpen472_hw8McDonnell/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt and /dev/null differ diff --git a/cmpen472_hw8McDonnell/prm/burner.bbl b/cmpen472_hw8McDonnell/prm/burner.bbl deleted file mode 100644 index 0c57619..0000000 --- a/cmpen472_hw8McDonnell/prm/burner.bbl +++ /dev/null @@ -1,157 +0,0 @@ -/* logical s-record file */ -OPENFILE "%ABS_FILE%.s19" -format=motorola -busWidth=1 -origin=0 -len=0x1000000 -destination=0 -SRECORD=Sx -SENDBYTE 1 "%ABS_FILE%" -CLOSE - - -/* physical s-record file */ -OPENFILE "%ABS_FILE%.phy" -format = motorola -busWidth = 1 -len = 0x4000 - -/* logical non banked flash at $4000 and $C000 to physical */ -origin = 0x004000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" - -origin = 0x00C000 -destination = 0x0FC000 -SENDBYTE 1 "%ABS_FILE%" - -/* physical FTS512K flash window to physical -origin = 0x008000 -destination = 0x080000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS256K parts flash window to physical -origin = 0x008000 -destination = 0x0C0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS128K parts flash window to physical -origin = 0x008000 -destination = 0x0E0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS64K parts flash window to physical -origin = 0x008000 -destination = 0x0F0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS32K parts flash window to physical -origin = 0x008000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* logical 512 kB banked flash to physical */ -origin = 0x208000 -destination = 0x080000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x218000 -destination = 0x084000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x228000 -destination = 0x088000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x238000 -destination = 0x08C000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x248000 -destination = 0x090000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x258000 -destination = 0x094000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x268000 -destination = 0x098000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x278000 -destination = 0x09C000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x288000 -destination = 0x0A0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x298000 -destination = 0x0A4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2A8000 -destination = 0x0A8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2B8000 -destination = 0x0AC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2C8000 -destination = 0x0B0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2D8000 -destination = 0x0B4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2E8000 -destination = 0x0B8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2F8000 -destination = 0x0BC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x308000 -destination = 0x0C0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x318000 -destination = 0x0C4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x328000 -destination = 0x0C8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x338000 -destination = 0x0CC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x348000 -destination = 0x0D0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x358000 -destination = 0x0D4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x368000 -destination = 0x0D8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x378000 -destination = 0x0DC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x388000 -destination = 0x0E0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x398000 -destination = 0x0E4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3A8000 -destination = 0x0E8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3B8000 -destination = 0x0EC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3C8000 -destination = 0x0F0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3D8000 -destination = 0x0F4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3E8000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3F8000 -destination = 0x0FC000 -SENDBYTE 1 "%ABS_FILE%" - -CLOSE - diff --git a/cmpen472hw1_McDonnell/ASM_layout.hwl b/cmpen472hw1_McDonnell/ASM_layout.hwl new file mode 100644 index 0000000..af05bda --- /dev/null +++ b/cmpen472hw1_McDonnell/ASM_layout.hwl @@ -0,0 +1,18 @@ +OPEN source 0 0 60 42 +Source < attributes MARKS off +OPEN assembly 60 0 40 30 +Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,TOPPC 0xF800 +OPEN procedure 60 60 40 17 +Procedure < attributes VALUES on,TYPES off +OPEN register 60 30 40 30 +Register < attributes FORMAT AUTO,COMPLEMENT None +OPEN memory 60 77 40 23 +Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,ADDRESS 0x80 +OPEN data 0 42 60 28 +Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,UPDATERATE 10,NAMEWIDTH 16 +OPEN command 0 70 60 30 +Command < attributes CACHESIZE 1000 +bckcolor 50331647 +font 'Courier New' 9 BLACK +AUTOSIZE on +ACTIVATE Assembly Memory Register Command Data Source Procedure diff --git a/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell.mcp b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell.mcp new file mode 100644 index 0000000..3426ce8 Binary files /dev/null and b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell.mcp differ diff --git a/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/CWSettingsWindows.stg b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/CWSettingsWindows.stg new file mode 100644 index 0000000..af68d57 Binary files /dev/null and b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/CWSettingsWindows.stg differ diff --git a/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.o new file mode 100644 index 0000000..f706514 Binary files /dev/null and b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.o differ diff --git a/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.sx new file mode 100644 index 0000000..000c066 --- /dev/null +++ b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/ObjectCode/main.asm.sx @@ -0,0 +1,11 @@ +S0750000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E3437324857314D63446F6E6E656C6C5C434D50454E3437324857314D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726DC9 +S12330000000000000000000000000000000000000000000000000000000000000000000AC +S123302000000000000000000000000000000000000000000000000000000000000000008C +S123304000000000000000000000000000000000000000000000000000000000000000006C +S123306000000000000000000000000000000000000000000000000000000000000000004C +S123308000000000000000000000000000000000000000000000000000000000000000002C +S12330A000000000000000000000000000000000000000000000000000000000000000000C +S12330C00000000000000000000000000000000000000000000000000000000000000000EC +S10530E000E109 +S1133100862AF630E1CE30006A00085326FA20FE03 +S9033100CB diff --git a/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/TargetDataWindows.tdt new file mode 100644 index 0000000..a3ebd6d Binary files /dev/null and b/cmpen472hw1_McDonnell/CMPEN472HW1McDonnell_Data/Standard/TargetDataWindows.tdt differ diff --git a/cmpen472hw1_McDonnell/Default.mem b/cmpen472hw1_McDonnell/Default.mem new file mode 100644 index 0000000..bf49148 Binary files /dev/null and b/cmpen472hw1_McDonnell/Default.mem differ diff --git a/cmpen472hw1_McDonnell/Full_Chip_Simulation.ini b/cmpen472hw1_McDonnell/Full_Chip_Simulation.ini new file mode 100644 index 0000000..9cb2bbc --- /dev/null +++ b/cmpen472hw1_McDonnell/Full_Chip_Simulation.ini @@ -0,0 +1,27 @@ +[Environment Variables] +GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib +LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include +OBJPATH={Project}bin +TEXTPATH={Project}bin +ABSPATH={Project}bin + +[HI-WAVE] +Target=sim +Layout=ASM_layout.hwl +LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD +CPU=HC12 +MainFrame=0,1,-1,-1,-1,-1,211,107,2131,1130 +TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 + + + +[Simulator] +CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" + +[Simulator HC12] +CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" +CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" +CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" +CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" +HCS12_SUPPORT=1 +FCS=MC9S12C32 diff --git a/cmpen472hw1_McDonnell/Sources/cmpen472hw1_McDonnell.asm b/cmpen472hw1_McDonnell/Sources/cmpen472hw1_McDonnell.asm new file mode 100644 index 0000000..0d13fd1 --- /dev/null +++ b/cmpen472hw1_McDonnell/Sources/cmpen472hw1_McDonnell.asm @@ -0,0 +1,63 @@ +********************************************************************************************** +* +* Title: Star Fill (In Memory) Homework #1 +* +* Objective: CMPEN472 Homework #1 demonstration program. Fill 225 bytes of memory with '*'. +* +* Revision: V1.0 +* +* Date: Jan. 22, 2025 +* +* Programmer: Jacob McDonnell +* +* Company: The Pennsylvania State Universtiy +* Electrical Engineering and Computer Science +* +* Algorithm: While Loop demo of HCS12 Assembly +* +* Register Use: A accumulator: character to be placed in memory +* B accumulator: counter of filled memory locations +* X register: pointer to memory location to fill +* +* Memory use: RAM locations $3000 to $30E1 +* +* Input: No input, data and parameters are hard coded. +* +* Output: Memory locations $3000 to $30E1 are filled with '*' character. +* +* Observation: This program is designed for instruction purpose. +* This program can be a template for other loop based code. +* +* Comments: This program is developed and simulated using CodeWarrior Development Software. +* +********************************************************************************************** +* Parameter Declaration Section +* +* Export Symbols + xdef pgstart ; export 'pgstart' symbol + absentry pgstart ; for assembly entry point +* Symbols and Macros +porta equ $0000 ; i/o port address +portb equ $0001 +ddra equ $0002 +ddrb equ $0003 +********************************************************************************************** +* Data Section +* + org $3000 ; reserved memory starting address +here ds.b $e1 ; 225 memory locations reserved +count dc.b $e1 ; constant counter for stars = 225 +* +********************************************************************************************** +* Program Section +* + org $3100 ; Program Start Address in RAM +pgstart ldaa #'*' ; Load '*' into accumulator A + ldab count ; Load count of stars into B + ldx #here ; Load address pointer into X +loop staa 0,x ; Put a start at this memory location + inx ; Go to the next memory location + decb ; Decrement the counter + bne loop ; Loop if not done +done bra done ; Task finished + end ; Last line of a file \ No newline at end of file diff --git a/cmpen472hw1_McDonnell/Sources/derivative.inc b/cmpen472hw1_McDonnell/Sources/derivative.inc new file mode 100644 index 0000000..988343b --- /dev/null +++ b/cmpen472hw1_McDonnell/Sources/derivative.inc @@ -0,0 +1,10 @@ + + ; Note: This file is recreated by the project wizard whenever the MCU is + ; changed and should not be edited by hand + ; + + ; include derivative specific macros + INCLUDE 'mc9s12c32.inc' + + + diff --git a/cmpen472hw1_McDonnell/Sources/main.asm b/cmpen472hw1_McDonnell/Sources/main.asm new file mode 100644 index 0000000..0d13fd1 --- /dev/null +++ b/cmpen472hw1_McDonnell/Sources/main.asm @@ -0,0 +1,63 @@ +********************************************************************************************** +* +* Title: Star Fill (In Memory) Homework #1 +* +* Objective: CMPEN472 Homework #1 demonstration program. Fill 225 bytes of memory with '*'. +* +* Revision: V1.0 +* +* Date: Jan. 22, 2025 +* +* Programmer: Jacob McDonnell +* +* Company: The Pennsylvania State Universtiy +* Electrical Engineering and Computer Science +* +* Algorithm: While Loop demo of HCS12 Assembly +* +* Register Use: A accumulator: character to be placed in memory +* B accumulator: counter of filled memory locations +* X register: pointer to memory location to fill +* +* Memory use: RAM locations $3000 to $30E1 +* +* Input: No input, data and parameters are hard coded. +* +* Output: Memory locations $3000 to $30E1 are filled with '*' character. +* +* Observation: This program is designed for instruction purpose. +* This program can be a template for other loop based code. +* +* Comments: This program is developed and simulated using CodeWarrior Development Software. +* +********************************************************************************************** +* Parameter Declaration Section +* +* Export Symbols + xdef pgstart ; export 'pgstart' symbol + absentry pgstart ; for assembly entry point +* Symbols and Macros +porta equ $0000 ; i/o port address +portb equ $0001 +ddra equ $0002 +ddrb equ $0003 +********************************************************************************************** +* Data Section +* + org $3000 ; reserved memory starting address +here ds.b $e1 ; 225 memory locations reserved +count dc.b $e1 ; constant counter for stars = 225 +* +********************************************************************************************** +* Program Section +* + org $3100 ; Program Start Address in RAM +pgstart ldaa #'*' ; Load '*' into accumulator A + ldab count ; Load count of stars into B + ldx #here ; Load address pointer into X +loop staa 0,x ; Put a start at this memory location + inx ; Go to the next memory location + decb ; Decrement the counter + bne loop ; Loop if not done +done bra done ; Task finished + end ; Last line of a file \ No newline at end of file diff --git a/cmpen472hw1_McDonnell/bin/Project.abs b/cmpen472hw1_McDonnell/bin/Project.abs new file mode 100644 index 0000000..f706514 Binary files /dev/null and b/cmpen472hw1_McDonnell/bin/Project.abs differ diff --git a/cmpen472hw1_McDonnell/bin/Project.abs.phy b/cmpen472hw1_McDonnell/bin/Project.abs.phy new file mode 100644 index 0000000..3d1b12c --- /dev/null +++ b/cmpen472hw1_McDonnell/bin/Project.abs.phy @@ -0,0 +1,2 @@ +S04A0000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E3437324857314D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627301 +S9030000FC diff --git a/cmpen472hw1_McDonnell/bin/Project.abs.s19 b/cmpen472hw1_McDonnell/bin/Project.abs.s19 new file mode 100644 index 0000000..8000fb1 --- /dev/null +++ b/cmpen472hw1_McDonnell/bin/Project.abs.s19 @@ -0,0 +1,11 @@ +S04A0000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E3437324857314D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627301 +S12330000000000000000000000000000000000000000000000000000000000000000000AC +S123302000000000000000000000000000000000000000000000000000000000000000008C +S123304000000000000000000000000000000000000000000000000000000000000000006C +S123306000000000000000000000000000000000000000000000000000000000000000004C +S123308000000000000000000000000000000000000000000000000000000000000000002C +S12330A000000000000000000000000000000000000000000000000000000000000000000C +S12330C00000000000000000000000000000000000000000000000000000000000000000EC +S10530E000E109 +S1133100862AF630E1CE30006A00085326FA20FE03 +S9030000FC diff --git a/cmpen472hw1_McDonnell/bin/main.dbg b/cmpen472hw1_McDonnell/bin/main.dbg new file mode 100644 index 0000000..7a8bd97 --- /dev/null +++ b/cmpen472hw1_McDonnell/bin/main.dbg @@ -0,0 +1,62 @@ +********************************************************************************************** +* +* Title: Star Fill (In Memory) Homework #1 +* +* Objective: CMPEN472 Homework #1 demonstration program. Fill 225 bytes of memory with '*'. +* +* Revision: V1.0 +* +* Date: Jan. 22, 2025 +* +* Programmer: Jacob McDonnell +* +* Company: The Pennsylvania State Universtiy +* Electrical Engineering and Computer Science +* +* Algorithm: While Loop demo of HCS12 Assembly +* +* Register Use: A accumulator: character to be placed in memory +* B accumulator: counter of filled memory locations +* X register: pointer to memory location to fill +* +* Memory use: RAM locations $3000 to $30E1 +* +* Input: No input, data and parameters are hard coded. +* +* Output: Memory locations $3000 to $30E1 are filled with '*' character. +* +* Observation: This program is designed for instruction purpose. +* This program can be a template for other loop based code. +* +* Comments: This program is developed and simulated using CodeWarrior Development Software. +* +********************************************************************************************** +* Parameter Declaration Section +* +* Export Symbols + xdef pgstart ; export 'pgstart' symbol + absentry pgstart ; for assembly entry point +* Symbols and Macros +porta equ $0000 ; i/o port address +portb equ $0001 +ddra equ $0002 +ddrb equ $0003 +********************************************************************************************** +* Data Section +* + org $3000 ; reserved memory starting address +here ds.b $e1 ; 225 memory locations reserved +count dc.b $e1 ; constant counter for stars = 225 +* +********************************************************************************************** +* Program Section +* + org $3100 ; Program Start Address in RAM +pgstart ldaa #'*' ; Load '*' into accumulator A + ldab count ; Load count of stars into B + ldx #here ; Load address pointer into X +loop staa 0,x ; Put a start at this memory location + inx ; Go to the next memory location + decb ; Decrement the counter + bne loop ; Loop if not done +done bra done ; Task finished diff --git a/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd new file mode 100644 index 0000000..ac4d359 --- /dev/null +++ b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd @@ -0,0 +1 @@ +// After load the commands written below will be executed diff --git a/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd new file mode 100644 index 0000000..0bed464 --- /dev/null +++ b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd @@ -0,0 +1 @@ +// Before load the commands written below will be executed diff --git a/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd new file mode 100644 index 0000000..bf55944 --- /dev/null +++ b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd @@ -0,0 +1 @@ +// After reset the commands written below will be executed diff --git a/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw1_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw1_McDonnell/prm/burner.bbl b/cmpen472hw1_McDonnell/prm/burner.bbl new file mode 100644 index 0000000..0c57619 --- /dev/null +++ b/cmpen472hw1_McDonnell/prm/burner.bbl @@ -0,0 +1,157 @@ +/* logical s-record file */ +OPENFILE "%ABS_FILE%.s19" +format=motorola +busWidth=1 +origin=0 +len=0x1000000 +destination=0 +SRECORD=Sx +SENDBYTE 1 "%ABS_FILE%" +CLOSE + + +/* physical s-record file */ +OPENFILE "%ABS_FILE%.phy" +format = motorola +busWidth = 1 +len = 0x4000 + +/* logical non banked flash at $4000 and $C000 to physical */ +origin = 0x004000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" + +origin = 0x00C000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +/* physical FTS512K flash window to physical +origin = 0x008000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS256K parts flash window to physical +origin = 0x008000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS128K parts flash window to physical +origin = 0x008000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS64K parts flash window to physical +origin = 0x008000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS32K parts flash window to physical +origin = 0x008000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* logical 512 kB banked flash to physical */ +origin = 0x208000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x218000 +destination = 0x084000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x228000 +destination = 0x088000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x238000 +destination = 0x08C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x248000 +destination = 0x090000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x258000 +destination = 0x094000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x268000 +destination = 0x098000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x278000 +destination = 0x09C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x288000 +destination = 0x0A0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x298000 +destination = 0x0A4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2A8000 +destination = 0x0A8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2B8000 +destination = 0x0AC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2C8000 +destination = 0x0B0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2D8000 +destination = 0x0B4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2E8000 +destination = 0x0B8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2F8000 +destination = 0x0BC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x308000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x318000 +destination = 0x0C4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x328000 +destination = 0x0C8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x338000 +destination = 0x0CC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x348000 +destination = 0x0D0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x358000 +destination = 0x0D4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x368000 +destination = 0x0D8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x378000 +destination = 0x0DC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x388000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x398000 +destination = 0x0E4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3A8000 +destination = 0x0E8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3B8000 +destination = 0x0EC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3C8000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3D8000 +destination = 0x0F4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3E8000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3F8000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +CLOSE + diff --git a/cmpen472hw2McDonnell/ASM_layout.hwl b/cmpen472hw2McDonnell/ASM_layout.hwl deleted file mode 100644 index 0e6a666..0000000 --- a/cmpen472hw2McDonnell/ASM_layout.hwl +++ /dev/null @@ -1,26 +0,0 @@ -OPEN source 0 0 60 42 -Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off -OPEN assembly 60 0 40 30 -Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0xCBCB -OPEN procedure 60 60 40 17 -Procedure < attributes VALUES on,TYPES off -OPEN register 60 30 40 30 -Register < attributes FORMAT AUTO,COMPLEMENT None -OPEN memory 60 77 40 23 -Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 -OPEN data 0 42 60 28 -Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 -OPEN command 0 70 60 30 -Command < attributes CACHESIZE 1000 -OPEN Visualizationtool 63 50 26 29 -VisualizationTool< Attributes [stEditM="0",swGridMode="1",swRefresh="3",refCycles="1"] -VisualizationTool< LoadInstrument LED[BoundX="102",BoundY="40",Port="0x0001",Port_PortEndian="1",swBIT="7"] -VisualizationTool< LoadInstrument LED[BoundX="133",BoundY="41",Port="0x0001",Port_PortEndian="1",swBIT="6"] -VisualizationTool< LoadInstrument LED[BoundX="166",BoundY="37",Port="0x0001",Port_PortEndian="1",swBIT="5"] -VisualizationTool< LoadInstrument LED[BoundX="202",BoundY="42",Port="0x0001",Port_PortEndian="1",swBIT="4"] -VisualizationTool< LoadInstrument DILSwitch[BoundX="83",BoundY="106",Port="0x0001"] -VisualizationTool< ResetVT Undo -bckcolor 50331647 -font 'Courier New' 9 BLACK -AUTOSIZE on -ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Procedure" "Source" "VisualizationTool" diff --git a/cmpen472hw2McDonnell/Default.mem b/cmpen472hw2McDonnell/Default.mem deleted file mode 100644 index bf49148..0000000 Binary files a/cmpen472hw2McDonnell/Default.mem and /dev/null differ diff --git a/cmpen472hw2McDonnell/Full_Chip_Simulation.hwc b/cmpen472hw2McDonnell/Full_Chip_Simulation.hwc deleted file mode 100644 index ae80da7..0000000 --- a/cmpen472hw2McDonnell/Full_Chip_Simulation.hwc +++ /dev/null @@ -1 +0,0 @@ -LOADMEM default.mem diff --git a/cmpen472hw2McDonnell/Full_Chip_Simulation.ini b/cmpen472hw2McDonnell/Full_Chip_Simulation.ini deleted file mode 100644 index e9f86a0..0000000 --- a/cmpen472hw2McDonnell/Full_Chip_Simulation.ini +++ /dev/null @@ -1,49 +0,0 @@ -[Environment Variables] -GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib -LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include -OBJPATH={Project}bin -TEXTPATH={Project}bin -ABSPATH={Project}bin - -[HI-WAVE] -Target=sim -Layout=ASM_layout.hwl -LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD -CPU=HC12 -MainFrame=0,1,-1,-1,-1,-1,514,197,1729,1220 -Configuration=Full_Chip_Simulation.hwc -Statusbar=1 -ShowToolbar=1 -Smallborder=0 -Hideheadline=0 -Hidetitle=0 -TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 - - - - - - - - - -[Simulator] -CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" - -[Simulator HC12] -CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" -CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" -CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" -CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" -HCS12_SUPPORT=1 -FCS=MC9S12C32 -ZEROTIMEATRESET=1 -OSCFREQUENCY=48000000 -DISPLAYTIME=0 - - -[Recent Layout File List] -File0=ASM_layout.hwl -File1= -File2= -File3= diff --git a/cmpen472hw2McDonnell/Sources/cmpen472hw2_McDonnell.asm b/cmpen472hw2McDonnell/Sources/cmpen472hw2_McDonnell.asm deleted file mode 100644 index 3652de5..0000000 --- a/cmpen472hw2McDonnell/Sources/cmpen472hw2_McDonnell.asm +++ /dev/null @@ -1,202 +0,0 @@ -************************************************************************** -* -* Title: LED Light Blinking -* -* Objective: CMPEN 472 Homework 2 in-class-room demonstration -* program -* -* Revision: V1.0 -* -* Date: Jan. 29, 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,Y: Delay and loop counters -* -* 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 that blinks LEDs and blinking period can -* be changed with the delay loop counter value. When switch 1 -* is not pressed, LEDs 1 and 4 will blink alternately for 1 -* second each. When switch 1 is pressed LEDs 1, 2, 3, & 4 will -* all turn on at the same time for 1 second and turn off at the -* same time for 1 second. -* -* Note: All Homework programs MUST have comments similar -* to this Homework 2 program. So, please use those -* comment format for all your subsequent CMPEN472 -* Homework programs. -* -* Adding more explanations and comments help you and -* others to understnad your program later. -* -* 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 - -* Symbols and Macros -PORTA equ $0000 ; i/o port A addresses -DDRA equ $0002 ; data direction register for PORTA -PORTB equ $0001 ; i/o port B addresses -DDRB equ $0003 ; data direction register for PORTB - -************************************************************************** -* Data Section: address used [ $3000 to $30FF ] RAM Memory -* - org $3000 ; Reserved RAM memory starting address - ; for Data for CMPEN 472 class -Counter1 dc.w $0100 ; X register count number for time Delay - ; inner loop for msec -Counter2 dc.w $00BF ; Y register count number for time delay - ; output loop for sec -* -************************************************************************** -* Program Section: address used [ $3100 to $3FFF ] RAM Memory -* - org $3100 ; Program start address, in RAM -pgstart lds #$3100 ; initialize the stack pointer - - ldaa #%11111111 ; LED 1, 2, 3, 4 at PORTB bit 4, 5, 6, 7 FOR CSM-12C128 board - staa DDRB ; set PORTB bit 4, 5, 6, 7 as Output - - ldaa #%00000000 - staa PORTB ; Turn off LED 1, 2, 3, 4 (all bits in PORTB, for simulation - -mainLoop - ldaa PORTB - anda #%00000001 ; Read switch 1 at PORTB bit 0 - bne sw1pushed ; check to see if it is pushed - -sw1notpsh jsr alternate ; Jump to the alternate subroutine to alternate LED 1 and 4 - bra mainLoop ; loop back to the beginning to check the switch - -sw1pushed jsr allBlink ; Jump to the allBlink subroutine to blink all lights - bra mainLoop ; loop back to the beginning to check the switch - -************************************************************************** -* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory -* - -;************************************************************************* -; 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 -; -; This subroutine causes a few msec. Delay -; -; Input: a 16bit count number in 'Counter1' -; 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. -; - -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 - -;************************************************************************* -; alternate subroutine -; -; This subroutine will alternately blink LEDs 1 anf 4 for 1 second each. -; -; Input: No input all values are hardcoded -; Output: LEDs 1 and 4 blinking alternately -; Registers in use: No registers are used -; Memory locations in use: A one byte memory location associated with PORTB ($0001) -; -; Comments: This subroutine requires delay1sec subroutine. -; - -alternate - bset PORTB,%10000000 ; Turn ON LED 4 at PORTB bit 7 - bclr PORTB,%00010000 ; Turn off LED 1 at PORTB bit 4 - jsr delay1sec ; Wait for 1 second - - bclr PORTB,%10000000 ; Turn off LED 4 at PORTB bit 7 - bset PORTB,%00010000 ; Turn on LED 1 at PORTB bit 4 - jsr delay1sec ; Wait for 1 second - rts ; Return to the caller - -;************************************************************************* -; allBlink subroutine -; -; This subroutine will blink LEDs 1, 2, 3, & 4 on for 1 second and off for -; 1 second all at the same time. -; -; Input: No input all values are hardcoded -; Output: LEDs 1, 2, 3, & 4 blinking on and off at the -; same time for 1 second -; Registers in use: No registers are used -; Memory locations in use: A one byte memory location associated with PORTB ($0001) -; -; Comments: This subroutine requires delay1sec subroutine. -; - -allBlink - bset PORTB,%11110000 ; Turn ON all 4 LEDs - jsr delay1sec ; Wait for 1 second - - bclr PORTB,%11110000 ; Turn off all 4 LEDs - jsr delay1sec ; Wait for 1 second - rts ; Return to the caller - -* -* Add any subroutines here -* - end ; last line of the file \ No newline at end of file diff --git a/cmpen472hw2McDonnell/Sources/derivative.inc b/cmpen472hw2McDonnell/Sources/derivative.inc deleted file mode 100644 index 9320da5..0000000 --- a/cmpen472hw2McDonnell/Sources/derivative.inc +++ /dev/null @@ -1,10 +0,0 @@ - - ; Note: This file is recreated by the project wizard whenever the MCU is - ; changed and should not be edited by hand - ; - - ; include derivative specific macros - INCLUDE 'mc9s12c32.inc' - - - diff --git a/cmpen472hw2McDonnell/Sources/main.asm b/cmpen472hw2McDonnell/Sources/main.asm deleted file mode 100644 index 3652de5..0000000 --- a/cmpen472hw2McDonnell/Sources/main.asm +++ /dev/null @@ -1,202 +0,0 @@ -************************************************************************** -* -* Title: LED Light Blinking -* -* Objective: CMPEN 472 Homework 2 in-class-room demonstration -* program -* -* Revision: V1.0 -* -* Date: Jan. 29, 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,Y: Delay and loop counters -* -* 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 that blinks LEDs and blinking period can -* be changed with the delay loop counter value. When switch 1 -* is not pressed, LEDs 1 and 4 will blink alternately for 1 -* second each. When switch 1 is pressed LEDs 1, 2, 3, & 4 will -* all turn on at the same time for 1 second and turn off at the -* same time for 1 second. -* -* Note: All Homework programs MUST have comments similar -* to this Homework 2 program. So, please use those -* comment format for all your subsequent CMPEN472 -* Homework programs. -* -* Adding more explanations and comments help you and -* others to understnad your program later. -* -* 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 - -* Symbols and Macros -PORTA equ $0000 ; i/o port A addresses -DDRA equ $0002 ; data direction register for PORTA -PORTB equ $0001 ; i/o port B addresses -DDRB equ $0003 ; data direction register for PORTB - -************************************************************************** -* Data Section: address used [ $3000 to $30FF ] RAM Memory -* - org $3000 ; Reserved RAM memory starting address - ; for Data for CMPEN 472 class -Counter1 dc.w $0100 ; X register count number for time Delay - ; inner loop for msec -Counter2 dc.w $00BF ; Y register count number for time delay - ; output loop for sec -* -************************************************************************** -* Program Section: address used [ $3100 to $3FFF ] RAM Memory -* - org $3100 ; Program start address, in RAM -pgstart lds #$3100 ; initialize the stack pointer - - ldaa #%11111111 ; LED 1, 2, 3, 4 at PORTB bit 4, 5, 6, 7 FOR CSM-12C128 board - staa DDRB ; set PORTB bit 4, 5, 6, 7 as Output - - ldaa #%00000000 - staa PORTB ; Turn off LED 1, 2, 3, 4 (all bits in PORTB, for simulation - -mainLoop - ldaa PORTB - anda #%00000001 ; Read switch 1 at PORTB bit 0 - bne sw1pushed ; check to see if it is pushed - -sw1notpsh jsr alternate ; Jump to the alternate subroutine to alternate LED 1 and 4 - bra mainLoop ; loop back to the beginning to check the switch - -sw1pushed jsr allBlink ; Jump to the allBlink subroutine to blink all lights - bra mainLoop ; loop back to the beginning to check the switch - -************************************************************************** -* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory -* - -;************************************************************************* -; 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 -; -; This subroutine causes a few msec. Delay -; -; Input: a 16bit count number in 'Counter1' -; 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. -; - -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 - -;************************************************************************* -; alternate subroutine -; -; This subroutine will alternately blink LEDs 1 anf 4 for 1 second each. -; -; Input: No input all values are hardcoded -; Output: LEDs 1 and 4 blinking alternately -; Registers in use: No registers are used -; Memory locations in use: A one byte memory location associated with PORTB ($0001) -; -; Comments: This subroutine requires delay1sec subroutine. -; - -alternate - bset PORTB,%10000000 ; Turn ON LED 4 at PORTB bit 7 - bclr PORTB,%00010000 ; Turn off LED 1 at PORTB bit 4 - jsr delay1sec ; Wait for 1 second - - bclr PORTB,%10000000 ; Turn off LED 4 at PORTB bit 7 - bset PORTB,%00010000 ; Turn on LED 1 at PORTB bit 4 - jsr delay1sec ; Wait for 1 second - rts ; Return to the caller - -;************************************************************************* -; allBlink subroutine -; -; This subroutine will blink LEDs 1, 2, 3, & 4 on for 1 second and off for -; 1 second all at the same time. -; -; Input: No input all values are hardcoded -; Output: LEDs 1, 2, 3, & 4 blinking on and off at the -; same time for 1 second -; Registers in use: No registers are used -; Memory locations in use: A one byte memory location associated with PORTB ($0001) -; -; Comments: This subroutine requires delay1sec subroutine. -; - -allBlink - bset PORTB,%11110000 ; Turn ON all 4 LEDs - jsr delay1sec ; Wait for 1 second - - bclr PORTB,%11110000 ; Turn off all 4 LEDs - jsr delay1sec ; Wait for 1 second - rts ; Return to the caller - -* -* Add any subroutines here -* - end ; last line of the file \ No newline at end of file diff --git a/cmpen472hw2McDonnell/bin/Project.abs b/cmpen472hw2McDonnell/bin/Project.abs deleted file mode 100644 index 2f19b93..0000000 Binary files a/cmpen472hw2McDonnell/bin/Project.abs and /dev/null differ diff --git a/cmpen472hw2McDonnell/bin/Project.abs.phy b/cmpen472hw2McDonnell/bin/Project.abs.phy deleted file mode 100644 index 20072a5..0000000 --- a/cmpen472hw2McDonnell/bin/Project.abs.phy +++ /dev/null @@ -1,2 +0,0 @@ -S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877324D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AE -S9030000FC diff --git a/cmpen472hw2McDonnell/bin/Project.abs.s19 b/cmpen472hw2McDonnell/bin/Project.abs.s19 deleted file mode 100644 index d70bfa2..0000000 --- a/cmpen472hw2McDonnell/bin/Project.abs.s19 +++ /dev/null @@ -1,6 +0,0 @@ -S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877324D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AE -S1073000010000BF08 -S1233100CF310086FF5A0386005A0196018401260516311B20F516312E20F04C01804D018A -S12331201016313B4D01804C011016313B3D4C01F016313B4D01F016313B3D35FD300216D9 -S114314031470326FA313D34FE3000A70926FC303DD0 -S9030000FC diff --git a/cmpen472hw2McDonnell/bin/main.dbg b/cmpen472hw2McDonnell/bin/main.dbg deleted file mode 100644 index 9b504c7..0000000 --- a/cmpen472hw2McDonnell/bin/main.dbg +++ /dev/null @@ -1,169 +0,0 @@ -************************************************************************** -* -* Title: LED Light Blinking -* -* Objective: CMPEN 472 Homework 2 in-class-room demonstration -* program -* -* Revision: V1.0 -* -* Date: Jan. 29, 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,Y: Delay and loop counters -* -* 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 that blinks LEDs and blinking period can -* be changed with the delay loop counter value. -* -* Note: All Homework programs MUST have comments similar -* to this Homework 2 program. So, please use those -* comment format for all your subsequent CMPEN472 -* Homework programs. -* -* Adding more explanations and comments help you and -* others to understnad your program later. -* -* 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 - -* Symbols and Macros -PORTA equ $0000 ; i/o port A addresses -DDRA equ $0002 ; data direction register for PORTA -PORTB equ $0001 ; i/o port B addresses -DDRB equ $0003 ; data direction register for PORTB - -************************************************************************** -* Data Section: address used [ $3000 to $30FF ] RAM Memory -* - org $3000 ; Reserved RAM memory starting address - ; for Data for CMPEN 472 class -Counter1 dc.w $0100 ; X register count number for time Delay - ; inner loop for msec -Counter2 dc.w $00BF ; Y register count number for time delay - ; output loop for sec -* -************************************************************************** -* Program Section: address used [ $3100 to $3FFF ] RAM Memory -* - org $3100 ; Program start address, in RAM -pgstart lds #$3100 ; initialize the stack pointer - - ldaa #%11111111 ; LED 1, 2, 3, 4 at PORTB bit 4, 5, 6, 7 FOR CSM-12C128 board - staa DDRB ; set PORTB bit 4, 5, 6, 7 as Output - - ldaa #%00000000 - staa PORTB ; Turn off LED 1, 2, 3, 4 (all bits in PORTB, for simulation - -mainLoop - ldaa PORTB - anda #%00000001 ; Read switch 1 at PORTB bit 0 - bne sw1pushed ; check to see if it is pushed - -sw1notpsh jsr alternate ; Jump to the alternate subroutine to alternate LED 1 and 4 - bra mainLoop ; loop back to the beginning to check the switch - -sw1pushed jsr allBlink ; Jump to the allBlink subroutine to blink all lights - bra mainLoop ; loop back to the beginning to check the switch - -************************************************************************** -* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory -* - -alternate - bset PORTB,%10000000 ; Turn ON LED 4 at PORTB bit 7 - bclr PORTB,%00010000 ; Turn off LED 1 at PORTB bit 4 - jsr delay1sec ; Wait for 1 second - - bclr PORTB,%10000000 ; Turn off LED 4 at PORTB bit 7 - bset PORTB,%00010000 ; Turn on LED 1 at PORTB bit 4 - jsr delay1sec ; Wait for 1 second - rts ; Return to the caller - -allBlink - bset PORTB,%11110000 ; Turn ON all 4 LEDs - jsr delay1sec ; Wait for 1 second - - bclr PORTB,%11110000 ; Turn off all 4 LEDs - jsr delay1sec ; Wait for 1 second - rts ; Return to the 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 -; -; This subroutine causes a few msec. Delay -; -; Input: a 16bit count number in 'Counter1' -; 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. -; - -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 - -* -* Add any subroutines here -* diff --git a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Postload.cmd b/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Postload.cmd deleted file mode 100644 index eb00f37..0000000 --- a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Postload.cmd +++ /dev/null @@ -1 +0,0 @@ -// After load the commands written below will be executed diff --git a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Preload.cmd b/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Preload.cmd deleted file mode 100644 index 691c5ee..0000000 --- a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Preload.cmd +++ /dev/null @@ -1 +0,0 @@ -// Before load the commands written below will be executed diff --git a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Reset.cmd b/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Reset.cmd deleted file mode 100644 index f0fc874..0000000 --- a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Reset.cmd +++ /dev/null @@ -1 +0,0 @@ -// After reset the commands written below will be executed diff --git a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd b/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd deleted file mode 100644 index 5f2b5a5..0000000 --- a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd +++ /dev/null @@ -1 +0,0 @@ -// At startup the commands written below will be executed diff --git a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Startup.cmd b/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Startup.cmd deleted file mode 100644 index 5f2b5a5..0000000 --- a/cmpen472hw2McDonnell/cmd/Full_Chip_Simulation_Startup.cmd +++ /dev/null @@ -1 +0,0 @@ -// At startup the commands written below will be executed diff --git a/cmpen472hw2McDonnell/cmpen472hw2McDonnell.mcp b/cmpen472hw2McDonnell/cmpen472hw2McDonnell.mcp deleted file mode 100644 index 9746eb7..0000000 Binary files a/cmpen472hw2McDonnell/cmpen472hw2McDonnell.mcp and /dev/null differ diff --git a/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/CWSettingsWindows.stg b/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/CWSettingsWindows.stg deleted file mode 100644 index c4b07f4..0000000 Binary files a/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/CWSettingsWindows.stg and /dev/null differ diff --git a/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.o deleted file mode 100644 index 2f19b93..0000000 Binary files a/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.o and /dev/null differ diff --git a/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.sx deleted file mode 100644 index 74843a2..0000000 --- a/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.sx +++ /dev/null @@ -1,6 +0,0 @@ -S0820000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877324D63446F6E6E656C6C5C636D70656E3437326877324D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726D95 -S1073000010000BF08 -S1233100CF310086FF5A0386005A0196018401260516311B20F516312E20F04C01804D018A -S12331201016313B4D01804C011016313B3D4C01F016313B4D01F016313B3D35FD300216D9 -S114314031470326FA313D34FE3000A70926FC303DD0 -S9033100CB diff --git a/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/TargetDataWindows.tdt deleted file mode 100644 index a3b4b88..0000000 Binary files a/cmpen472hw2McDonnell/cmpen472hw2McDonnell_Data/Standard/TargetDataWindows.tdt and /dev/null differ diff --git a/cmpen472hw2McDonnell/debuggerlayout.hwl b/cmpen472hw2McDonnell/debuggerlayout.hwl deleted file mode 100644 index 861b255..0000000 --- a/cmpen472hw2McDonnell/debuggerlayout.hwl +++ /dev/null @@ -1,26 +0,0 @@ -OPEN source 0 0 60 42 -Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off -OPEN assembly 60 0 40 30 -Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0x3138 -OPEN procedure 60 60 40 17 -Procedure < attributes VALUES on,TYPES off -OPEN register 60 30 40 30 -Register < attributes FORMAT AUTO,COMPLEMENT None -OPEN memory 60 77 40 23 -Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 -OPEN data 0 42 60 28 -Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 -OPEN command 0 70 60 30 -Command < attributes CACHESIZE 1000 -OPEN Visualizationtool 63 50 26 29 -VisualizationTool< Attributes [stEditM="0",swGridMode="1",swRefresh="3",refCycles="1"] -VisualizationTool< LoadInstrument LED[BoundX="102",BoundY="40",Port="0x0001",Port_PortEndian="1",swBIT="7"] -VisualizationTool< LoadInstrument LED[BoundX="133",BoundY="41",Port="0x0001",Port_PortEndian="1",swBIT="6"] -VisualizationTool< LoadInstrument LED[BoundX="166",BoundY="37",Port="0x0001",Port_PortEndian="1",swBIT="5"] -VisualizationTool< LoadInstrument LED[BoundX="202",BoundY="42",Port="0x0001",Port_PortEndian="1",swBIT="4"] -VisualizationTool< LoadInstrument DILSwitch[BoundX="83",BoundY="106",Port="0x0001"] -VisualizationTool< ResetVT Undo -bckcolor 50331647 -font 'Courier New' 9 BLACK -AUTOSIZE on -ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Procedure" "Source" "VisualizationTool" diff --git a/cmpen472hw2McDonnell/debuggerlayout.ini b/cmpen472hw2McDonnell/debuggerlayout.ini deleted file mode 100644 index 5f6d141..0000000 --- a/cmpen472hw2McDonnell/debuggerlayout.ini +++ /dev/null @@ -1,42 +0,0 @@ -[Environment Variables] -GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib -LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include -OBJPATH={Project}bin -TEXTPATH={Project}bin -ABSPATH={Project}bin - -[HI-WAVE] -Target=sim -Layout=debuggerlayout.hwl -LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD -CPU=HC12 -MainFrame=0,1,-1,-1,-1,-1,1302,254,2517,1277 -Configuration=Full_Chip_Simulation.hwc -Statusbar=1 -ShowToolbar=1 -Smallborder=0 -Hideheadline=0 -Hidetitle=0 -TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 - - - - - - - - - -[Simulator] -CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" - -[Simulator HC12] -CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" -CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" -CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" -CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" -HCS12_SUPPORT=1 -FCS=MC9S12C32 -ZEROTIMEATRESET=1 -OSCFREQUENCY=48000000 -DISPLAYTIME=0 diff --git a/cmpen472hw2McDonnell/prm/burner.bbl b/cmpen472hw2McDonnell/prm/burner.bbl deleted file mode 100644 index 42c21ed..0000000 --- a/cmpen472hw2McDonnell/prm/burner.bbl +++ /dev/null @@ -1,157 +0,0 @@ -/* logical s-record file */ -OPENFILE "%ABS_FILE%.s19" -format=motorola -busWidth=1 -origin=0 -len=0x1000000 -destination=0 -SRECORD=Sx -SENDBYTE 1 "%ABS_FILE%" -CLOSE - - -/* physical s-record file */ -OPENFILE "%ABS_FILE%.phy" -format = motorola -busWidth = 1 -len = 0x4000 - -/* logical non banked flash at $4000 and $C000 to physical */ -origin = 0x004000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" - -origin = 0x00C000 -destination = 0x0FC000 -SENDBYTE 1 "%ABS_FILE%" - -/* physical FTS512K flash window to physical -origin = 0x008000 -destination = 0x080000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS256K parts flash window to physical -origin = 0x008000 -destination = 0x0C0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS128K parts flash window to physical -origin = 0x008000 -destination = 0x0E0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS64K parts flash window to physical -origin = 0x008000 -destination = 0x0F0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS32K parts flash window to physical -origin = 0x008000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* logical 512 kB banked flash to physical */ -origin = 0x208000 -destination = 0x080000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x218000 -destination = 0x084000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x228000 -destination = 0x088000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x238000 -destination = 0x08C000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x248000 -destination = 0x090000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x258000 -destination = 0x094000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x268000 -destination = 0x098000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x278000 -destination = 0x09C000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x288000 -destination = 0x0A0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x298000 -destination = 0x0A4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2A8000 -destination = 0x0A8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2B8000 -destination = 0x0AC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2C8000 -destination = 0x0B0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2D8000 -destination = 0x0B4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2E8000 -destination = 0x0B8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2F8000 -destination = 0x0BC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x308000 -destination = 0x0C0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x318000 -destination = 0x0C4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x328000 -destination = 0x0C8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x338000 -destination = 0x0CC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x348000 -destination = 0x0D0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x358000 -destination = 0x0D4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x368000 -destination = 0x0D8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x378000 -destination = 0x0DC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x388000 -destination = 0x0E0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x398000 -destination = 0x0E4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3A8000 -destination = 0x0E8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3B8000 -destination = 0x0EC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3C8000 -destination = 0x0F0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3D8000 -destination = 0x0F4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3E8000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3F8000 -destination = 0x0FC000 -SENDBYTE 1 "%ABS_FILE%" - -CLOSE - diff --git a/cmpen472hw2_McDonnell/ASM_layout.hwl b/cmpen472hw2_McDonnell/ASM_layout.hwl new file mode 100644 index 0000000..3516c73 --- /dev/null +++ b/cmpen472hw2_McDonnell/ASM_layout.hwl @@ -0,0 +1,26 @@ +OPEN source 0 0 60 42 +Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off +OPEN assembly 60 0 40 30 +Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0xCBCB +OPEN procedure 60 60 40 17 +Procedure < attributes VALUES on,TYPES off +OPEN register 60 30 40 30 +Register < attributes FORMAT AUTO,COMPLEMENT None +OPEN memory 60 77 40 23 +Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 +OPEN data 0 42 60 28 +Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 +OPEN command 0 70 60 30 +Command < attributes CACHESIZE 1000 +OPEN Visualizationtool 63 50 26 29 +VisualizationTool< Attributes [stEditM="0",swGridMode="1",swRefresh="3",refCycles="1"] +VisualizationTool< LoadInstrument LED[BoundX="102",BoundY="40",Port="0x0001",Port_PortEndian="1",swBIT="7"] +VisualizationTool< LoadInstrument LED[BoundX="133",BoundY="41",Port="0x0001",Port_PortEndian="1",swBIT="6"] +VisualizationTool< LoadInstrument LED[BoundX="166",BoundY="37",Port="0x0001",Port_PortEndian="1",swBIT="5"] +VisualizationTool< LoadInstrument LED[BoundX="202",BoundY="42",Port="0x0001",Port_PortEndian="1",swBIT="4"] +VisualizationTool< LoadInstrument DILSwitch[BoundX="83",BoundY="106",Port="0x0001"] +VisualizationTool< ResetVT Undo +bckcolor 50331647 +font 'Courier New' 9 BLACK +AUTOSIZE on +ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Procedure" "Source" "VisualizationTool" diff --git a/cmpen472hw2_McDonnell/Default.mem b/cmpen472hw2_McDonnell/Default.mem new file mode 100644 index 0000000..bf49148 Binary files /dev/null and b/cmpen472hw2_McDonnell/Default.mem differ diff --git a/cmpen472hw2_McDonnell/Full_Chip_Simulation.hwc b/cmpen472hw2_McDonnell/Full_Chip_Simulation.hwc new file mode 100644 index 0000000..f3ce7c9 --- /dev/null +++ b/cmpen472hw2_McDonnell/Full_Chip_Simulation.hwc @@ -0,0 +1 @@ +LOADMEM default.mem diff --git a/cmpen472hw2_McDonnell/Full_Chip_Simulation.ini b/cmpen472hw2_McDonnell/Full_Chip_Simulation.ini new file mode 100644 index 0000000..fafa17e --- /dev/null +++ b/cmpen472hw2_McDonnell/Full_Chip_Simulation.ini @@ -0,0 +1,49 @@ +[Environment Variables] +GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib +LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include +OBJPATH={Project}bin +TEXTPATH={Project}bin +ABSPATH={Project}bin + +[HI-WAVE] +Target=sim +Layout=ASM_layout.hwl +LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD +CPU=HC12 +MainFrame=0,1,-1,-1,-1,-1,514,197,1729,1220 +Configuration=Full_Chip_Simulation.hwc +Statusbar=1 +ShowToolbar=1 +Smallborder=0 +Hideheadline=0 +Hidetitle=0 +TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 + + + + + + + + + +[Simulator] +CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" + +[Simulator HC12] +CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" +CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" +CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" +CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" +HCS12_SUPPORT=1 +FCS=MC9S12C32 +ZEROTIMEATRESET=1 +OSCFREQUENCY=48000000 +DISPLAYTIME=0 + + +[Recent Layout File List] +File0=ASM_layout.hwl +File1= +File2= +File3= diff --git a/cmpen472hw2_McDonnell/Sources/cmpen472hw2_McDonnell.asm b/cmpen472hw2_McDonnell/Sources/cmpen472hw2_McDonnell.asm new file mode 100644 index 0000000..7c5eced --- /dev/null +++ b/cmpen472hw2_McDonnell/Sources/cmpen472hw2_McDonnell.asm @@ -0,0 +1,202 @@ +************************************************************************** +* +* Title: LED Light Blinking +* +* Objective: CMPEN 472 Homework 2 in-class-room demonstration +* program +* +* Revision: V1.0 +* +* Date: Jan. 29, 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,Y: Delay and loop counters +* +* 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 that blinks LEDs and blinking period can +* be changed with the delay loop counter value. When switch 1 +* is not pressed, LEDs 1 and 4 will blink alternately for 1 +* second each. When switch 1 is pressed LEDs 1, 2, 3, & 4 will +* all turn on at the same time for 1 second and turn off at the +* same time for 1 second. +* +* Note: All Homework programs MUST have comments similar +* to this Homework 2 program. So, please use those +* comment format for all your subsequent CMPEN472 +* Homework programs. +* +* Adding more explanations and comments help you and +* others to understnad your program later. +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +Counter1 dc.w $0100 ; X register count number for time Delay + ; inner loop for msec +Counter2 dc.w $00BF ; Y register count number for time delay + ; output loop for sec +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +pgstart lds #$3100 ; initialize the stack pointer + + ldaa #%11111111 ; LED 1, 2, 3, 4 at PORTB bit 4, 5, 6, 7 FOR CSM-12C128 board + staa DDRB ; set PORTB bit 4, 5, 6, 7 as Output + + ldaa #%00000000 + staa PORTB ; Turn off LED 1, 2, 3, 4 (all bits in PORTB, for simulation + +mainLoop + ldaa PORTB + anda #%00000001 ; Read switch 1 at PORTB bit 0 + bne sw1pushed ; check to see if it is pushed + +sw1notpsh jsr alternate ; Jump to the alternate subroutine to alternate LED 1 and 4 + bra mainLoop ; loop back to the beginning to check the switch + +sw1pushed jsr allBlink ; Jump to the allBlink subroutine to blink all lights + bra mainLoop ; loop back to the beginning to check the switch + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +;************************************************************************* +; 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 +; +; This subroutine causes a few msec. Delay +; +; Input: a 16bit count number in 'Counter1' +; 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. +; + +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 + +;************************************************************************* +; alternate subroutine +; +; This subroutine will alternately blink LEDs 1 anf 4 for 1 second each. +; +; Input: No input all values are hardcoded +; Output: LEDs 1 and 4 blinking alternately +; Registers in use: No registers are used +; Memory locations in use: A one byte memory location associated with PORTB ($0001) +; +; Comments: This subroutine requires delay1sec subroutine. +; + +alternate + bset PORTB,%10000000 ; Turn ON LED 4 at PORTB bit 7 + bclr PORTB,%00010000 ; Turn off LED 1 at PORTB bit 4 + jsr delay1sec ; Wait for 1 second + + bclr PORTB,%10000000 ; Turn off LED 4 at PORTB bit 7 + bset PORTB,%00010000 ; Turn on LED 1 at PORTB bit 4 + jsr delay1sec ; Wait for 1 second + rts ; Return to the caller + +;************************************************************************* +; allBlink subroutine +; +; This subroutine will blink LEDs 1, 2, 3, & 4 on for 1 second and off for +; 1 second all at the same time. +; +; Input: No input all values are hardcoded +; Output: LEDs 1, 2, 3, & 4 blinking on and off at the +; same time for 1 second +; Registers in use: No registers are used +; Memory locations in use: A one byte memory location associated with PORTB ($0001) +; +; Comments: This subroutine requires delay1sec subroutine. +; + +allBlink + bset PORTB,%11110000 ; Turn ON all 4 LEDs + jsr delay1sec ; Wait for 1 second + + bclr PORTB,%11110000 ; Turn off all 4 LEDs + jsr delay1sec ; Wait for 1 second + rts ; Return to the caller + +* +* Add any subroutines here +* + end ; last line of the file \ No newline at end of file diff --git a/cmpen472hw2_McDonnell/Sources/derivative.inc b/cmpen472hw2_McDonnell/Sources/derivative.inc new file mode 100644 index 0000000..988343b --- /dev/null +++ b/cmpen472hw2_McDonnell/Sources/derivative.inc @@ -0,0 +1,10 @@ + + ; Note: This file is recreated by the project wizard whenever the MCU is + ; changed and should not be edited by hand + ; + + ; include derivative specific macros + INCLUDE 'mc9s12c32.inc' + + + diff --git a/cmpen472hw2_McDonnell/Sources/main.asm b/cmpen472hw2_McDonnell/Sources/main.asm new file mode 100644 index 0000000..7c5eced --- /dev/null +++ b/cmpen472hw2_McDonnell/Sources/main.asm @@ -0,0 +1,202 @@ +************************************************************************** +* +* Title: LED Light Blinking +* +* Objective: CMPEN 472 Homework 2 in-class-room demonstration +* program +* +* Revision: V1.0 +* +* Date: Jan. 29, 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,Y: Delay and loop counters +* +* 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 that blinks LEDs and blinking period can +* be changed with the delay loop counter value. When switch 1 +* is not pressed, LEDs 1 and 4 will blink alternately for 1 +* second each. When switch 1 is pressed LEDs 1, 2, 3, & 4 will +* all turn on at the same time for 1 second and turn off at the +* same time for 1 second. +* +* Note: All Homework programs MUST have comments similar +* to this Homework 2 program. So, please use those +* comment format for all your subsequent CMPEN472 +* Homework programs. +* +* Adding more explanations and comments help you and +* others to understnad your program later. +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +Counter1 dc.w $0100 ; X register count number for time Delay + ; inner loop for msec +Counter2 dc.w $00BF ; Y register count number for time delay + ; output loop for sec +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +pgstart lds #$3100 ; initialize the stack pointer + + ldaa #%11111111 ; LED 1, 2, 3, 4 at PORTB bit 4, 5, 6, 7 FOR CSM-12C128 board + staa DDRB ; set PORTB bit 4, 5, 6, 7 as Output + + ldaa #%00000000 + staa PORTB ; Turn off LED 1, 2, 3, 4 (all bits in PORTB, for simulation + +mainLoop + ldaa PORTB + anda #%00000001 ; Read switch 1 at PORTB bit 0 + bne sw1pushed ; check to see if it is pushed + +sw1notpsh jsr alternate ; Jump to the alternate subroutine to alternate LED 1 and 4 + bra mainLoop ; loop back to the beginning to check the switch + +sw1pushed jsr allBlink ; Jump to the allBlink subroutine to blink all lights + bra mainLoop ; loop back to the beginning to check the switch + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +;************************************************************************* +; 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 +; +; This subroutine causes a few msec. Delay +; +; Input: a 16bit count number in 'Counter1' +; 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. +; + +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 + +;************************************************************************* +; alternate subroutine +; +; This subroutine will alternately blink LEDs 1 anf 4 for 1 second each. +; +; Input: No input all values are hardcoded +; Output: LEDs 1 and 4 blinking alternately +; Registers in use: No registers are used +; Memory locations in use: A one byte memory location associated with PORTB ($0001) +; +; Comments: This subroutine requires delay1sec subroutine. +; + +alternate + bset PORTB,%10000000 ; Turn ON LED 4 at PORTB bit 7 + bclr PORTB,%00010000 ; Turn off LED 1 at PORTB bit 4 + jsr delay1sec ; Wait for 1 second + + bclr PORTB,%10000000 ; Turn off LED 4 at PORTB bit 7 + bset PORTB,%00010000 ; Turn on LED 1 at PORTB bit 4 + jsr delay1sec ; Wait for 1 second + rts ; Return to the caller + +;************************************************************************* +; allBlink subroutine +; +; This subroutine will blink LEDs 1, 2, 3, & 4 on for 1 second and off for +; 1 second all at the same time. +; +; Input: No input all values are hardcoded +; Output: LEDs 1, 2, 3, & 4 blinking on and off at the +; same time for 1 second +; Registers in use: No registers are used +; Memory locations in use: A one byte memory location associated with PORTB ($0001) +; +; Comments: This subroutine requires delay1sec subroutine. +; + +allBlink + bset PORTB,%11110000 ; Turn ON all 4 LEDs + jsr delay1sec ; Wait for 1 second + + bclr PORTB,%11110000 ; Turn off all 4 LEDs + jsr delay1sec ; Wait for 1 second + rts ; Return to the caller + +* +* Add any subroutines here +* + end ; last line of the file \ No newline at end of file diff --git a/cmpen472hw2_McDonnell/bin/Project.abs b/cmpen472hw2_McDonnell/bin/Project.abs new file mode 100644 index 0000000..2f19b93 Binary files /dev/null and b/cmpen472hw2_McDonnell/bin/Project.abs differ diff --git a/cmpen472hw2_McDonnell/bin/Project.abs.phy b/cmpen472hw2_McDonnell/bin/Project.abs.phy new file mode 100644 index 0000000..9f77331 --- /dev/null +++ b/cmpen472hw2_McDonnell/bin/Project.abs.phy @@ -0,0 +1,2 @@ +S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877324D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AE +S9030000FC diff --git a/cmpen472hw2_McDonnell/bin/Project.abs.s19 b/cmpen472hw2_McDonnell/bin/Project.abs.s19 new file mode 100644 index 0000000..1c45a26 --- /dev/null +++ b/cmpen472hw2_McDonnell/bin/Project.abs.s19 @@ -0,0 +1,6 @@ +S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877324D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AE +S1073000010000BF08 +S1233100CF310086FF5A0386005A0196018401260516311B20F516312E20F04C01804D018A +S12331201016313B4D01804C011016313B3D4C01F016313B4D01F016313B3D35FD300216D9 +S114314031470326FA313D34FE3000A70926FC303DD0 +S9030000FC diff --git a/cmpen472hw2_McDonnell/bin/main.dbg b/cmpen472hw2_McDonnell/bin/main.dbg new file mode 100644 index 0000000..0560731 --- /dev/null +++ b/cmpen472hw2_McDonnell/bin/main.dbg @@ -0,0 +1,169 @@ +************************************************************************** +* +* Title: LED Light Blinking +* +* Objective: CMPEN 472 Homework 2 in-class-room demonstration +* program +* +* Revision: V1.0 +* +* Date: Jan. 29, 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,Y: Delay and loop counters +* +* 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 that blinks LEDs and blinking period can +* be changed with the delay loop counter value. +* +* Note: All Homework programs MUST have comments similar +* to this Homework 2 program. So, please use those +* comment format for all your subsequent CMPEN472 +* Homework programs. +* +* Adding more explanations and comments help you and +* others to understnad your program later. +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +Counter1 dc.w $0100 ; X register count number for time Delay + ; inner loop for msec +Counter2 dc.w $00BF ; Y register count number for time delay + ; output loop for sec +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +pgstart lds #$3100 ; initialize the stack pointer + + ldaa #%11111111 ; LED 1, 2, 3, 4 at PORTB bit 4, 5, 6, 7 FOR CSM-12C128 board + staa DDRB ; set PORTB bit 4, 5, 6, 7 as Output + + ldaa #%00000000 + staa PORTB ; Turn off LED 1, 2, 3, 4 (all bits in PORTB, for simulation + +mainLoop + ldaa PORTB + anda #%00000001 ; Read switch 1 at PORTB bit 0 + bne sw1pushed ; check to see if it is pushed + +sw1notpsh jsr alternate ; Jump to the alternate subroutine to alternate LED 1 and 4 + bra mainLoop ; loop back to the beginning to check the switch + +sw1pushed jsr allBlink ; Jump to the allBlink subroutine to blink all lights + bra mainLoop ; loop back to the beginning to check the switch + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +alternate + bset PORTB,%10000000 ; Turn ON LED 4 at PORTB bit 7 + bclr PORTB,%00010000 ; Turn off LED 1 at PORTB bit 4 + jsr delay1sec ; Wait for 1 second + + bclr PORTB,%10000000 ; Turn off LED 4 at PORTB bit 7 + bset PORTB,%00010000 ; Turn on LED 1 at PORTB bit 4 + jsr delay1sec ; Wait for 1 second + rts ; Return to the caller + +allBlink + bset PORTB,%11110000 ; Turn ON all 4 LEDs + jsr delay1sec ; Wait for 1 second + + bclr PORTB,%11110000 ; Turn off all 4 LEDs + jsr delay1sec ; Wait for 1 second + rts ; Return to the 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 +; +; This subroutine causes a few msec. Delay +; +; Input: a 16bit count number in 'Counter1' +; 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. +; + +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 + +* +* Add any subroutines here +* diff --git a/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd new file mode 100644 index 0000000..ac4d359 --- /dev/null +++ b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd @@ -0,0 +1 @@ +// After load the commands written below will be executed diff --git a/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd new file mode 100644 index 0000000..0bed464 --- /dev/null +++ b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd @@ -0,0 +1 @@ +// Before load the commands written below will be executed diff --git a/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd new file mode 100644 index 0000000..bf55944 --- /dev/null +++ b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd @@ -0,0 +1 @@ +// After reset the commands written below will be executed diff --git a/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw2_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw2_McDonnell/cmpen472hw2McDonnell.mcp b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell.mcp new file mode 100644 index 0000000..9746eb7 Binary files /dev/null and b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell.mcp differ diff --git a/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/CWSettingsWindows.stg b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/CWSettingsWindows.stg new file mode 100644 index 0000000..c4b07f4 Binary files /dev/null and b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/CWSettingsWindows.stg differ diff --git a/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.o new file mode 100644 index 0000000..2f19b93 Binary files /dev/null and b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.o differ diff --git a/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.sx new file mode 100644 index 0000000..6fe8671 --- /dev/null +++ b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/ObjectCode/main.asm.sx @@ -0,0 +1,6 @@ +S0820000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877324D63446F6E6E656C6C5C636D70656E3437326877324D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726D95 +S1073000010000BF08 +S1233100CF310086FF5A0386005A0196018401260516311B20F516312E20F04C01804D018A +S12331201016313B4D01804C011016313B3D4C01F016313B4D01F016313B3D35FD300216D9 +S114314031470326FA313D34FE3000A70926FC303DD0 +S9033100CB diff --git a/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/TargetDataWindows.tdt new file mode 100644 index 0000000..a3b4b88 Binary files /dev/null and b/cmpen472hw2_McDonnell/cmpen472hw2McDonnell_Data/Standard/TargetDataWindows.tdt differ diff --git a/cmpen472hw2_McDonnell/debuggerlayout.hwl b/cmpen472hw2_McDonnell/debuggerlayout.hwl new file mode 100644 index 0000000..2a5dc26 --- /dev/null +++ b/cmpen472hw2_McDonnell/debuggerlayout.hwl @@ -0,0 +1,26 @@ +OPEN source 0 0 60 42 +Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off +OPEN assembly 60 0 40 30 +Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0x3138 +OPEN procedure 60 60 40 17 +Procedure < attributes VALUES on,TYPES off +OPEN register 60 30 40 30 +Register < attributes FORMAT AUTO,COMPLEMENT None +OPEN memory 60 77 40 23 +Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 +OPEN data 0 42 60 28 +Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 +OPEN command 0 70 60 30 +Command < attributes CACHESIZE 1000 +OPEN Visualizationtool 63 50 26 29 +VisualizationTool< Attributes [stEditM="0",swGridMode="1",swRefresh="3",refCycles="1"] +VisualizationTool< LoadInstrument LED[BoundX="102",BoundY="40",Port="0x0001",Port_PortEndian="1",swBIT="7"] +VisualizationTool< LoadInstrument LED[BoundX="133",BoundY="41",Port="0x0001",Port_PortEndian="1",swBIT="6"] +VisualizationTool< LoadInstrument LED[BoundX="166",BoundY="37",Port="0x0001",Port_PortEndian="1",swBIT="5"] +VisualizationTool< LoadInstrument LED[BoundX="202",BoundY="42",Port="0x0001",Port_PortEndian="1",swBIT="4"] +VisualizationTool< LoadInstrument DILSwitch[BoundX="83",BoundY="106",Port="0x0001"] +VisualizationTool< ResetVT Undo +bckcolor 50331647 +font 'Courier New' 9 BLACK +AUTOSIZE on +ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Procedure" "Source" "VisualizationTool" diff --git a/cmpen472hw2_McDonnell/debuggerlayout.ini b/cmpen472hw2_McDonnell/debuggerlayout.ini new file mode 100644 index 0000000..1ebd014 --- /dev/null +++ b/cmpen472hw2_McDonnell/debuggerlayout.ini @@ -0,0 +1,42 @@ +[Environment Variables] +GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib +LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include +OBJPATH={Project}bin +TEXTPATH={Project}bin +ABSPATH={Project}bin + +[HI-WAVE] +Target=sim +Layout=debuggerlayout.hwl +LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD +CPU=HC12 +MainFrame=0,1,-1,-1,-1,-1,1302,254,2517,1277 +Configuration=Full_Chip_Simulation.hwc +Statusbar=1 +ShowToolbar=1 +Smallborder=0 +Hideheadline=0 +Hidetitle=0 +TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 + + + + + + + + + +[Simulator] +CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" + +[Simulator HC12] +CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" +CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" +CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" +CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" +HCS12_SUPPORT=1 +FCS=MC9S12C32 +ZEROTIMEATRESET=1 +OSCFREQUENCY=48000000 +DISPLAYTIME=0 diff --git a/cmpen472hw2_McDonnell/prm/burner.bbl b/cmpen472hw2_McDonnell/prm/burner.bbl new file mode 100644 index 0000000..0c57619 --- /dev/null +++ b/cmpen472hw2_McDonnell/prm/burner.bbl @@ -0,0 +1,157 @@ +/* logical s-record file */ +OPENFILE "%ABS_FILE%.s19" +format=motorola +busWidth=1 +origin=0 +len=0x1000000 +destination=0 +SRECORD=Sx +SENDBYTE 1 "%ABS_FILE%" +CLOSE + + +/* physical s-record file */ +OPENFILE "%ABS_FILE%.phy" +format = motorola +busWidth = 1 +len = 0x4000 + +/* logical non banked flash at $4000 and $C000 to physical */ +origin = 0x004000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" + +origin = 0x00C000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +/* physical FTS512K flash window to physical +origin = 0x008000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS256K parts flash window to physical +origin = 0x008000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS128K parts flash window to physical +origin = 0x008000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS64K parts flash window to physical +origin = 0x008000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS32K parts flash window to physical +origin = 0x008000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* logical 512 kB banked flash to physical */ +origin = 0x208000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x218000 +destination = 0x084000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x228000 +destination = 0x088000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x238000 +destination = 0x08C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x248000 +destination = 0x090000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x258000 +destination = 0x094000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x268000 +destination = 0x098000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x278000 +destination = 0x09C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x288000 +destination = 0x0A0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x298000 +destination = 0x0A4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2A8000 +destination = 0x0A8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2B8000 +destination = 0x0AC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2C8000 +destination = 0x0B0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2D8000 +destination = 0x0B4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2E8000 +destination = 0x0B8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2F8000 +destination = 0x0BC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x308000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x318000 +destination = 0x0C4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x328000 +destination = 0x0C8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x338000 +destination = 0x0CC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x348000 +destination = 0x0D0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x358000 +destination = 0x0D4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x368000 +destination = 0x0D8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x378000 +destination = 0x0DC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x388000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x398000 +destination = 0x0E4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3A8000 +destination = 0x0E8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3B8000 +destination = 0x0EC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3C8000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3D8000 +destination = 0x0F4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3E8000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3F8000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +CLOSE + diff --git a/cmpen472hw3McDonnell/ASM_layout.hwl b/cmpen472hw3McDonnell/ASM_layout.hwl deleted file mode 100644 index 3600632..0000000 --- a/cmpen472hw3McDonnell/ASM_layout.hwl +++ /dev/null @@ -1,18 +0,0 @@ -OPEN source 0 0 60 42 -Source < attributes MARKS off -OPEN assembly 60 0 40 30 -Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,TOPPC 0xF800 -OPEN procedure 60 60 40 17 -Procedure < attributes VALUES on,TYPES off -OPEN register 60 30 40 30 -Register < attributes FORMAT AUTO,COMPLEMENT None -OPEN memory 60 77 40 23 -Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,ADDRESS 0x80 -OPEN data 0 42 60 28 -Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,UPDATERATE 10,NAMEWIDTH 16 -OPEN command 0 70 60 30 -Command < attributes CACHESIZE 1000 -bckcolor 50331647 -font 'Courier New' 9 BLACK -AUTOSIZE on -ACTIVATE Assembly Memory Register Command Data Source Procedure diff --git a/cmpen472hw3McDonnell/Default.mem b/cmpen472hw3McDonnell/Default.mem deleted file mode 100644 index bf49148..0000000 Binary files a/cmpen472hw3McDonnell/Default.mem and /dev/null differ diff --git a/cmpen472hw3McDonnell/Full_Chip_Simulation.hwc b/cmpen472hw3McDonnell/Full_Chip_Simulation.hwc deleted file mode 100644 index ae80da7..0000000 --- a/cmpen472hw3McDonnell/Full_Chip_Simulation.hwc +++ /dev/null @@ -1 +0,0 @@ -LOADMEM default.mem diff --git a/cmpen472hw3McDonnell/Full_Chip_Simulation.hwl b/cmpen472hw3McDonnell/Full_Chip_Simulation.hwl deleted file mode 100644 index 0e6a666..0000000 --- a/cmpen472hw3McDonnell/Full_Chip_Simulation.hwl +++ /dev/null @@ -1,26 +0,0 @@ -OPEN source 0 0 60 42 -Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off -OPEN assembly 60 0 40 30 -Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0xCBCB -OPEN procedure 60 60 40 17 -Procedure < attributes VALUES on,TYPES off -OPEN register 60 30 40 30 -Register < attributes FORMAT AUTO,COMPLEMENT None -OPEN memory 60 77 40 23 -Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 -OPEN data 0 42 60 28 -Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 -OPEN command 0 70 60 30 -Command < attributes CACHESIZE 1000 -OPEN Visualizationtool 63 50 26 29 -VisualizationTool< Attributes [stEditM="0",swGridMode="1",swRefresh="3",refCycles="1"] -VisualizationTool< LoadInstrument LED[BoundX="102",BoundY="40",Port="0x0001",Port_PortEndian="1",swBIT="7"] -VisualizationTool< LoadInstrument LED[BoundX="133",BoundY="41",Port="0x0001",Port_PortEndian="1",swBIT="6"] -VisualizationTool< LoadInstrument LED[BoundX="166",BoundY="37",Port="0x0001",Port_PortEndian="1",swBIT="5"] -VisualizationTool< LoadInstrument LED[BoundX="202",BoundY="42",Port="0x0001",Port_PortEndian="1",swBIT="4"] -VisualizationTool< LoadInstrument DILSwitch[BoundX="83",BoundY="106",Port="0x0001"] -VisualizationTool< ResetVT Undo -bckcolor 50331647 -font 'Courier New' 9 BLACK -AUTOSIZE on -ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Procedure" "Source" "VisualizationTool" diff --git a/cmpen472hw3McDonnell/Full_Chip_Simulation.ini b/cmpen472hw3McDonnell/Full_Chip_Simulation.ini deleted file mode 100644 index b6a9c64..0000000 --- a/cmpen472hw3McDonnell/Full_Chip_Simulation.ini +++ /dev/null @@ -1,49 +0,0 @@ -[Environment Variables] -GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib -LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include -OBJPATH={Project}bin -TEXTPATH={Project}bin -ABSPATH={Project}bin - -[HI-WAVE] -Target=sim -Layout=Full_Chip_Simulation.hwl -LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD -CPU=HC12 -MainFrame=2,3,-1,-1,-1,-1,985,223,2200,1246 -Configuration=Full_Chip_Simulation.hwc -Statusbar=1 -ShowToolbar=1 -Smallborder=0 -Hideheadline=0 -Hidetitle=0 -TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 - - - - - - - - - -[Simulator] -CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" - -[Simulator HC12] -CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" -CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" -CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" -CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" -HCS12_SUPPORT=1 -FCS=MC9S12C32 -ZEROTIMEATRESET=1 -OSCFREQUENCY=48000000 -DISPLAYTIME=0 - - -[Recent Layout File List] -File0=Full_Chip_Simulation.hwl -File1=ASM_layout.hwl -File2= -File3= diff --git a/cmpen472hw3McDonnell/Sources/cmpen472hw3_McDonnell.asm b/cmpen472hw3McDonnell/Sources/cmpen472hw3_McDonnell.asm deleted file mode 100644 index 2eb72c3..0000000 --- a/cmpen472hw3McDonnell/Sources/cmpen472hw3_McDonnell.asm +++ /dev/null @@ -1,173 +0,0 @@ -************************************************************************** -* -* 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 - -* Symbols and Macros -PORTA equ $0000 ; i/o port A addresses -DDRA equ $0002 ; data direction register for PORTA -PORTB equ $0001 ; i/o port B addresses -DDRB equ $0003 ; data direction register for PORTB - -************************************************************************** -* Data Section: address used [ $3000 to $30FF ] RAM Memory -* - org $3000 ; Reserved RAM memory starting address - ; 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 - -* -************************************************************************** -* Program Section: address used [ $3100 to $3FFF ] RAM Memory -* - org $3100 ; Program start address, in RAM -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 #%01010000 - staa PORTB ; Turn on only LEDs 1 & 3 on PORTB - -mainLoop - ldaa PORTB ; check bit 0 of PORTB, switch 1 - anda #%00000001 ; if 0, run blink LED4 5% light level - bne p25LED4 ; if 1, run blink LED4 25% 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 - -p25LED4 - ldaa #25 ; load 25 into accumulator A - staa ONN ; store A in counter ONN - ldaa #75 ; load 75 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 -* - -;************************************************************************* -; dimmer subroutine -; -; This subroutine will dim LED4 to a given level -; -; 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 delay10usec subroutine -; - -dimmer - bset PORTB,%10000000 ; Turn LED4 on - psha ; Save A to the stack -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 onDelay ; jump back to loop1 always -skipToOff bclr PORTB,%10000000 ; Turn off LED4 -offDelay ldaa OFF ; load counter OFF into A - beq doneLoop ; if 0, skip loop - jsr delay10usec ; delay 10 microseconds - dec OFF ; decrement counter OFF by 1 - bra offDelay ; jump back to loop2 always -doneLoop pula ; restore A from the stack - rts ; return to caller - -;************************************************************************* -; delay10usec subroutine -; -; This subroutine causes a 10 usec. delay -; -; 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 'Counter' -; -; 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 - 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 - - end ; last line of the file - diff --git a/cmpen472hw3McDonnell/Sources/derivative.inc b/cmpen472hw3McDonnell/Sources/derivative.inc deleted file mode 100644 index 9320da5..0000000 --- a/cmpen472hw3McDonnell/Sources/derivative.inc +++ /dev/null @@ -1,10 +0,0 @@ - - ; Note: This file is recreated by the project wizard whenever the MCU is - ; changed and should not be edited by hand - ; - - ; include derivative specific macros - INCLUDE 'mc9s12c32.inc' - - - diff --git a/cmpen472hw3McDonnell/Sources/main.asm b/cmpen472hw3McDonnell/Sources/main.asm deleted file mode 100644 index 2eb72c3..0000000 --- a/cmpen472hw3McDonnell/Sources/main.asm +++ /dev/null @@ -1,173 +0,0 @@ -************************************************************************** -* -* 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 - -* Symbols and Macros -PORTA equ $0000 ; i/o port A addresses -DDRA equ $0002 ; data direction register for PORTA -PORTB equ $0001 ; i/o port B addresses -DDRB equ $0003 ; data direction register for PORTB - -************************************************************************** -* Data Section: address used [ $3000 to $30FF ] RAM Memory -* - org $3000 ; Reserved RAM memory starting address - ; 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 - -* -************************************************************************** -* Program Section: address used [ $3100 to $3FFF ] RAM Memory -* - org $3100 ; Program start address, in RAM -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 #%01010000 - staa PORTB ; Turn on only LEDs 1 & 3 on PORTB - -mainLoop - ldaa PORTB ; check bit 0 of PORTB, switch 1 - anda #%00000001 ; if 0, run blink LED4 5% light level - bne p25LED4 ; if 1, run blink LED4 25% 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 - -p25LED4 - ldaa #25 ; load 25 into accumulator A - staa ONN ; store A in counter ONN - ldaa #75 ; load 75 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 -* - -;************************************************************************* -; dimmer subroutine -; -; This subroutine will dim LED4 to a given level -; -; 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 delay10usec subroutine -; - -dimmer - bset PORTB,%10000000 ; Turn LED4 on - psha ; Save A to the stack -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 onDelay ; jump back to loop1 always -skipToOff bclr PORTB,%10000000 ; Turn off LED4 -offDelay ldaa OFF ; load counter OFF into A - beq doneLoop ; if 0, skip loop - jsr delay10usec ; delay 10 microseconds - dec OFF ; decrement counter OFF by 1 - bra offDelay ; jump back to loop2 always -doneLoop pula ; restore A from the stack - rts ; return to caller - -;************************************************************************* -; delay10usec subroutine -; -; This subroutine causes a 10 usec. delay -; -; 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 'Counter' -; -; 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 - 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 - - end ; last line of the file - diff --git a/cmpen472hw3McDonnell/bin/Project.abs b/cmpen472hw3McDonnell/bin/Project.abs deleted file mode 100644 index 67d0932..0000000 Binary files a/cmpen472hw3McDonnell/bin/Project.abs and /dev/null differ diff --git a/cmpen472hw3McDonnell/bin/Project.abs.phy b/cmpen472hw3McDonnell/bin/Project.abs.phy deleted file mode 100644 index 3d79e92..0000000 --- a/cmpen472hw3McDonnell/bin/Project.abs.phy +++ /dev/null @@ -1,2 +0,0 @@ -S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AD -S9030000FC diff --git a/cmpen472hw3McDonnell/bin/Project.abs.s19 b/cmpen472hw3McDonnell/bin/Project.abs.s19 deleted file mode 100644 index eb47c25..0000000 --- a/cmpen472hw3McDonnell/bin/Project.abs.s19 +++ /dev/null @@ -1,6 +0,0 @@ -S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AD -S10730000039055F2B -S1233100CF310086F15A0386505A0196018401260F86057A3002865F7A300316312F20EB0B -S123312086197A3002864B7A300316312F20DC4C018036B63002270816315273300220F3E5 -S11F31404D0180B63003270816315273300320F3323D34FE30000926FD30A73D26 -S9030000FC diff --git a/cmpen472hw3McDonnell/bin/main.dbg b/cmpen472hw3McDonnell/bin/main.dbg deleted file mode 100644 index 050a874..0000000 --- a/cmpen472hw3McDonnell/bin/main.dbg +++ /dev/null @@ -1,171 +0,0 @@ -************************************************************************** -* -* 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 - -* Symbols and Macros -PORTA equ $0000 ; i/o port A addresses -DDRA equ $0002 ; data direction register for PORTA -PORTB equ $0001 ; i/o port B addresses -DDRB equ $0003 ; data direction register for PORTB - -************************************************************************** -* Data Section: address used [ $3000 to $30FF ] RAM Memory -* - org $3000 ; Reserved RAM memory starting address - ; 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 - -* -************************************************************************** -* Program Section: address used [ $3100 to $3FFF ] RAM Memory -* - org $3100 ; Program start address, in RAM -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 #%01010000 - staa PORTB ; Turn on only LEDs 1 & 3 on PORTB - -mainLoop - ldaa PORTB ; check bit 0 of PORTB, switch 1 - anda #%00000001 ; if 0, run blink LED4 5% light level - bne p25LED4 ; if 1, run blink LED4 25% 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 - -p25LED4 - ldaa #25 ; load 25 into accumulator A - staa ONN ; store A in counter ONN - ldaa #75 ; load 75 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 -* - -;************************************************************************* -; dimmer subroutine -; -; This subroutine will dim LED4 to a given level -; -; 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 delay10usec subroutine -; - -dimmer - bset PORTB,%10000000 ; Turn LED4 on - psha ; Save A to the stack -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 onDelay ; jump back to loop1 always -skipToOff bclr PORTB,%10000000 ; Turn off LED4 -offDelay ldaa OFF ; load counter OFF into A - beq doneLoop ; if 0, skip loop - jsr delay10usec ; delay 10 microseconds - dec OFF ; decrement counter OFF by 1 - bra offDelay ; jump back to loop2 always -doneLoop pula ; restore A from the stack - rts ; return to caller - -;************************************************************************* -; delay10usec subroutine -; -; This subroutine causes a 10 usec. delay -; -; 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 'Counter' -; -; 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 - 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/cmd/Full_Chip_Simulation_Postload.cmd b/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Postload.cmd deleted file mode 100644 index eb00f37..0000000 --- a/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Postload.cmd +++ /dev/null @@ -1 +0,0 @@ -// After load the commands written below will be executed diff --git a/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Preload.cmd b/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Preload.cmd deleted file mode 100644 index 691c5ee..0000000 --- a/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Preload.cmd +++ /dev/null @@ -1 +0,0 @@ -// Before load the commands written below will be executed diff --git a/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Reset.cmd b/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Reset.cmd deleted file mode 100644 index f0fc874..0000000 --- a/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Reset.cmd +++ /dev/null @@ -1 +0,0 @@ -// After reset the commands written below will be executed diff --git a/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd b/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd deleted file mode 100644 index 5f2b5a5..0000000 --- a/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd +++ /dev/null @@ -1 +0,0 @@ -// At startup the commands written below will be executed diff --git a/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Startup.cmd b/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Startup.cmd deleted file mode 100644 index 5f2b5a5..0000000 --- a/cmpen472hw3McDonnell/cmd/Full_Chip_Simulation_Startup.cmd +++ /dev/null @@ -1 +0,0 @@ -// At startup the commands written below will be executed diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell.mcp b/cmpen472hw3McDonnell/cmpen472hw3McDonnell.mcp deleted file mode 100644 index 19b4bdd..0000000 Binary files a/cmpen472hw3McDonnell/cmpen472hw3McDonnell.mcp and /dev/null differ diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/CWSettingsWindows.stg b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/CWSettingsWindows.stg deleted file mode 100644 index da25121..0000000 Binary files a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/CWSettingsWindows.stg and /dev/null differ diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o deleted file mode 100644 index 67d0932..0000000 Binary files a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o and /dev/null differ diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx deleted file mode 100644 index 69819b7..0000000 --- a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx +++ /dev/null @@ -1,6 +0,0 @@ -S0820000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C636D70656E3437326877334D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726D93 -S10730000039055F2B -S1233100CF310086F15A0386505A0196018401260F86057A3002865F7A300316312F20EB0B -S123312086197A3002864B7A300316312F20DC4C018036B63002270816315273300220F3E5 -S11F31404D0180B63003270816315273300320F3323D34FE30000926FD30A73D26 -S9033100CB diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt deleted file mode 100644 index 3343110..0000000 Binary files a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt and /dev/null differ diff --git a/cmpen472hw3McDonnell/prm/burner.bbl b/cmpen472hw3McDonnell/prm/burner.bbl deleted file mode 100644 index 42c21ed..0000000 --- a/cmpen472hw3McDonnell/prm/burner.bbl +++ /dev/null @@ -1,157 +0,0 @@ -/* logical s-record file */ -OPENFILE "%ABS_FILE%.s19" -format=motorola -busWidth=1 -origin=0 -len=0x1000000 -destination=0 -SRECORD=Sx -SENDBYTE 1 "%ABS_FILE%" -CLOSE - - -/* physical s-record file */ -OPENFILE "%ABS_FILE%.phy" -format = motorola -busWidth = 1 -len = 0x4000 - -/* logical non banked flash at $4000 and $C000 to physical */ -origin = 0x004000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" - -origin = 0x00C000 -destination = 0x0FC000 -SENDBYTE 1 "%ABS_FILE%" - -/* physical FTS512K flash window to physical -origin = 0x008000 -destination = 0x080000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS256K parts flash window to physical -origin = 0x008000 -destination = 0x0C0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS128K parts flash window to physical -origin = 0x008000 -destination = 0x0E0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS64K parts flash window to physical -origin = 0x008000 -destination = 0x0F0000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* physical FTS32K parts flash window to physical -origin = 0x008000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" -*/ - -/* logical 512 kB banked flash to physical */ -origin = 0x208000 -destination = 0x080000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x218000 -destination = 0x084000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x228000 -destination = 0x088000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x238000 -destination = 0x08C000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x248000 -destination = 0x090000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x258000 -destination = 0x094000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x268000 -destination = 0x098000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x278000 -destination = 0x09C000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x288000 -destination = 0x0A0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x298000 -destination = 0x0A4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2A8000 -destination = 0x0A8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2B8000 -destination = 0x0AC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2C8000 -destination = 0x0B0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2D8000 -destination = 0x0B4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2E8000 -destination = 0x0B8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x2F8000 -destination = 0x0BC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x308000 -destination = 0x0C0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x318000 -destination = 0x0C4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x328000 -destination = 0x0C8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x338000 -destination = 0x0CC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x348000 -destination = 0x0D0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x358000 -destination = 0x0D4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x368000 -destination = 0x0D8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x378000 -destination = 0x0DC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x388000 -destination = 0x0E0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x398000 -destination = 0x0E4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3A8000 -destination = 0x0E8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3B8000 -destination = 0x0EC000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3C8000 -destination = 0x0F0000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3D8000 -destination = 0x0F4000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3E8000 -destination = 0x0F8000 -SENDBYTE 1 "%ABS_FILE%" -origin = 0x3F8000 -destination = 0x0FC000 -SENDBYTE 1 "%ABS_FILE%" - -CLOSE - diff --git a/cmpen472hw3_McDonnell/ASM_layout.hwl b/cmpen472hw3_McDonnell/ASM_layout.hwl new file mode 100644 index 0000000..af05bda --- /dev/null +++ b/cmpen472hw3_McDonnell/ASM_layout.hwl @@ -0,0 +1,18 @@ +OPEN source 0 0 60 42 +Source < attributes MARKS off +OPEN assembly 60 0 40 30 +Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,TOPPC 0xF800 +OPEN procedure 60 60 40 17 +Procedure < attributes VALUES on,TYPES off +OPEN register 60 30 40 30 +Register < attributes FORMAT AUTO,COMPLEMENT None +OPEN memory 60 77 40 23 +Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,ADDRESS 0x80 +OPEN data 0 42 60 28 +Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,UPDATERATE 10,NAMEWIDTH 16 +OPEN command 0 70 60 30 +Command < attributes CACHESIZE 1000 +bckcolor 50331647 +font 'Courier New' 9 BLACK +AUTOSIZE on +ACTIVATE Assembly Memory Register Command Data Source Procedure diff --git a/cmpen472hw3_McDonnell/Default.mem b/cmpen472hw3_McDonnell/Default.mem new file mode 100644 index 0000000..bf49148 Binary files /dev/null and b/cmpen472hw3_McDonnell/Default.mem differ diff --git a/cmpen472hw3_McDonnell/Full_Chip_Simulation.hwc b/cmpen472hw3_McDonnell/Full_Chip_Simulation.hwc new file mode 100644 index 0000000..f3ce7c9 --- /dev/null +++ b/cmpen472hw3_McDonnell/Full_Chip_Simulation.hwc @@ -0,0 +1 @@ +LOADMEM default.mem diff --git a/cmpen472hw3_McDonnell/Full_Chip_Simulation.hwl b/cmpen472hw3_McDonnell/Full_Chip_Simulation.hwl new file mode 100644 index 0000000..3516c73 --- /dev/null +++ b/cmpen472hw3_McDonnell/Full_Chip_Simulation.hwl @@ -0,0 +1,26 @@ +OPEN source 0 0 60 42 +Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off +OPEN assembly 60 0 40 30 +Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0xCBCB +OPEN procedure 60 60 40 17 +Procedure < attributes VALUES on,TYPES off +OPEN register 60 30 40 30 +Register < attributes FORMAT AUTO,COMPLEMENT None +OPEN memory 60 77 40 23 +Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 +OPEN data 0 42 60 28 +Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 +OPEN command 0 70 60 30 +Command < attributes CACHESIZE 1000 +OPEN Visualizationtool 63 50 26 29 +VisualizationTool< Attributes [stEditM="0",swGridMode="1",swRefresh="3",refCycles="1"] +VisualizationTool< LoadInstrument LED[BoundX="102",BoundY="40",Port="0x0001",Port_PortEndian="1",swBIT="7"] +VisualizationTool< LoadInstrument LED[BoundX="133",BoundY="41",Port="0x0001",Port_PortEndian="1",swBIT="6"] +VisualizationTool< LoadInstrument LED[BoundX="166",BoundY="37",Port="0x0001",Port_PortEndian="1",swBIT="5"] +VisualizationTool< LoadInstrument LED[BoundX="202",BoundY="42",Port="0x0001",Port_PortEndian="1",swBIT="4"] +VisualizationTool< LoadInstrument DILSwitch[BoundX="83",BoundY="106",Port="0x0001"] +VisualizationTool< ResetVT Undo +bckcolor 50331647 +font 'Courier New' 9 BLACK +AUTOSIZE on +ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Procedure" "Source" "VisualizationTool" diff --git a/cmpen472hw3_McDonnell/Full_Chip_Simulation.ini b/cmpen472hw3_McDonnell/Full_Chip_Simulation.ini new file mode 100644 index 0000000..e7c287d --- /dev/null +++ b/cmpen472hw3_McDonnell/Full_Chip_Simulation.ini @@ -0,0 +1,49 @@ +[Environment Variables] +GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib +LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include +OBJPATH={Project}bin +TEXTPATH={Project}bin +ABSPATH={Project}bin + +[HI-WAVE] +Target=sim +Layout=Full_Chip_Simulation.hwl +LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD +CPU=HC12 +MainFrame=2,3,-1,-1,-1,-1,985,223,2200,1246 +Configuration=Full_Chip_Simulation.hwc +Statusbar=1 +ShowToolbar=1 +Smallborder=0 +Hideheadline=0 +Hidetitle=0 +TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 + + + + + + + + + +[Simulator] +CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" + +[Simulator HC12] +CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" +CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" +CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" +CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" +HCS12_SUPPORT=1 +FCS=MC9S12C32 +ZEROTIMEATRESET=1 +OSCFREQUENCY=48000000 +DISPLAYTIME=0 + + +[Recent Layout File List] +File0=Full_Chip_Simulation.hwl +File1=ASM_layout.hwl +File2= +File3= diff --git a/cmpen472hw3_McDonnell/Sources/cmpen472hw3_McDonnell.asm b/cmpen472hw3_McDonnell/Sources/cmpen472hw3_McDonnell.asm new file mode 100644 index 0000000..7e19beb --- /dev/null +++ b/cmpen472hw3_McDonnell/Sources/cmpen472hw3_McDonnell.asm @@ -0,0 +1,173 @@ +************************************************************************** +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; 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 + +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #%01010000 + staa PORTB ; Turn on only LEDs 1 & 3 on PORTB + +mainLoop + ldaa PORTB ; check bit 0 of PORTB, switch 1 + anda #%00000001 ; if 0, run blink LED4 5% light level + bne p25LED4 ; if 1, run blink LED4 25% 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 + +p25LED4 + ldaa #25 ; load 25 into accumulator A + staa ONN ; store A in counter ONN + ldaa #75 ; load 75 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 +* + +;************************************************************************* +; dimmer subroutine +; +; This subroutine will dim LED4 to a given level +; +; 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 delay10usec subroutine +; + +dimmer + bset PORTB,%10000000 ; Turn LED4 on + psha ; Save A to the stack +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 onDelay ; jump back to loop1 always +skipToOff bclr PORTB,%10000000 ; Turn off LED4 +offDelay ldaa OFF ; load counter OFF into A + beq doneLoop ; if 0, skip loop + jsr delay10usec ; delay 10 microseconds + dec OFF ; decrement counter OFF by 1 + bra offDelay ; jump back to loop2 always +doneLoop pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; delay10usec subroutine +; +; This subroutine causes a 10 usec. delay +; +; 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 'Counter' +; +; 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 + 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 + + end ; last line of the file + diff --git a/cmpen472hw3_McDonnell/Sources/derivative.inc b/cmpen472hw3_McDonnell/Sources/derivative.inc new file mode 100644 index 0000000..988343b --- /dev/null +++ b/cmpen472hw3_McDonnell/Sources/derivative.inc @@ -0,0 +1,10 @@ + + ; Note: This file is recreated by the project wizard whenever the MCU is + ; changed and should not be edited by hand + ; + + ; include derivative specific macros + INCLUDE 'mc9s12c32.inc' + + + diff --git a/cmpen472hw3_McDonnell/Sources/main.asm b/cmpen472hw3_McDonnell/Sources/main.asm new file mode 100644 index 0000000..7e19beb --- /dev/null +++ b/cmpen472hw3_McDonnell/Sources/main.asm @@ -0,0 +1,173 @@ +************************************************************************** +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; 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 + +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #%01010000 + staa PORTB ; Turn on only LEDs 1 & 3 on PORTB + +mainLoop + ldaa PORTB ; check bit 0 of PORTB, switch 1 + anda #%00000001 ; if 0, run blink LED4 5% light level + bne p25LED4 ; if 1, run blink LED4 25% 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 + +p25LED4 + ldaa #25 ; load 25 into accumulator A + staa ONN ; store A in counter ONN + ldaa #75 ; load 75 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 +* + +;************************************************************************* +; dimmer subroutine +; +; This subroutine will dim LED4 to a given level +; +; 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 delay10usec subroutine +; + +dimmer + bset PORTB,%10000000 ; Turn LED4 on + psha ; Save A to the stack +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 onDelay ; jump back to loop1 always +skipToOff bclr PORTB,%10000000 ; Turn off LED4 +offDelay ldaa OFF ; load counter OFF into A + beq doneLoop ; if 0, skip loop + jsr delay10usec ; delay 10 microseconds + dec OFF ; decrement counter OFF by 1 + bra offDelay ; jump back to loop2 always +doneLoop pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; delay10usec subroutine +; +; This subroutine causes a 10 usec. delay +; +; 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 'Counter' +; +; 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 + 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 + + end ; last line of the file + diff --git a/cmpen472hw3_McDonnell/bin/Project.abs b/cmpen472hw3_McDonnell/bin/Project.abs new file mode 100644 index 0000000..67d0932 Binary files /dev/null and b/cmpen472hw3_McDonnell/bin/Project.abs differ diff --git a/cmpen472hw3_McDonnell/bin/Project.abs.phy b/cmpen472hw3_McDonnell/bin/Project.abs.phy new file mode 100644 index 0000000..3d2bd7a --- /dev/null +++ b/cmpen472hw3_McDonnell/bin/Project.abs.phy @@ -0,0 +1,2 @@ +S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AD +S9030000FC diff --git a/cmpen472hw3_McDonnell/bin/Project.abs.s19 b/cmpen472hw3_McDonnell/bin/Project.abs.s19 new file mode 100644 index 0000000..b364abc --- /dev/null +++ b/cmpen472hw3_McDonnell/bin/Project.abs.s19 @@ -0,0 +1,6 @@ +S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AD +S10730000039055F2B +S1233100CF310086F15A0386505A0196018401260F86057A3002865F7A300316312F20EB0B +S123312086197A3002864B7A300316312F20DC4C018036B63002270816315273300220F3E5 +S11F31404D0180B63003270816315273300320F3323D34FE30000926FD30A73D26 +S9030000FC diff --git a/cmpen472hw3_McDonnell/bin/main.dbg b/cmpen472hw3_McDonnell/bin/main.dbg new file mode 100644 index 0000000..6562514 --- /dev/null +++ b/cmpen472hw3_McDonnell/bin/main.dbg @@ -0,0 +1,171 @@ +************************************************************************** +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; 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 + +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #%01010000 + staa PORTB ; Turn on only LEDs 1 & 3 on PORTB + +mainLoop + ldaa PORTB ; check bit 0 of PORTB, switch 1 + anda #%00000001 ; if 0, run blink LED4 5% light level + bne p25LED4 ; if 1, run blink LED4 25% 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 + +p25LED4 + ldaa #25 ; load 25 into accumulator A + staa ONN ; store A in counter ONN + ldaa #75 ; load 75 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 +* + +;************************************************************************* +; dimmer subroutine +; +; This subroutine will dim LED4 to a given level +; +; 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 delay10usec subroutine +; + +dimmer + bset PORTB,%10000000 ; Turn LED4 on + psha ; Save A to the stack +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 onDelay ; jump back to loop1 always +skipToOff bclr PORTB,%10000000 ; Turn off LED4 +offDelay ldaa OFF ; load counter OFF into A + beq doneLoop ; if 0, skip loop + jsr delay10usec ; delay 10 microseconds + dec OFF ; decrement counter OFF by 1 + bra offDelay ; jump back to loop2 always +doneLoop pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; delay10usec subroutine +; +; This subroutine causes a 10 usec. delay +; +; 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 'Counter' +; +; 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 + 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/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd new file mode 100644 index 0000000..ac4d359 --- /dev/null +++ b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd @@ -0,0 +1 @@ +// After load the commands written below will be executed diff --git a/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd new file mode 100644 index 0000000..0bed464 --- /dev/null +++ b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd @@ -0,0 +1 @@ +// Before load the commands written below will be executed diff --git a/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd new file mode 100644 index 0000000..bf55944 --- /dev/null +++ b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd @@ -0,0 +1 @@ +// After reset the commands written below will be executed diff --git a/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw3_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw3_McDonnell/cmpen472hw3McDonnell.mcp b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell.mcp new file mode 100644 index 0000000..19b4bdd Binary files /dev/null and b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell.mcp differ diff --git a/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/CWSettingsWindows.stg b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/CWSettingsWindows.stg new file mode 100644 index 0000000..da25121 Binary files /dev/null and b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/CWSettingsWindows.stg differ diff --git a/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o new file mode 100644 index 0000000..67d0932 Binary files /dev/null and b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o differ diff --git a/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx new file mode 100644 index 0000000..94cf452 --- /dev/null +++ b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx @@ -0,0 +1,6 @@ +S0820000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C636D70656E3437326877334D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726D93 +S10730000039055F2B +S1233100CF310086F15A0386505A0196018401260F86057A3002865F7A300316312F20EB0B +S123312086197A3002864B7A300316312F20DC4C018036B63002270816315273300220F3E5 +S11F31404D0180B63003270816315273300320F3323D34FE30000926FD30A73D26 +S9033100CB diff --git a/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt new file mode 100644 index 0000000..3343110 Binary files /dev/null and b/cmpen472hw3_McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt differ diff --git a/cmpen472hw3_McDonnell/prm/burner.bbl b/cmpen472hw3_McDonnell/prm/burner.bbl new file mode 100644 index 0000000..0c57619 --- /dev/null +++ b/cmpen472hw3_McDonnell/prm/burner.bbl @@ -0,0 +1,157 @@ +/* logical s-record file */ +OPENFILE "%ABS_FILE%.s19" +format=motorola +busWidth=1 +origin=0 +len=0x1000000 +destination=0 +SRECORD=Sx +SENDBYTE 1 "%ABS_FILE%" +CLOSE + + +/* physical s-record file */ +OPENFILE "%ABS_FILE%.phy" +format = motorola +busWidth = 1 +len = 0x4000 + +/* logical non banked flash at $4000 and $C000 to physical */ +origin = 0x004000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" + +origin = 0x00C000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +/* physical FTS512K flash window to physical +origin = 0x008000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS256K parts flash window to physical +origin = 0x008000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS128K parts flash window to physical +origin = 0x008000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS64K parts flash window to physical +origin = 0x008000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS32K parts flash window to physical +origin = 0x008000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* logical 512 kB banked flash to physical */ +origin = 0x208000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x218000 +destination = 0x084000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x228000 +destination = 0x088000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x238000 +destination = 0x08C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x248000 +destination = 0x090000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x258000 +destination = 0x094000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x268000 +destination = 0x098000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x278000 +destination = 0x09C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x288000 +destination = 0x0A0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x298000 +destination = 0x0A4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2A8000 +destination = 0x0A8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2B8000 +destination = 0x0AC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2C8000 +destination = 0x0B0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2D8000 +destination = 0x0B4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2E8000 +destination = 0x0B8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2F8000 +destination = 0x0BC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x308000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x318000 +destination = 0x0C4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x328000 +destination = 0x0C8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x338000 +destination = 0x0CC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x348000 +destination = 0x0D0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x358000 +destination = 0x0D4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x368000 +destination = 0x0D8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x378000 +destination = 0x0DC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x388000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x398000 +destination = 0x0E4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3A8000 +destination = 0x0E8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3B8000 +destination = 0x0EC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3C8000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3D8000 +destination = 0x0F4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3E8000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3F8000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +CLOSE + diff --git a/cmpen472hw8_McDonnell/ASM_layout.hwl b/cmpen472hw8_McDonnell/ASM_layout.hwl new file mode 100644 index 0000000..22795c3 --- /dev/null +++ b/cmpen472hw8_McDonnell/ASM_layout.hwl @@ -0,0 +1,27 @@ +OPEN source 0 0 60 42 +Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off +OPEN assembly 60 0 40 30 +Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0x3100 +OPEN procedure 60 60 40 17 +Procedure < attributes VALUES on,TYPES off +OPEN register 60 30 40 30 +Register < attributes FORMAT AUTO,COMPLEMENT None +OPEN memory 60 77 40 23 +Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 +OPEN data 0 42 60 28 +Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 +OPEN command 0 70 60 30 +Command < attributes CACHESIZE 1000 +OPEN Terminal 10 20 40 69 +Terminal < attributes CACHESIZE 1000 +Terminal < attributes SCI_DEFAULT_TEXT "Virtual SCI",SCI_CONNECTION 0,1,SCI_CONNECTION 1,0,SCI_CONNECTION 1,3,SCI_CONNECTION 3,1,SCI_PORT COM1,SCI_BAUD 9600,SCI_SHOW_PROTOCOL OFF,SCI_VIRTUAL_IN "Sci:2.SerialOutput",SCI_VIRTUAL_OUT "Sci:2.SerialInput",SCI_FILENAME_IN "",SCI_FILENAME_OUT "" +OPEN Visualizationtool 76 37 11 29 +VisualizationTool< Attributes [stEditM="0",swRefresh="3",refCycles="1"] +VisualizationTool< LoadInstrument Seg7[BoundX="26",BoundY="12",Port="0x1",swDM="2"] +VisualizationTool< LoadInstrument Seg7[BoundX="67",BoundY="14",Port="0x1",swDM="1"] +VisualizationTool< LoadInstrument DILSwitch[BoundX="25",BoundY="106",Port="0x1"] +VisualizationTool< ResetVT Undo +bckcolor 50331647 +font 'Courier New' 9 BLACK +AUTOSIZE on +ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Source" "Procedure" "Terminal" "VisualizationTool" diff --git a/cmpen472hw8_McDonnell/Default.mem b/cmpen472hw8_McDonnell/Default.mem new file mode 100644 index 0000000..bf49148 Binary files /dev/null and b/cmpen472hw8_McDonnell/Default.mem differ diff --git a/cmpen472hw8_McDonnell/Full_Chip_Simulation.hwc b/cmpen472hw8_McDonnell/Full_Chip_Simulation.hwc new file mode 100644 index 0000000..f3ce7c9 --- /dev/null +++ b/cmpen472hw8_McDonnell/Full_Chip_Simulation.hwc @@ -0,0 +1 @@ +LOADMEM default.mem diff --git a/cmpen472hw8_McDonnell/Full_Chip_Simulation.ini b/cmpen472hw8_McDonnell/Full_Chip_Simulation.ini new file mode 100644 index 0000000..b56906d --- /dev/null +++ b/cmpen472hw8_McDonnell/Full_Chip_Simulation.ini @@ -0,0 +1,42 @@ +[Environment Variables] +GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib +LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include +OBJPATH={Project}bin +TEXTPATH={Project}bin +ABSPATH={Project}bin + +[HI-WAVE] +Target=sim +Layout=ASM_layout.hwl +LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD +CPU=HC12 +MainFrame=0,1,-1,-1,-1,-1,854,150,1955,1166 +Configuration=Full_Chip_Simulation.hwc +Statusbar=1 +ShowToolbar=1 +Smallborder=0 +Hideheadline=0 +Hidetitle=0 +TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 + + + + + + + + + +[Simulator] +CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" + +[Simulator HC12] +CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" +CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" +CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" +CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" +HCS12_SUPPORT=1 +FCS=MC9S12C32 +ZEROTIMEATRESET=1 +OSCFREQUENCY=48000000 +DISPLAYTIME=0 diff --git a/cmpen472hw8_McDonnell/Sources/cmpen472hw8_McDonnell.asm b/cmpen472hw8_McDonnell/Sources/cmpen472hw8_McDonnell.asm new file mode 100644 index 0000000..cbfe22a --- /dev/null +++ b/cmpen472hw8_McDonnell/Sources/cmpen472hw8_McDonnell.asm @@ -0,0 +1,764 @@ +************************************************************************** +* +* Title: Calculator +* +* Objective: CMPEN 472 Homework 8 +* +* Revision: V1.0 +* +* Date: Mar. 24, 2025 +* +* Programmer: Jacob McDonnell +* +* Company: The Pennsylvania State University +* Department of Computer Science and Engineering +* +* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking +* +* Register Use: A & B to current byte, etc, +* X & Y holds address of strings and length of string, +* D to hold data for printing, reading, and updating time. +* +* Memory Use: RAM Locations from $3000 for data, +* RAM Locations from $3100 for program +* +* Input: Serial Port for User Input +* +* Output: Serial Port for String Output +* +* Observation: The HC12 will output the time and a command prompt every second. +* The user can input commands and the program will output a response +* based on the input. +* +* Note: ON CSM-12C128 board, +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H +SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L +SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 +SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 +SCIDRL equ $00CF ; Serial port (SCI) Data Register + +CRGFLG EQU $0037 ; Clock and Reset Generator Flags +CRGINT EQU $0038 ; Clock and Reset Generator Interrupts +RTICTL EQU $003B ; Real Time Interrupt Control + +CR equ $0d ; carriage return, ASCII 'Return' key +LF equ $0a ; line feed, ASCII 'next line' character +NULL equ $00 ; NULL Terminator character + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +buffer ds.b $0010 ; Array of 16 bytes to read a string + dc.b NULL ; NULL terminated +lenBuf dc.w $0010 ; Length of buffer array + +buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal + dc.b NULL ; NULL terminated +lenBuf2 dc.w $0010 ; length of buffer2 + +hours dc.w $0000 ; Buffer to hold the hours of the time + +minutes dc.w $0000 ; Buffer to hold the minutes of the time + +seconds dc.w $0000 ; Buffer to hold the seconds of the time + +counter dc.w $0000 ; Counter for RTI ISR for 1 second + +numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers + +operator dc.b $0000 ; Used by ReadDecimal for reading numbers + +inputBuffer ds.b $0010 ; Input Buffer Length + +lenInput dc.w $0010 ; Length of the Input Buffer + +outputBuf dc.b 'h' ; Used to control what to output on 7 segment display + +* +* There is a section Data Section at the end of the file +************************************************************************** +* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory +* + org $FFF0 ; Memory location for RTI interrupt vector section for simulator + dc.w rtiisr ; Real Time Interrupt vector +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #$0C ; Enable SCI port Tx and Rx units + staa SCICR2 ; disable SCI interrupts + + ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) + std SCIBDH ; SCI port baud rate change + + ldx #msg ; Load the address of the welcome message into X + jsr WriteString ; Write the string to the serial console + + bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board + ; 4MHz quartz oscillator clock + 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 + cli ; Enable interrupts + jsr PrintTime ; Jump to PrintTime to write to serial console +mainLoop + 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 + + ldx #inputBuffer ; Load the address of inputBuffer into X + jsr ExecuteCommand ; Jump to ExecuteCommand + + ldx #inputBuffer ; Load the address of inputBuffer into X + ldy lenInput ; Load the length of inputBuffer into Y + jsr Zeros ; Zero out inputBuffer + + sei ; Disable interrupts + jsr PrintTime ; Jump to PrintTime to print new time + cli ; Enable interrupts + + bra mainLoop ; Loop back to mainLoop always + +TypeWrite + sei ; Disable Interrupts + bclr CRGINT,%10000000; Disable RTI interrupt + ldx #twMsg ; Load the address of twMsg into X + jsr WriteString ; Write the string to the serial console +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 + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +;************************************************************************* +; rtiisr subroutine +; +; This subroutine will increment the counter, seconds, minutes, & hours counters +; to track the time. This subroutine will be called ~400 times a second. +; +; Input: No input other than the timer to call the isr. +; Output: The counter, seconds, minutes, & hours buffers will +; be updated to track the time, the time & prompt will be +; printed every second. +; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. +; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, +; Buffer words for counters, seconds, minutes, & hours buffers. +; +; Comments: The counter buffer should be compared to 400, but for the simulator, +; the counter is compared to 200 to better simulate 1 second on my computer. +; + +rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + ldx counter ; Load counter into X + inx ; Increment counter by 1 + stx counter ; Save X to counter + 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 + inx ; Increment the seconds by 1 + stx seconds ; Save the new seconds to the location + cpx #60 ; Compare X to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the seconds + stx seconds ; Save the new seconds to the location + ldx minutes ; load the minutes into X + inx ; Increment the minutes by 1 + stx minutes ; Save the updated minutes + cpx #60 ; Compare the minutes to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the minutes + stx minutes ; Save the updated minutes + ldx hours ; Load the hours into X + inx ; Increment the hours by 1 + stx hours ; Save the updated hours + cpx #24 ; Compare the hours to 24 + bne rtidone ; If X != 24, exit the isr + ldx #0 ; Reset the hours + stx hours ; Save the updated hours +rtidone jsr PrintTime ; Jump to PrintTime +rtiSkip RTI ; Return from RTI ISR + +;************************************************************************* +; PrintTime subroutine +; +; This subroutine will print the time, command prompt, and maybe an error prompt. +; +; Input: No input. +; Output: The time prompt, time, command prompt, the current input, +; and/or an error on the serial console. +; Registers in use: A for the characters to print, X for buffer addresses, +; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB +; Memory locations in use: Memory Address for serial line, Buffer words for counters, +; seconds, minutes, & hours buffers, and buffer to print time, +; outputBuf for tracking what to output on PORTB. +; +; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine +; will print the current user input if its not finished. +; + +PrintTime + pshd ; Save D to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack + ldaa #CR ; Load the character CR into A + jsr putchar ; Write the character to the serial + ldaa #LF ; Load the character LF into A + jsr putchar ; Write the character to the serial + ldx #clock ; Load the address of the clock prompt into X + jsr WriteString ; Write the string to serial + ldd hours ; Load the hours into D + cpd #10 ; Compare D to 10 + bhs goodHours ; If D >= goodHours + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodHours ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd minutes ; Load the minutes into D + cpd #10 ; Compare D to 10 + bhs goodMins ; If D >= goodMins + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodMins ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd seconds ; Load the seconds into D + cpd #10 ; Compare D to 10 + bhs goodSecs ; If D >= goodSecs + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodSecs ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #' ' ; Load ' ' character into A + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + 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 + 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 subroutine +; +; This subroutine will output the time given on on PORTB for two seven segment displays. +; +; Input: Two Digit Decimal number in register D. +; Output: The given two digit decimal number on PORTB for two 7 segment displays. +; Registers in use: D for the input, and for math to split the digits, X for math to split digits. +; Memory locations in use: PORTB memory location. +; +; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal +; numbers (leading zeros will be added). +; + +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 subroutine +; +; This subroutine will parse user input and execute the proper command or error out. +; +; Input: An address of a NULL terminated string in X. +; Output: The output of the proper command or an error message. +; Registers in use: X for the address of the user input, A for individual characters, +; D & Y for numbers read from user input. +; Memory locations in use: Serial console memory locations. +; +; Comments: This subroutine will disable interrupts while setting the time and will +; reenable them after setting the time. +; + +ExecuteCommand + pshd ; Save D to the stack + pshy ; Save Y to the stack + ldaa 1,x+ ; Load the character from X into A + lbeq ecDone ; If A == 0, jump to ecDone + cmpa #'t' ; Compare A to 't' + bne isH ; If A != 't', branch to isH +skipSpaces ldaa 1,+x ; Load the next character into X + cmpa #' ' ; Compare A to ' ' character + beq skipSpaces ; If A == ' ', loop to skipSpaces + sei ; Disable interrupts + ldd hours ; Load hours into D + pshd ; Save hours to the stack + jsr ReadDecimal ; Read Hour number + exg y,d ; Exchange Y and D + cpd #24 ; Compare D to 24 + lbhs badHours ; If D >= 24, badHours + cpd #0 ; Compare D to 0 + lblt badHours ; If D < 0, badHours + std hours ; Save D to hours + ldaa -1,x ; Load the next character into A + cmpa #':' ; Compare A to ':' + lbne badHours ; If A != ':', badHours + ldd minutes ; Load minutes into D + pshd ; Save minutes to the stack + jsr ReadDecimal ; Read minute number + exg y,d ; Exchange Y and D + cpd #60 ; Compare D to 60 + bhs badMinutes ; If D >= 60, badMinutes + cpd #0 ; Compare D to 0 + blt 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 + 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 + cpd #0 ; Compare D to 0 + blt 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 + 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 +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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra ecDone ; Branch to ecDone +isQ cmpa #'q' ; Compare A to 'q' + bne badCommand ; If A != 'q', branch to badCommand + ldab 1,x+ ; Load next character into B + cmpb #NULL ; Compare B to NULL + bne badCommand ; If B != NULL, branch to ecDone + jmp TypeWrite ; Jump to TypeWrite +badSeconds puld ; Restore Seconds from the stack + std seconds ; Restore seconds before change +badMinutes puld ; Restore minutes from the stack + std minutes ; Restore minutes before change +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 +ecDone puly ; Restore Y from the stack + puld ; Restore D 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 +; its value. +; +; Input: A memory address in register X. +; Output: The value of the number in the Y register, and any errors printed +; to the serial line. Zero bit is set if error occurs. +; Registers in use: X for the address of the contents and for a buffer while printing, +; D for multiplication, B for the character, Y for output value. +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine will return the value in the Y register, and if an error occurs, +; the Zero bit in the CCR will be set. +; + +ReadDecimal + pshd ; Save D to the stack + ldy #0 ; Clear Y register +dHLoop ldab 1,x+ ; Read Next character from X + beq dHDone ; If B == 0, exit loop + cmpb #'+' ; Compare B to '+' + beq dHDone ; If B == '+', end of number + cmpb #'-' ; Compare B to '-' + beq dHDone ; If B == '-', end of number + cmpb #'*' ; Compare B to '*' + beq dHDone ; If B == '+', end of number + cmpb #'/' ; Compare B to '/' + beq dHDone ; If B == '-', end of number + cmpb #':' ; Compare B to ':' + beq dHDone ; If B == '-', end of number + cmpb #' ' ; Compare B to space character + beq dHDone ; If B == ' ', exit loop + cmpb #'0' ; Compare B to '0' character + blt dHError ; If B < '0', bad address, exit loop + cmpb #'9' ; Compare B to '9' character + bhi dHError ; If B > '9', check if 'A'-'F' characters + subb #'0' ; Subtract '0' from B to get true value + pshb ; Save B to the stack + ldd #10 ; load 10 into D + emul ; Multiply Y and D + exg d,y ; Transfer data from D to Y + pulb ; Restore b from the stack + aby ; Add B to Y + bra dHLoop ; Branch always to rHLoop +dHDone clra ; clear A accumulator + tap ; Transfer A into CCR to clear zero bit + puld ; Restore D from the stack + rts ; Return to caller +dHError ldaa #4 ; Load 4 into A to set zero bit in CCR + tap ; Transfer A into CCR to set zero bit and warn error + puld ; Restore D from the stack + rts ; Return to caller + +;************************************************************************* +; strrev subroutine +; +; This subroutine will reverse a string from one buffer into another. +; +; Input: Address of null terminated string in X, address of a large enough +; buffer in Y. +; Output: The string in X reversed in Y. +; Registers in use: X for the address of the string, Y for the address of the buffer, +; A to read characters from the string. +; Memory locations in use: Memory Address for serial line, address of the string & buffer +; +; Comments: This subroutine will not check that the output buffer is large enough, that +; is the job of the caller. +; + +strrev + pshx ; Save X to the stack + pshy ; Save Y to the stack + psha ; Save A to the stack +revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y + beq revDone ; If Character is 0, exit loop + staa 1,x+ ; Save character in address in X, increment X + bra revLoop ; Loop back always + clra ; Set A to Zero +revDone staa 1,x+ ; Copy Null terminator into new string + pula ; Restore A from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller + +;************************************************************************* +; PrintDecimalWord subroutine +; +; This subroutine will print a given word of data to the serial in binary. +; +; Input: 1 word of data in register D, Buffer Address in Y +; Output: Decimal representation of the data on the serial console +; Registers in use: Y for the address of the buffer, X to count the number of bits +; written and for division, D for the input, A for characters. +; Memory locations in use: Memory addresses for serial, and operator to hold sign +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +PrintDecimalWord + pshx ; Save X to the stack + pshy ; Save Y to the stack + pshd ; Save D (A:B) to the stack + cpd #0 ; Compare D to zero + beq dIsZero ; Branch to hIsZero + blt dIsNegative ; If D < 0, Jump to dIsNegative +dAfterNeg psha ; Save A to the stack + pshy ; Save Y to the stack + pshx ; Save x to the stack + ldaa #'0' ; Load the '0' character into A + ldx #buffer2 ; Load the address of buffer2 into X + ldy #5 ; Load 5 into Y + jsr memset ; Write '0' to the first 5 bytes in buffer2 + pulx ; Restore X from the stack + puly ; Restore Y from the stack + clra ; Set A to zero + staa 0,y ; Load Zero into Y for Null Terminator + pula ; Restore A from the stack +dPrintLoop ldx #10 ; Load 10 in X for division + idiv ; Divide D / 10 to get Hex Digit + cpx #0 ; Compare X to 0 + beq dCheck ; If X == 0, branch to check D is zero +dDNotZero addb #'0' ; Add '0' to B to get ASCII Character + stab 1,+y ; Save character from B to Y + exg X,D ; Swap values in X and D + bra dPrintLoop ; Loop to hPrintLoop +dCheck cpd #0 ; Compare D to 0 + bne dDNotZero ; If D != 0, branch back to hDNotZero +dPrintDone ldaa operator ; Load operator into A to see if negative + cmpa #'-' ; Compare A to '-' + bne dNotNeg ; If A != '-', jump to dNotNeg + staa 1,+y ; Save '-' into buffer +dNotNeg ldx #buffer2 ; Load the address of buffer2 in X + jsr strrev ; Reverse string in Y in buffer in X + jsr WriteString ; Jump to write string to write the number + ldy lenBuf2 ; Load the length of buffer2 into Y + ldx #buffer2 ; Load the address of buffer2 into X + jsr Zeros ; Fill buffer2 with zeros + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsZero ldaa #'0' ; Load '0' character into A + jsr putchar ; Print character to the screen + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsNegative psha ; Save A to the stack + ldaa #'-' ; Load '-' into A + staa operator ; Save '-' to operator buffer + pula ; Restore A from the stack + nega ; Two's complement of A + suba #1 ; Subtract 1 from A + negb ; Two'complement of B + subb #1 ; Subtract 1 from B + addd #1 ; Add 1 to D + bra dAfterNeg ; Jump back to dAfterNeg + +;************************************************************************* +; Zeros subroutine +; +; This subroutine will write zeros to every byte in a given array. +; +; Input: Address of an array in X and its length in Y +; Output: Zeros in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for 0 +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +Zeros + psha ; Save A to the Stack + clra ; Clear A +zerosLoop staa 1,x+ ; Load A into byte at X + dbne y,zerosLoop ; Decrement Y and loop if Y != 0 + pula ; Restore A from the stack + rts ; Return to caller + +;************************************************************************* +; memset subroutine +; +; This subroutine will write a given byte to every byte in a given array. +; +; Input: Address of an array in X and its length in Y, the byte in A +; Output: The given byte in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for the given byte +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +memset + staa 1,x+ ; Load A into byte at X + dbne y,memset ; Decrement Y and loop if Y != 0 + rts ; Return to caller + +;************************************************************************* +; WriteString subroutine +; +; This subroutine will write a given null terminated string to the serial. +; +; Input: Address of null terminated string in X +; Output: Null terminated string written to serial +; Registers in use: X for the address of the string and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +WriteString + psha ; Save A to the stack +writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 + beq doneWrite ; if A == 0, branch to doneWrite + jsr putchar ; Jump to putchar to write byte to serial + bra writeLoop ; branch always to writeLoop +doneWrite pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; ReadString subroutine +; +; This subroutine will read a string from the serial line to a given address. +; +; Input: Address of an array in X +; Output: Null terminated string in the given array +; Registers in use: X for the address of the string Y for the length of the string, +; and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and getchar subroutine. +; + +ReadString + psha ; Save accumulator A to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack +readLoop jsr getchar ; Jump to putchar to write byte to serial + beq readLoop ; While A == 0, loop + cmpa #CR ; If A == CR, exit loop + beq doneRead ; Branch to doneRead if A == CR + staa 1,x+ ; Save the byte to the addr in X, then add 1 + jsr putchar ; Write Character back to the terminal + 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 + pulY ; Restore Y from the stack + pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine writes a single byte to a serial line +; +; Input: A single ASCII byte in accumulator A +; Output: Sends one character to SCI port +; Registers in use: Accumulator A with input byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty + staa SCIDRL ; send a character + rts ; Return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine reads one byte from the SCI port +; +; Input: One byte from the SCI port +; Output: One byte in accumulator A +; Registers in use: Accumulator A for output byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 + ldaa SCIDRL ; Read one byte from SCI port into A + rts ; Return to caller +getchar7 clra ; Set A to 0 + rts ; Return to caller + +* +************************************************************************** +* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory +* + +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',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 + +; msg: this is the main option menu string +msg dc.b 'Commands:',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 + dc.b 's: Display the seconds on the 7 segment displays',CR,LF + dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL + + end ; last line of the file diff --git a/cmpen472hw8_McDonnell/Sources/derivative.inc b/cmpen472hw8_McDonnell/Sources/derivative.inc new file mode 100644 index 0000000..988343b --- /dev/null +++ b/cmpen472hw8_McDonnell/Sources/derivative.inc @@ -0,0 +1,10 @@ + + ; Note: This file is recreated by the project wizard whenever the MCU is + ; changed and should not be edited by hand + ; + + ; include derivative specific macros + INCLUDE 'mc9s12c32.inc' + + + diff --git a/cmpen472hw8_McDonnell/Sources/main.asm b/cmpen472hw8_McDonnell/Sources/main.asm new file mode 100644 index 0000000..cbfe22a --- /dev/null +++ b/cmpen472hw8_McDonnell/Sources/main.asm @@ -0,0 +1,764 @@ +************************************************************************** +* +* Title: Calculator +* +* Objective: CMPEN 472 Homework 8 +* +* Revision: V1.0 +* +* Date: Mar. 24, 2025 +* +* Programmer: Jacob McDonnell +* +* Company: The Pennsylvania State University +* Department of Computer Science and Engineering +* +* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking +* +* Register Use: A & B to current byte, etc, +* X & Y holds address of strings and length of string, +* D to hold data for printing, reading, and updating time. +* +* Memory Use: RAM Locations from $3000 for data, +* RAM Locations from $3100 for program +* +* Input: Serial Port for User Input +* +* Output: Serial Port for String Output +* +* Observation: The HC12 will output the time and a command prompt every second. +* The user can input commands and the program will output a response +* based on the input. +* +* Note: ON CSM-12C128 board, +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H +SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L +SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 +SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 +SCIDRL equ $00CF ; Serial port (SCI) Data Register + +CRGFLG EQU $0037 ; Clock and Reset Generator Flags +CRGINT EQU $0038 ; Clock and Reset Generator Interrupts +RTICTL EQU $003B ; Real Time Interrupt Control + +CR equ $0d ; carriage return, ASCII 'Return' key +LF equ $0a ; line feed, ASCII 'next line' character +NULL equ $00 ; NULL Terminator character + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +buffer ds.b $0010 ; Array of 16 bytes to read a string + dc.b NULL ; NULL terminated +lenBuf dc.w $0010 ; Length of buffer array + +buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal + dc.b NULL ; NULL terminated +lenBuf2 dc.w $0010 ; length of buffer2 + +hours dc.w $0000 ; Buffer to hold the hours of the time + +minutes dc.w $0000 ; Buffer to hold the minutes of the time + +seconds dc.w $0000 ; Buffer to hold the seconds of the time + +counter dc.w $0000 ; Counter for RTI ISR for 1 second + +numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers + +operator dc.b $0000 ; Used by ReadDecimal for reading numbers + +inputBuffer ds.b $0010 ; Input Buffer Length + +lenInput dc.w $0010 ; Length of the Input Buffer + +outputBuf dc.b 'h' ; Used to control what to output on 7 segment display + +* +* There is a section Data Section at the end of the file +************************************************************************** +* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory +* + org $FFF0 ; Memory location for RTI interrupt vector section for simulator + dc.w rtiisr ; Real Time Interrupt vector +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #$0C ; Enable SCI port Tx and Rx units + staa SCICR2 ; disable SCI interrupts + + ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) + std SCIBDH ; SCI port baud rate change + + ldx #msg ; Load the address of the welcome message into X + jsr WriteString ; Write the string to the serial console + + bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board + ; 4MHz quartz oscillator clock + 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 + cli ; Enable interrupts + jsr PrintTime ; Jump to PrintTime to write to serial console +mainLoop + 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 + + ldx #inputBuffer ; Load the address of inputBuffer into X + jsr ExecuteCommand ; Jump to ExecuteCommand + + ldx #inputBuffer ; Load the address of inputBuffer into X + ldy lenInput ; Load the length of inputBuffer into Y + jsr Zeros ; Zero out inputBuffer + + sei ; Disable interrupts + jsr PrintTime ; Jump to PrintTime to print new time + cli ; Enable interrupts + + bra mainLoop ; Loop back to mainLoop always + +TypeWrite + sei ; Disable Interrupts + bclr CRGINT,%10000000; Disable RTI interrupt + ldx #twMsg ; Load the address of twMsg into X + jsr WriteString ; Write the string to the serial console +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 + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +;************************************************************************* +; rtiisr subroutine +; +; This subroutine will increment the counter, seconds, minutes, & hours counters +; to track the time. This subroutine will be called ~400 times a second. +; +; Input: No input other than the timer to call the isr. +; Output: The counter, seconds, minutes, & hours buffers will +; be updated to track the time, the time & prompt will be +; printed every second. +; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. +; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, +; Buffer words for counters, seconds, minutes, & hours buffers. +; +; Comments: The counter buffer should be compared to 400, but for the simulator, +; the counter is compared to 200 to better simulate 1 second on my computer. +; + +rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + ldx counter ; Load counter into X + inx ; Increment counter by 1 + stx counter ; Save X to counter + 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 + inx ; Increment the seconds by 1 + stx seconds ; Save the new seconds to the location + cpx #60 ; Compare X to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the seconds + stx seconds ; Save the new seconds to the location + ldx minutes ; load the minutes into X + inx ; Increment the minutes by 1 + stx minutes ; Save the updated minutes + cpx #60 ; Compare the minutes to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the minutes + stx minutes ; Save the updated minutes + ldx hours ; Load the hours into X + inx ; Increment the hours by 1 + stx hours ; Save the updated hours + cpx #24 ; Compare the hours to 24 + bne rtidone ; If X != 24, exit the isr + ldx #0 ; Reset the hours + stx hours ; Save the updated hours +rtidone jsr PrintTime ; Jump to PrintTime +rtiSkip RTI ; Return from RTI ISR + +;************************************************************************* +; PrintTime subroutine +; +; This subroutine will print the time, command prompt, and maybe an error prompt. +; +; Input: No input. +; Output: The time prompt, time, command prompt, the current input, +; and/or an error on the serial console. +; Registers in use: A for the characters to print, X for buffer addresses, +; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB +; Memory locations in use: Memory Address for serial line, Buffer words for counters, +; seconds, minutes, & hours buffers, and buffer to print time, +; outputBuf for tracking what to output on PORTB. +; +; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine +; will print the current user input if its not finished. +; + +PrintTime + pshd ; Save D to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack + ldaa #CR ; Load the character CR into A + jsr putchar ; Write the character to the serial + ldaa #LF ; Load the character LF into A + jsr putchar ; Write the character to the serial + ldx #clock ; Load the address of the clock prompt into X + jsr WriteString ; Write the string to serial + ldd hours ; Load the hours into D + cpd #10 ; Compare D to 10 + bhs goodHours ; If D >= goodHours + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodHours ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd minutes ; Load the minutes into D + cpd #10 ; Compare D to 10 + bhs goodMins ; If D >= goodMins + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodMins ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd seconds ; Load the seconds into D + cpd #10 ; Compare D to 10 + bhs goodSecs ; If D >= goodSecs + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodSecs ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #' ' ; Load ' ' character into A + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + 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 + 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 subroutine +; +; This subroutine will output the time given on on PORTB for two seven segment displays. +; +; Input: Two Digit Decimal number in register D. +; Output: The given two digit decimal number on PORTB for two 7 segment displays. +; Registers in use: D for the input, and for math to split the digits, X for math to split digits. +; Memory locations in use: PORTB memory location. +; +; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal +; numbers (leading zeros will be added). +; + +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 subroutine +; +; This subroutine will parse user input and execute the proper command or error out. +; +; Input: An address of a NULL terminated string in X. +; Output: The output of the proper command or an error message. +; Registers in use: X for the address of the user input, A for individual characters, +; D & Y for numbers read from user input. +; Memory locations in use: Serial console memory locations. +; +; Comments: This subroutine will disable interrupts while setting the time and will +; reenable them after setting the time. +; + +ExecuteCommand + pshd ; Save D to the stack + pshy ; Save Y to the stack + ldaa 1,x+ ; Load the character from X into A + lbeq ecDone ; If A == 0, jump to ecDone + cmpa #'t' ; Compare A to 't' + bne isH ; If A != 't', branch to isH +skipSpaces ldaa 1,+x ; Load the next character into X + cmpa #' ' ; Compare A to ' ' character + beq skipSpaces ; If A == ' ', loop to skipSpaces + sei ; Disable interrupts + ldd hours ; Load hours into D + pshd ; Save hours to the stack + jsr ReadDecimal ; Read Hour number + exg y,d ; Exchange Y and D + cpd #24 ; Compare D to 24 + lbhs badHours ; If D >= 24, badHours + cpd #0 ; Compare D to 0 + lblt badHours ; If D < 0, badHours + std hours ; Save D to hours + ldaa -1,x ; Load the next character into A + cmpa #':' ; Compare A to ':' + lbne badHours ; If A != ':', badHours + ldd minutes ; Load minutes into D + pshd ; Save minutes to the stack + jsr ReadDecimal ; Read minute number + exg y,d ; Exchange Y and D + cpd #60 ; Compare D to 60 + bhs badMinutes ; If D >= 60, badMinutes + cpd #0 ; Compare D to 0 + blt 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 + 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 + cpd #0 ; Compare D to 0 + blt 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 + 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 +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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra ecDone ; Branch to ecDone +isQ cmpa #'q' ; Compare A to 'q' + bne badCommand ; If A != 'q', branch to badCommand + ldab 1,x+ ; Load next character into B + cmpb #NULL ; Compare B to NULL + bne badCommand ; If B != NULL, branch to ecDone + jmp TypeWrite ; Jump to TypeWrite +badSeconds puld ; Restore Seconds from the stack + std seconds ; Restore seconds before change +badMinutes puld ; Restore minutes from the stack + std minutes ; Restore minutes before change +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 +ecDone puly ; Restore Y from the stack + puld ; Restore D 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 +; its value. +; +; Input: A memory address in register X. +; Output: The value of the number in the Y register, and any errors printed +; to the serial line. Zero bit is set if error occurs. +; Registers in use: X for the address of the contents and for a buffer while printing, +; D for multiplication, B for the character, Y for output value. +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine will return the value in the Y register, and if an error occurs, +; the Zero bit in the CCR will be set. +; + +ReadDecimal + pshd ; Save D to the stack + ldy #0 ; Clear Y register +dHLoop ldab 1,x+ ; Read Next character from X + beq dHDone ; If B == 0, exit loop + cmpb #'+' ; Compare B to '+' + beq dHDone ; If B == '+', end of number + cmpb #'-' ; Compare B to '-' + beq dHDone ; If B == '-', end of number + cmpb #'*' ; Compare B to '*' + beq dHDone ; If B == '+', end of number + cmpb #'/' ; Compare B to '/' + beq dHDone ; If B == '-', end of number + cmpb #':' ; Compare B to ':' + beq dHDone ; If B == '-', end of number + cmpb #' ' ; Compare B to space character + beq dHDone ; If B == ' ', exit loop + cmpb #'0' ; Compare B to '0' character + blt dHError ; If B < '0', bad address, exit loop + cmpb #'9' ; Compare B to '9' character + bhi dHError ; If B > '9', check if 'A'-'F' characters + subb #'0' ; Subtract '0' from B to get true value + pshb ; Save B to the stack + ldd #10 ; load 10 into D + emul ; Multiply Y and D + exg d,y ; Transfer data from D to Y + pulb ; Restore b from the stack + aby ; Add B to Y + bra dHLoop ; Branch always to rHLoop +dHDone clra ; clear A accumulator + tap ; Transfer A into CCR to clear zero bit + puld ; Restore D from the stack + rts ; Return to caller +dHError ldaa #4 ; Load 4 into A to set zero bit in CCR + tap ; Transfer A into CCR to set zero bit and warn error + puld ; Restore D from the stack + rts ; Return to caller + +;************************************************************************* +; strrev subroutine +; +; This subroutine will reverse a string from one buffer into another. +; +; Input: Address of null terminated string in X, address of a large enough +; buffer in Y. +; Output: The string in X reversed in Y. +; Registers in use: X for the address of the string, Y for the address of the buffer, +; A to read characters from the string. +; Memory locations in use: Memory Address for serial line, address of the string & buffer +; +; Comments: This subroutine will not check that the output buffer is large enough, that +; is the job of the caller. +; + +strrev + pshx ; Save X to the stack + pshy ; Save Y to the stack + psha ; Save A to the stack +revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y + beq revDone ; If Character is 0, exit loop + staa 1,x+ ; Save character in address in X, increment X + bra revLoop ; Loop back always + clra ; Set A to Zero +revDone staa 1,x+ ; Copy Null terminator into new string + pula ; Restore A from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller + +;************************************************************************* +; PrintDecimalWord subroutine +; +; This subroutine will print a given word of data to the serial in binary. +; +; Input: 1 word of data in register D, Buffer Address in Y +; Output: Decimal representation of the data on the serial console +; Registers in use: Y for the address of the buffer, X to count the number of bits +; written and for division, D for the input, A for characters. +; Memory locations in use: Memory addresses for serial, and operator to hold sign +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +PrintDecimalWord + pshx ; Save X to the stack + pshy ; Save Y to the stack + pshd ; Save D (A:B) to the stack + cpd #0 ; Compare D to zero + beq dIsZero ; Branch to hIsZero + blt dIsNegative ; If D < 0, Jump to dIsNegative +dAfterNeg psha ; Save A to the stack + pshy ; Save Y to the stack + pshx ; Save x to the stack + ldaa #'0' ; Load the '0' character into A + ldx #buffer2 ; Load the address of buffer2 into X + ldy #5 ; Load 5 into Y + jsr memset ; Write '0' to the first 5 bytes in buffer2 + pulx ; Restore X from the stack + puly ; Restore Y from the stack + clra ; Set A to zero + staa 0,y ; Load Zero into Y for Null Terminator + pula ; Restore A from the stack +dPrintLoop ldx #10 ; Load 10 in X for division + idiv ; Divide D / 10 to get Hex Digit + cpx #0 ; Compare X to 0 + beq dCheck ; If X == 0, branch to check D is zero +dDNotZero addb #'0' ; Add '0' to B to get ASCII Character + stab 1,+y ; Save character from B to Y + exg X,D ; Swap values in X and D + bra dPrintLoop ; Loop to hPrintLoop +dCheck cpd #0 ; Compare D to 0 + bne dDNotZero ; If D != 0, branch back to hDNotZero +dPrintDone ldaa operator ; Load operator into A to see if negative + cmpa #'-' ; Compare A to '-' + bne dNotNeg ; If A != '-', jump to dNotNeg + staa 1,+y ; Save '-' into buffer +dNotNeg ldx #buffer2 ; Load the address of buffer2 in X + jsr strrev ; Reverse string in Y in buffer in X + jsr WriteString ; Jump to write string to write the number + ldy lenBuf2 ; Load the length of buffer2 into Y + ldx #buffer2 ; Load the address of buffer2 into X + jsr Zeros ; Fill buffer2 with zeros + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsZero ldaa #'0' ; Load '0' character into A + jsr putchar ; Print character to the screen + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsNegative psha ; Save A to the stack + ldaa #'-' ; Load '-' into A + staa operator ; Save '-' to operator buffer + pula ; Restore A from the stack + nega ; Two's complement of A + suba #1 ; Subtract 1 from A + negb ; Two'complement of B + subb #1 ; Subtract 1 from B + addd #1 ; Add 1 to D + bra dAfterNeg ; Jump back to dAfterNeg + +;************************************************************************* +; Zeros subroutine +; +; This subroutine will write zeros to every byte in a given array. +; +; Input: Address of an array in X and its length in Y +; Output: Zeros in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for 0 +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +Zeros + psha ; Save A to the Stack + clra ; Clear A +zerosLoop staa 1,x+ ; Load A into byte at X + dbne y,zerosLoop ; Decrement Y and loop if Y != 0 + pula ; Restore A from the stack + rts ; Return to caller + +;************************************************************************* +; memset subroutine +; +; This subroutine will write a given byte to every byte in a given array. +; +; Input: Address of an array in X and its length in Y, the byte in A +; Output: The given byte in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for the given byte +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +memset + staa 1,x+ ; Load A into byte at X + dbne y,memset ; Decrement Y and loop if Y != 0 + rts ; Return to caller + +;************************************************************************* +; WriteString subroutine +; +; This subroutine will write a given null terminated string to the serial. +; +; Input: Address of null terminated string in X +; Output: Null terminated string written to serial +; Registers in use: X for the address of the string and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +WriteString + psha ; Save A to the stack +writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 + beq doneWrite ; if A == 0, branch to doneWrite + jsr putchar ; Jump to putchar to write byte to serial + bra writeLoop ; branch always to writeLoop +doneWrite pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; ReadString subroutine +; +; This subroutine will read a string from the serial line to a given address. +; +; Input: Address of an array in X +; Output: Null terminated string in the given array +; Registers in use: X for the address of the string Y for the length of the string, +; and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and getchar subroutine. +; + +ReadString + psha ; Save accumulator A to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack +readLoop jsr getchar ; Jump to putchar to write byte to serial + beq readLoop ; While A == 0, loop + cmpa #CR ; If A == CR, exit loop + beq doneRead ; Branch to doneRead if A == CR + staa 1,x+ ; Save the byte to the addr in X, then add 1 + jsr putchar ; Write Character back to the terminal + 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 + pulY ; Restore Y from the stack + pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine writes a single byte to a serial line +; +; Input: A single ASCII byte in accumulator A +; Output: Sends one character to SCI port +; Registers in use: Accumulator A with input byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty + staa SCIDRL ; send a character + rts ; Return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine reads one byte from the SCI port +; +; Input: One byte from the SCI port +; Output: One byte in accumulator A +; Registers in use: Accumulator A for output byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 + ldaa SCIDRL ; Read one byte from SCI port into A + rts ; Return to caller +getchar7 clra ; Set A to 0 + rts ; Return to caller + +* +************************************************************************** +* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory +* + +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',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 + +; msg: this is the main option menu string +msg dc.b 'Commands:',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 + dc.b 's: Display the seconds on the 7 segment displays',CR,LF + dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL + + end ; last line of the file diff --git a/cmpen472hw8_McDonnell/bin/Project.abs b/cmpen472hw8_McDonnell/bin/Project.abs new file mode 100644 index 0000000..452be23 Binary files /dev/null and b/cmpen472hw8_McDonnell/bin/Project.abs differ diff --git a/cmpen472hw8_McDonnell/bin/Project.abs.phy b/cmpen472hw8_McDonnell/bin/Project.abs.phy new file mode 100644 index 0000000..05d1923 --- /dev/null +++ b/cmpen472hw8_McDonnell/bin/Project.abs.phy @@ -0,0 +1,3 @@ +S0580000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437325F6877384D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627348 +S2060FFFF0316A60 +S9030000FC diff --git a/cmpen472hw8_McDonnell/bin/Project.abs.s19 b/cmpen472hw8_McDonnell/bin/Project.abs.s19 new file mode 100644 index 0000000..6af90b5 --- /dev/null +++ b/cmpen472hw8_McDonnell/bin/Project.abs.s19 @@ -0,0 +1,44 @@ +S0580000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437325F6877384D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627348 +S123300000000000000000000000000000000000000010000000000000000000000000009C +S123302000000000001000000000000000000000000000000000000000000000000000007C +S106304000106811 +S1233100CF310086F15A03860C5ACBCC00015CC8CE34B71634174C3B194C38804C378086E8 +S1233120FF5A03CE3030FD304016340810EF1631B9CE3030FD3040163423CE30301632665F +S1233140CE3030FD304016340814101631B910EF20DF14104D3880CE3471163417163444D1 +S12331609727FA5A0116343D20F34C3780FE302C087E302C8E00C8263FCE00007E302CFEFE +S1233180302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C2618CE000027 +S12331A07E3028FE3026087E30268E00182606CE00007E30261631B90B3B3534860D163405 +S12331C03D860A16343DCE344D163417FC30268C000A240736863016343D32CD30001633E9 +S12331E099863A16343DFC30288C000A240736863016343D32CD3000163399863A16343D0B +S1233200FC302A8C000A240736863016343D32CD3000163399862016343D16343D16343DD4 +S123322016343DCE3455163417CE3030163417B6304281682605FC3026200C816D2605FCED +S123324030282003FC302A16324E30313A3D3B34CE000A181037B7D4CE000A58585858EAD8 +S1233260B05B01303A3D3B35A630182700D58174266DA620812027FA1410FC30263B163333 +S123328046B7E48C0018182400978C0000182D00907C3026A61F813A18260085FC30283BCD +S12332A0163346B7E48C003C24738C00002D6E7C3028A61F813A2665FC302A3B163346B7A4 +S12332C0E48C003C24538C00002D4E7C302AA61F81002645877A302C10EF3A3A3A2064812A +S12332E068260BE630C100263E7A30422055816D260BE630C100262F7A30422046817326DE +S12333000BE630C10026207A3042203781712617E630C10026110631523A7C302A3A7C3082 +S1233320283A7C302610EF34862016343D16343D16343D16343DCE345B163417CE34631627 +S1233340341730313A3D3BCD0000E630272EC12B272AC12D2726C12A2722C12F271EC13AF7 +S1233360271AC1202716C1302D17C1392213C03037CC000A13B7C63319ED20CE87B7023A58 +S12333803D8604B7023A3D343536A67F27056A3020F8876A303231303D34353B8C00002748 +S12333A04C2D533635348630CE3013CD00051634113031876A4032CE000A18108E00002731 +S12333C008CB306B60B7D420EE8C000026F3B6302F812D26026A60CE3013163387163417E6 +S12333E0FD3024CE30131634083A31303D863016343D3A31303D36862D7A302F3240800173 +S123340050C001C30001209B36876A300436FB323D6A300436FB3D36A630270516343D2032 +S1233420F7323D36353416344427FB810D270A6A3016343D03270220ED3031323D4FCC804F +S1233440FC5ACF3D4FCC200396CF3D873D436C6F636B3E2000434D443E20004572726F72DC +S12334603E2000496E76616C696420496E707574000D0A436C6F636B2073746F70706564D1 +S123348020616E64205479706577726974652070726F6772616D20737461727465642E0D7E +S12334A00A596F75206D617920747970652062656C6F772E0D0A00436F6D6D616E64733A8E +S12334C00D0A743A20536574207468652074696D6520696E20666F726D61742048483A4DD0 +S12334E04D3A53530D0A683A20446973706C61792074686520686F757273206F6E20746841 +S1233500652037207365676D656E7420646973706C6179730D0A6D3A20446973706C61799B +S123352020746865206D696E75746573206F6E207468652037207365676D656E742064694C +S123354073706C6179730D0A733A20446973706C617920746865207365636F6E6473206F12 +S12335606E207468652037207365676D656E7420646973706C6179730D0A713A2053746F6D +S1233580702074686520636C6F636B20616E6420656E74657220747970657772697465721A +S10635A00D0A000D +S105FFF0316A70 +S9030000FC diff --git a/cmpen472hw8_McDonnell/bin/main.dbg b/cmpen472hw8_McDonnell/bin/main.dbg new file mode 100644 index 0000000..94da668 --- /dev/null +++ b/cmpen472hw8_McDonnell/bin/main.dbg @@ -0,0 +1,763 @@ +************************************************************************** +* +* Title: Calculator +* +* Objective: CMPEN 472 Homework 8 +* +* Revision: V1.0 +* +* Date: Mar. 24, 2025 +* +* Programmer: Jacob McDonnell +* +* Company: The Pennsylvania State University +* Department of Computer Science and Engineering +* +* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking +* +* Register Use: A & B to current byte, etc, +* X & Y holds address of strings and length of string, +* D to hold data for printing, reading, and updating time. +* +* Memory Use: RAM Locations from $3000 for data, +* RAM Locations from $3100 for program +* +* Input: Serial Port for User Input +* +* Output: Serial Port for String Output +* +* Observation: The HC12 will output the time and a command prompt every second. +* The user can input commands and the program will output a response +* based on the input. +* +* Note: ON CSM-12C128 board, +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H +SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L +SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 +SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 +SCIDRL equ $00CF ; Serial port (SCI) Data Register + +CRGFLG EQU $0037 ; Clock and Reset Generator Flags +CRGINT EQU $0038 ; Clock and Reset Generator Interrupts +RTICTL EQU $003B ; Real Time Interrupt Control + +CR equ $0d ; carriage return, ASCII 'Return' key +LF equ $0a ; line feed, ASCII 'next line' character +NULL equ $00 ; NULL Terminator character + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +buffer ds.b $0010 ; Array of 16 bytes to read a string + dc.b NULL ; NULL terminated +lenBuf dc.w $0010 ; Length of buffer array + +buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal + dc.b NULL ; NULL terminated +lenBuf2 dc.w $0010 ; length of buffer2 + +hours dc.w $0000 ; Buffer to hold the hours of the time + +minutes dc.w $0000 ; Buffer to hold the minutes of the time + +seconds dc.w $0000 ; Buffer to hold the seconds of the time + +counter dc.w $0000 ; Counter for RTI ISR for 1 second + +numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers + +operator dc.b $0000 ; Used by ReadDecimal for reading numbers + +inputBuffer ds.b $0010 ; Input Buffer Length + +lenInput dc.w $0010 ; Length of the Input Buffer + +outputBuf dc.b 'h' ; Used to control what to output on 7 segment display + +* +* There is a section Data Section at the end of the file +************************************************************************** +* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory +* + org $FFF0 ; Memory location for RTI interrupt vector section for simulator + dc.w rtiisr ; Real Time Interrupt vector +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #$0C ; Enable SCI port Tx and Rx units + staa SCICR2 ; disable SCI interrupts + + ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) + std SCIBDH ; SCI port baud rate change + + ldx #msg ; Load the address of the welcome message into X + jsr WriteString ; Write the string to the serial console + + bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board + ; 4MHz quartz oscillator clock + 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 + cli ; Enable interrupts + jsr PrintTime ; Jump to PrintTime to write to serial console +mainLoop + 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 + + ldx #inputBuffer ; Load the address of inputBuffer into X + jsr ExecuteCommand ; Jump to ExecuteCommand + + ldx #inputBuffer ; Load the address of inputBuffer into X + ldy lenInput ; Load the length of inputBuffer into Y + jsr Zeros ; Zero out inputBuffer + + sei ; Disable interrupts + jsr PrintTime ; Jump to PrintTime to print new time + cli ; Enable interrupts + + bra mainLoop ; Loop back to mainLoop always + +TypeWrite + sei ; Disable Interrupts + bclr CRGINT,%10000000; Disable RTI interrupt + ldx #twMsg ; Load the address of twMsg into X + jsr WriteString ; Write the string to the serial console +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 + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +;************************************************************************* +; rtiisr subroutine +; +; This subroutine will increment the counter, seconds, minutes, & hours counters +; to track the time. This subroutine will be called ~400 times a second. +; +; Input: No input other than the timer to call the isr. +; Output: The counter, seconds, minutes, & hours buffers will +; be updated to track the time, the time & prompt will be +; printed every second. +; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. +; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, +; Buffer words for counters, seconds, minutes, & hours buffers. +; +; Comments: The counter buffer should be compared to 400, but for the simulator, +; the counter is compared to 200 to better simulate 1 second on my computer. +; + +rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + ldx counter ; Load counter into X + inx ; Increment counter by 1 + stx counter ; Save X to counter + 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 + inx ; Increment the seconds by 1 + stx seconds ; Save the new seconds to the location + cpx #60 ; Compare X to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the seconds + stx seconds ; Save the new seconds to the location + ldx minutes ; load the minutes into X + inx ; Increment the minutes by 1 + stx minutes ; Save the updated minutes + cpx #60 ; Compare the minutes to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the minutes + stx minutes ; Save the updated minutes + ldx hours ; Load the hours into X + inx ; Increment the hours by 1 + stx hours ; Save the updated hours + cpx #24 ; Compare the hours to 24 + bne rtidone ; If X != 24, exit the isr + ldx #0 ; Reset the hours + stx hours ; Save the updated hours +rtidone jsr PrintTime ; Jump to PrintTime +rtiSkip RTI ; Return from RTI ISR + +;************************************************************************* +; PrintTime subroutine +; +; This subroutine will print the time, command prompt, and maybe an error prompt. +; +; Input: No input. +; Output: The time prompt, time, command prompt, the current input, +; and/or an error on the serial console. +; Registers in use: A for the characters to print, X for buffer addresses, +; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB +; Memory locations in use: Memory Address for serial line, Buffer words for counters, +; seconds, minutes, & hours buffers, and buffer to print time, +; outputBuf for tracking what to output on PORTB. +; +; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine +; will print the current user input if its not finished. +; + +PrintTime + pshd ; Save D to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack + ldaa #CR ; Load the character CR into A + jsr putchar ; Write the character to the serial + ldaa #LF ; Load the character LF into A + jsr putchar ; Write the character to the serial + ldx #clock ; Load the address of the clock prompt into X + jsr WriteString ; Write the string to serial + ldd hours ; Load the hours into D + cpd #10 ; Compare D to 10 + bhs goodHours ; If D >= goodHours + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodHours ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd minutes ; Load the minutes into D + cpd #10 ; Compare D to 10 + bhs goodMins ; If D >= goodMins + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodMins ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd seconds ; Load the seconds into D + cpd #10 ; Compare D to 10 + bhs goodSecs ; If D >= goodSecs + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodSecs ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #' ' ; Load ' ' character into A + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + 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 + 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 subroutine +; +; This subroutine will output the time given on on PORTB for two seven segment displays. +; +; Input: Two Digit Decimal number in register D. +; Output: The given two digit decimal number on PORTB for two 7 segment displays. +; Registers in use: D for the input, and for math to split the digits, X for math to split digits. +; Memory locations in use: PORTB memory location. +; +; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal +; numbers (leading zeros will be added). +; + +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 subroutine +; +; This subroutine will parse user input and execute the proper command or error out. +; +; Input: An address of a NULL terminated string in X. +; Output: The output of the proper command or an error message. +; Registers in use: X for the address of the user input, A for individual characters, +; D & Y for numbers read from user input. +; Memory locations in use: Serial console memory locations. +; +; Comments: This subroutine will disable interrupts while setting the time and will +; reenable them after setting the time. +; + +ExecuteCommand + pshd ; Save D to the stack + pshy ; Save Y to the stack + ldaa 1,x+ ; Load the character from X into A + lbeq ecDone ; If A == 0, jump to ecDone + cmpa #'t' ; Compare A to 't' + bne isH ; If A != 't', branch to isH +skipSpaces ldaa 1,+x ; Load the next character into X + cmpa #' ' ; Compare A to ' ' character + beq skipSpaces ; If A == ' ', loop to skipSpaces + sei ; Disable interrupts + ldd hours ; Load hours into D + pshd ; Save hours to the stack + jsr ReadDecimal ; Read Hour number + exg y,d ; Exchange Y and D + cpd #24 ; Compare D to 24 + lbhs badHours ; If D >= 24, badHours + cpd #0 ; Compare D to 0 + lblt badHours ; If D < 0, badHours + std hours ; Save D to hours + ldaa -1,x ; Load the next character into A + cmpa #':' ; Compare A to ':' + lbne badHours ; If A != ':', badHours + ldd minutes ; Load minutes into D + pshd ; Save minutes to the stack + jsr ReadDecimal ; Read minute number + exg y,d ; Exchange Y and D + cpd #60 ; Compare D to 60 + bhs badMinutes ; If D >= 60, badMinutes + cpd #0 ; Compare D to 0 + blt 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 + 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 + cpd #0 ; Compare D to 0 + blt 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 + 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 +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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra ecDone ; Branch to ecDone +isQ cmpa #'q' ; Compare A to 'q' + bne badCommand ; If A != 'q', branch to badCommand + ldab 1,x+ ; Load next character into B + cmpb #NULL ; Compare B to NULL + bne badCommand ; If B != NULL, branch to ecDone + jmp TypeWrite ; Jump to TypeWrite +badSeconds puld ; Restore Seconds from the stack + std seconds ; Restore seconds before change +badMinutes puld ; Restore minutes from the stack + std minutes ; Restore minutes before change +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 +ecDone puly ; Restore Y from the stack + puld ; Restore D 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 +; its value. +; +; Input: A memory address in register X. +; Output: The value of the number in the Y register, and any errors printed +; to the serial line. Zero bit is set if error occurs. +; Registers in use: X for the address of the contents and for a buffer while printing, +; D for multiplication, B for the character, Y for output value. +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine will return the value in the Y register, and if an error occurs, +; the Zero bit in the CCR will be set. +; + +ReadDecimal + pshd ; Save D to the stack + ldy #0 ; Clear Y register +dHLoop ldab 1,x+ ; Read Next character from X + beq dHDone ; If B == 0, exit loop + cmpb #'+' ; Compare B to '+' + beq dHDone ; If B == '+', end of number + cmpb #'-' ; Compare B to '-' + beq dHDone ; If B == '-', end of number + cmpb #'*' ; Compare B to '*' + beq dHDone ; If B == '+', end of number + cmpb #'/' ; Compare B to '/' + beq dHDone ; If B == '-', end of number + cmpb #':' ; Compare B to ':' + beq dHDone ; If B == '-', end of number + cmpb #' ' ; Compare B to space character + beq dHDone ; If B == ' ', exit loop + cmpb #'0' ; Compare B to '0' character + blt dHError ; If B < '0', bad address, exit loop + cmpb #'9' ; Compare B to '9' character + bhi dHError ; If B > '9', check if 'A'-'F' characters + subb #'0' ; Subtract '0' from B to get true value + pshb ; Save B to the stack + ldd #10 ; load 10 into D + emul ; Multiply Y and D + exg d,y ; Transfer data from D to Y + pulb ; Restore b from the stack + aby ; Add B to Y + bra dHLoop ; Branch always to rHLoop +dHDone clra ; clear A accumulator + tap ; Transfer A into CCR to clear zero bit + puld ; Restore D from the stack + rts ; Return to caller +dHError ldaa #4 ; Load 4 into A to set zero bit in CCR + tap ; Transfer A into CCR to set zero bit and warn error + puld ; Restore D from the stack + rts ; Return to caller + +;************************************************************************* +; strrev subroutine +; +; This subroutine will reverse a string from one buffer into another. +; +; Input: Address of null terminated string in X, address of a large enough +; buffer in Y. +; Output: The string in X reversed in Y. +; Registers in use: X for the address of the string, Y for the address of the buffer, +; A to read characters from the string. +; Memory locations in use: Memory Address for serial line, address of the string & buffer +; +; Comments: This subroutine will not check that the output buffer is large enough, that +; is the job of the caller. +; + +strrev + pshx ; Save X to the stack + pshy ; Save Y to the stack + psha ; Save A to the stack +revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y + beq revDone ; If Character is 0, exit loop + staa 1,x+ ; Save character in address in X, increment X + bra revLoop ; Loop back always + clra ; Set A to Zero +revDone staa 1,x+ ; Copy Null terminator into new string + pula ; Restore A from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller + +;************************************************************************* +; PrintDecimalWord subroutine +; +; This subroutine will print a given word of data to the serial in binary. +; +; Input: 1 word of data in register D, Buffer Address in Y +; Output: Decimal representation of the data on the serial console +; Registers in use: Y for the address of the buffer, X to count the number of bits +; written and for division, D for the input, A for characters. +; Memory locations in use: Memory addresses for serial, and operator to hold sign +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +PrintDecimalWord + pshx ; Save X to the stack + pshy ; Save Y to the stack + pshd ; Save D (A:B) to the stack + cpd #0 ; Compare D to zero + beq dIsZero ; Branch to hIsZero + blt dIsNegative ; If D < 0, Jump to dIsNegative +dAfterNeg psha ; Save A to the stack + pshy ; Save Y to the stack + pshx ; Save x to the stack + ldaa #'0' ; Load the '0' character into A + ldx #buffer2 ; Load the address of buffer2 into X + ldy #5 ; Load 5 into Y + jsr memset ; Write '0' to the first 5 bytes in buffer2 + pulx ; Restore X from the stack + puly ; Restore Y from the stack + clra ; Set A to zero + staa 0,y ; Load Zero into Y for Null Terminator + pula ; Restore A from the stack +dPrintLoop ldx #10 ; Load 10 in X for division + idiv ; Divide D / 10 to get Hex Digit + cpx #0 ; Compare X to 0 + beq dCheck ; If X == 0, branch to check D is zero +dDNotZero addb #'0' ; Add '0' to B to get ASCII Character + stab 1,+y ; Save character from B to Y + exg X,D ; Swap values in X and D + bra dPrintLoop ; Loop to hPrintLoop +dCheck cpd #0 ; Compare D to 0 + bne dDNotZero ; If D != 0, branch back to hDNotZero +dPrintDone ldaa operator ; Load operator into A to see if negative + cmpa #'-' ; Compare A to '-' + bne dNotNeg ; If A != '-', jump to dNotNeg + staa 1,+y ; Save '-' into buffer +dNotNeg ldx #buffer2 ; Load the address of buffer2 in X + jsr strrev ; Reverse string in Y in buffer in X + jsr WriteString ; Jump to write string to write the number + ldy lenBuf2 ; Load the length of buffer2 into Y + ldx #buffer2 ; Load the address of buffer2 into X + jsr Zeros ; Fill buffer2 with zeros + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsZero ldaa #'0' ; Load '0' character into A + jsr putchar ; Print character to the screen + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsNegative psha ; Save A to the stack + ldaa #'-' ; Load '-' into A + staa operator ; Save '-' to operator buffer + pula ; Restore A from the stack + nega ; Two's complement of A + suba #1 ; Subtract 1 from A + negb ; Two'complement of B + subb #1 ; Subtract 1 from B + addd #1 ; Add 1 to D + bra dAfterNeg ; Jump back to dAfterNeg + +;************************************************************************* +; Zeros subroutine +; +; This subroutine will write zeros to every byte in a given array. +; +; Input: Address of an array in X and its length in Y +; Output: Zeros in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for 0 +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +Zeros + psha ; Save A to the Stack + clra ; Clear A +zerosLoop staa 1,x+ ; Load A into byte at X + dbne y,zerosLoop ; Decrement Y and loop if Y != 0 + pula ; Restore A from the stack + rts ; Return to caller + +;************************************************************************* +; memset subroutine +; +; This subroutine will write a given byte to every byte in a given array. +; +; Input: Address of an array in X and its length in Y, the byte in A +; Output: The given byte in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for the given byte +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +memset + staa 1,x+ ; Load A into byte at X + dbne y,memset ; Decrement Y and loop if Y != 0 + rts ; Return to caller + +;************************************************************************* +; WriteString subroutine +; +; This subroutine will write a given null terminated string to the serial. +; +; Input: Address of null terminated string in X +; Output: Null terminated string written to serial +; Registers in use: X for the address of the string and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +WriteString + psha ; Save A to the stack +writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 + beq doneWrite ; if A == 0, branch to doneWrite + jsr putchar ; Jump to putchar to write byte to serial + bra writeLoop ; branch always to writeLoop +doneWrite pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; ReadString subroutine +; +; This subroutine will read a string from the serial line to a given address. +; +; Input: Address of an array in X +; Output: Null terminated string in the given array +; Registers in use: X for the address of the string Y for the length of the string, +; and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and getchar subroutine. +; + +ReadString + psha ; Save accumulator A to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack +readLoop jsr getchar ; Jump to putchar to write byte to serial + beq readLoop ; While A == 0, loop + cmpa #CR ; If A == CR, exit loop + beq doneRead ; Branch to doneRead if A == CR + staa 1,x+ ; Save the byte to the addr in X, then add 1 + jsr putchar ; Write Character back to the terminal + 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 + pulY ; Restore Y from the stack + pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine writes a single byte to a serial line +; +; Input: A single ASCII byte in accumulator A +; Output: Sends one character to SCI port +; Registers in use: Accumulator A with input byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty + staa SCIDRL ; send a character + rts ; Return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine reads one byte from the SCI port +; +; Input: One byte from the SCI port +; Output: One byte in accumulator A +; Registers in use: Accumulator A for output byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 + ldaa SCIDRL ; Read one byte from SCI port into A + rts ; Return to caller +getchar7 clra ; Set A to 0 + rts ; Return to caller + +* +************************************************************************** +* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory +* + +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',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 + +; msg: this is the main option menu string +msg dc.b 'Commands:',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 + dc.b 's: Display the seconds on the 7 segment displays',CR,LF + dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL + diff --git a/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd new file mode 100644 index 0000000..ac4d359 --- /dev/null +++ b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd @@ -0,0 +1 @@ +// After load the commands written below will be executed diff --git a/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd new file mode 100644 index 0000000..0bed464 --- /dev/null +++ b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd @@ -0,0 +1 @@ +// Before load the commands written below will be executed diff --git a/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd new file mode 100644 index 0000000..bf55944 --- /dev/null +++ b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd @@ -0,0 +1 @@ +// After reset the commands written below will be executed diff --git a/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw8_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell.mcp b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell.mcp new file mode 100644 index 0000000..9377caf Binary files /dev/null and b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell.mcp differ diff --git a/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg new file mode 100644 index 0000000..d39991e Binary files /dev/null and b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg differ diff --git a/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o new file mode 100644 index 0000000..452be23 Binary files /dev/null and b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o differ diff --git a/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx new file mode 100644 index 0000000..9fb3f9a --- /dev/null +++ b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx @@ -0,0 +1,44 @@ +S0840000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437325F6877384D63446F6E6E656C6C5C636D70656E3437325F6877384D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726DC9 +S123300000000000000000000000000000000000000010000000000000000000000000009C +S123302000000000001000000000000000000000000000000000000000000000000000007C +S106304000106811 +S105FFF0316A70 +S1233100CF310086F15A03860C5ACBCC00015CC8CE34B71634174C3B194C38804C378086E8 +S1233120FF5A03CE3030FD304016340810EF1631B9CE3030FD3040163423CE30301632665F +S1233140CE3030FD304016340814101631B910EF20DF14104D3880CE3471163417163444D1 +S12331609727FA5A0116343D20F34C3780FE302C087E302C8E00C8263FCE00007E302CFEFE +S1233180302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C2618CE000027 +S12331A07E3028FE3026087E30268E00182606CE00007E30261631B90B3B3534860D163405 +S12331C03D860A16343DCE344D163417FC30268C000A240736863016343D32CD30001633E9 +S12331E099863A16343DFC30288C000A240736863016343D32CD3000163399863A16343D0B +S1233200FC302A8C000A240736863016343D32CD3000163399862016343D16343D16343DD4 +S123322016343DCE3455163417CE3030163417B6304281682605FC3026200C816D2605FCED +S123324030282003FC302A16324E30313A3D3B34CE000A181037B7D4CE000A58585858EAD8 +S1233260B05B01303A3D3B35A630182700D58174266DA620812027FA1410FC30263B163333 +S123328046B7E48C0018182400978C0000182D00907C3026A61F813A18260085FC30283BCD +S12332A0163346B7E48C003C24738C00002D6E7C3028A61F813A2665FC302A3B163346B7A4 +S12332C0E48C003C24538C00002D4E7C302AA61F81002645877A302C10EF3A3A3A2064812A +S12332E068260BE630C100263E7A30422055816D260BE630C100262F7A30422046817326DE +S12333000BE630C10026207A3042203781712617E630C10026110631523A7C302A3A7C3082 +S1233320283A7C302610EF34862016343D16343D16343D16343DCE345B163417CE34631627 +S1233340341730313A3D3BCD0000E630272EC12B272AC12D2726C12A2722C12F271EC13AF7 +S1233360271AC1202716C1302D17C1392213C03037CC000A13B7C63319ED20CE87B7023A58 +S12333803D8604B7023A3D343536A67F27056A3020F8876A303231303D34353B8C00002748 +S12333A04C2D533635348630CE3013CD00051634113031876A4032CE000A18108E00002731 +S12333C008CB306B60B7D420EE8C000026F3B6302F812D26026A60CE3013163387163417E6 +S12333E0FD3024CE30131634083A31303D863016343D3A31303D36862D7A302F3240800173 +S123340050C001C30001209B36876A300436FB323D6A300436FB3D36A630270516343D2032 +S1233420F7323D36353416344427FB810D270A6A3016343D03270220ED3031323D4FCC804F +S1233440FC5ACF3D4FCC200396CF3D873D436C6F636B3E2000434D443E20004572726F72DC +S12334603E2000496E76616C696420496E707574000D0A436C6F636B2073746F70706564D1 +S123348020616E64205479706577726974652070726F6772616D20737461727465642E0D7E +S12334A00A596F75206D617920747970652062656C6F772E0D0A00436F6D6D616E64733A8E +S12334C00D0A743A20536574207468652074696D6520696E20666F726D61742048483A4DD0 +S12334E04D3A53530D0A683A20446973706C61792074686520686F757273206F6E20746841 +S1233500652037207365676D656E7420646973706C6179730D0A6D3A20446973706C61799B +S123352020746865206D696E75746573206F6E207468652037207365676D656E742064694C +S123354073706C6179730D0A733A20446973706C617920746865207365636F6E6473206F12 +S12335606E207468652037207365676D656E7420646973706C6179730D0A713A2053746F6D +S1233580702074686520636C6F636B20616E6420656E74657220747970657772697465721A +S10635A00D0A000D +S9033100CB diff --git a/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt new file mode 100644 index 0000000..3962bcd Binary files /dev/null and b/cmpen472hw8_McDonnell/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt differ diff --git a/cmpen472hw8_McDonnell/prm/burner.bbl b/cmpen472hw8_McDonnell/prm/burner.bbl new file mode 100644 index 0000000..0c57619 --- /dev/null +++ b/cmpen472hw8_McDonnell/prm/burner.bbl @@ -0,0 +1,157 @@ +/* logical s-record file */ +OPENFILE "%ABS_FILE%.s19" +format=motorola +busWidth=1 +origin=0 +len=0x1000000 +destination=0 +SRECORD=Sx +SENDBYTE 1 "%ABS_FILE%" +CLOSE + + +/* physical s-record file */ +OPENFILE "%ABS_FILE%.phy" +format = motorola +busWidth = 1 +len = 0x4000 + +/* logical non banked flash at $4000 and $C000 to physical */ +origin = 0x004000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" + +origin = 0x00C000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +/* physical FTS512K flash window to physical +origin = 0x008000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS256K parts flash window to physical +origin = 0x008000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS128K parts flash window to physical +origin = 0x008000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS64K parts flash window to physical +origin = 0x008000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS32K parts flash window to physical +origin = 0x008000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* logical 512 kB banked flash to physical */ +origin = 0x208000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x218000 +destination = 0x084000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x228000 +destination = 0x088000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x238000 +destination = 0x08C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x248000 +destination = 0x090000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x258000 +destination = 0x094000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x268000 +destination = 0x098000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x278000 +destination = 0x09C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x288000 +destination = 0x0A0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x298000 +destination = 0x0A4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2A8000 +destination = 0x0A8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2B8000 +destination = 0x0AC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2C8000 +destination = 0x0B0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2D8000 +destination = 0x0B4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2E8000 +destination = 0x0B8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2F8000 +destination = 0x0BC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x308000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x318000 +destination = 0x0C4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x328000 +destination = 0x0C8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x338000 +destination = 0x0CC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x348000 +destination = 0x0D0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x358000 +destination = 0x0D4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x368000 +destination = 0x0D8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x378000 +destination = 0x0DC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x388000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x398000 +destination = 0x0E4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3A8000 +destination = 0x0E8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3B8000 +destination = 0x0EC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3C8000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3D8000 +destination = 0x0F4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3E8000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3F8000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +CLOSE + diff --git a/cmpen472hw9_McDonnell/ASM_layout.hwl b/cmpen472hw9_McDonnell/ASM_layout.hwl new file mode 100644 index 0000000..22795c3 --- /dev/null +++ b/cmpen472hw9_McDonnell/ASM_layout.hwl @@ -0,0 +1,27 @@ +OPEN source 0 0 60 42 +Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off +OPEN assembly 60 0 40 30 +Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0x3100 +OPEN procedure 60 60 40 17 +Procedure < attributes VALUES on,TYPES off +OPEN register 60 30 40 30 +Register < attributes FORMAT AUTO,COMPLEMENT None +OPEN memory 60 77 40 23 +Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 +OPEN data 0 42 60 28 +Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 +OPEN command 0 70 60 30 +Command < attributes CACHESIZE 1000 +OPEN Terminal 10 20 40 69 +Terminal < attributes CACHESIZE 1000 +Terminal < attributes SCI_DEFAULT_TEXT "Virtual SCI",SCI_CONNECTION 0,1,SCI_CONNECTION 1,0,SCI_CONNECTION 1,3,SCI_CONNECTION 3,1,SCI_PORT COM1,SCI_BAUD 9600,SCI_SHOW_PROTOCOL OFF,SCI_VIRTUAL_IN "Sci:2.SerialOutput",SCI_VIRTUAL_OUT "Sci:2.SerialInput",SCI_FILENAME_IN "",SCI_FILENAME_OUT "" +OPEN Visualizationtool 76 37 11 29 +VisualizationTool< Attributes [stEditM="0",swRefresh="3",refCycles="1"] +VisualizationTool< LoadInstrument Seg7[BoundX="26",BoundY="12",Port="0x1",swDM="2"] +VisualizationTool< LoadInstrument Seg7[BoundX="67",BoundY="14",Port="0x1",swDM="1"] +VisualizationTool< LoadInstrument DILSwitch[BoundX="25",BoundY="106",Port="0x1"] +VisualizationTool< ResetVT Undo +bckcolor 50331647 +font 'Courier New' 9 BLACK +AUTOSIZE on +ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Source" "Procedure" "Terminal" "VisualizationTool" diff --git a/cmpen472hw9_McDonnell/Default.mem b/cmpen472hw9_McDonnell/Default.mem new file mode 100644 index 0000000..bf49148 Binary files /dev/null and b/cmpen472hw9_McDonnell/Default.mem differ diff --git a/cmpen472hw9_McDonnell/Full_Chip_Simulation.hwc b/cmpen472hw9_McDonnell/Full_Chip_Simulation.hwc new file mode 100644 index 0000000..f3ce7c9 --- /dev/null +++ b/cmpen472hw9_McDonnell/Full_Chip_Simulation.hwc @@ -0,0 +1 @@ +LOADMEM default.mem diff --git a/cmpen472hw9_McDonnell/Full_Chip_Simulation.ini b/cmpen472hw9_McDonnell/Full_Chip_Simulation.ini new file mode 100644 index 0000000..9b2a0df --- /dev/null +++ b/cmpen472hw9_McDonnell/Full_Chip_Simulation.ini @@ -0,0 +1,42 @@ +[Environment Variables] +GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib +LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include +OBJPATH={Project}bin +TEXTPATH={Project}bin +ABSPATH={Project}bin + +[HI-WAVE] +Target=sim +Layout=ASM_layout.hwl +LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD +CPU=HC12 +MainFrame=0,1,-1,-1,-1,-1,459,132,2322,1148 +Configuration=Full_Chip_Simulation.hwc +Statusbar=1 +ShowToolbar=1 +Smallborder=0 +Hideheadline=0 +Hidetitle=0 +TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 + + + + + + + + + +[Simulator] +CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" + +[Simulator HC12] +CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" +CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" +CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" +CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" +HCS12_SUPPORT=1 +FCS=MC9S12C32 +ZEROTIMEATRESET=1 +OSCFREQUENCY=48000000 +DISPLAYTIME=0 diff --git a/cmpen472hw9_McDonnell/Sources/derivative.inc b/cmpen472hw9_McDonnell/Sources/derivative.inc new file mode 100644 index 0000000..988343b --- /dev/null +++ b/cmpen472hw9_McDonnell/Sources/derivative.inc @@ -0,0 +1,10 @@ + + ; Note: This file is recreated by the project wizard whenever the MCU is + ; changed and should not be edited by hand + ; + + ; include derivative specific macros + INCLUDE 'mc9s12c32.inc' + + + diff --git a/cmpen472hw9_McDonnell/Sources/main.asm b/cmpen472hw9_McDonnell/Sources/main.asm new file mode 100644 index 0000000..c25cf81 --- /dev/null +++ b/cmpen472hw9_McDonnell/Sources/main.asm @@ -0,0 +1,929 @@ +************************************************************************** +* +* Title: Calculator Clock +* +* Objective: CMPEN 472 Homework 9 +* +* Revision: V1.0 +* +* Date: Apr. 2, 2025 +* +* Programmer: Jacob McDonnell +* +* Company: The Pennsylvania State University +* Department of Computer Science and Engineering +* +* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking +* +* Register Use: A & B to current byte, etc, +* X & Y holds address of strings and length of string, +* D to hold data for printing, reading, and updating time. +* +* Memory Use: RAM Locations from $3000 for data, +* RAM Locations from $3100 for program +* +* Input: Serial Port for User Input +* +* Output: Serial Port for String Output +* +* Observation: The HC12 will output the time and a command prompt every second. +* The user can input commands and the program will output a response +* based on the input. +* +* Note: ON CSM-12C128 board, +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H +SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L +SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 +SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 +SCIDRL equ $00CF ; Serial port (SCI) Data Register + +CRGFLG EQU $0037 ; Clock and Reset Generator Flags +CRGINT EQU $0038 ; Clock and Reset Generator Interrupts +RTICTL EQU $003B ; Real Time Interrupt Control + +CR equ $0d ; carriage return, ASCII 'Return' key +LF equ $0a ; line feed, ASCII 'next line' character +NULL equ $00 ; NULL Terminator character + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +buffer ds.b $0010 ; Array of 16 bytes to read a string + dc.b NULL ; NULL terminated +lenBuf dc.w $0010 ; Length of buffer array + +buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal + dc.b NULL ; NULL terminated +lenBuf2 dc.w $0010 ; length of buffer2 + +hours dc.w $0000 ; Buffer to hold the hours of the time + +minutes dc.w $0000 ; Buffer to hold the minutes of the time + +seconds dc.w $0000 ; Buffer to hold the seconds of the time + +counter dc.w $0000 ; Counter for RTI ISR for 1 second + +numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers + +operator dc.b $0000 ; Used by ReadDecimal for reading numbers + +inputBuffer ds.b $0010 ; Input Buffer Length + +lenInput dc.w $0010 ; Length of the Input Buffer + +outputBuf dc.b 'h' ; Used to control what to output on 7 segment display + +* +* There is a section Data Section at the end of the file +************************************************************************** +* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory +* + org $FFF0 ; Memory location for RTI interrupt vector section for simulator + dc.w rtiisr ; Real Time Interrupt vector +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #$0C ; Enable SCI port Tx and Rx units + staa SCICR2 ; disable SCI interrupts + + ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) + std SCIBDH ; SCI port baud rate change + + ldx #msg ; Load the address of the welcome message into X + jsr WriteString ; Write the string to the serial console + + bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board + ; 4MHz quartz oscillator clock + 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 + cli ; Enable interrupts + jsr PrintTime ; Jump to PrintTime to write to serial console +mainLoop + 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 + + ldx #inputBuffer ; Load the address of inputBuffer into X + jsr ExecuteCommand ; Jump to ExecuteCommand + + ldx #inputBuffer ; Load the address of inputBuffer into X + ldy lenInput ; Load the length of inputBuffer into Y + jsr Zeros ; Zero out inputBuffer + + sei ; Disable interrupts + jsr PrintTime ; Jump to PrintTime to print new time + cli ; Enable interrupts + + bra mainLoop ; Loop back to mainLoop always + +TypeWrite + sei ; Disable Interrupts + bclr CRGINT,%10000000; Disable RTI interrupt + ldx #twMsg ; Load the address of twMsg into X + jsr WriteString ; Write the string to the serial console +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 + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +;************************************************************************* +; rtiisr subroutine +; +; This subroutine will increment the counter, seconds, minutes, & hours counters +; to track the time. This subroutine will be called ~400 times a second. +; +; Input: No input other than the timer to call the isr. +; Output: The counter, seconds, minutes, & hours buffers will +; be updated to track the time, the time & prompt will be +; printed every second. +; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. +; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, +; Buffer words for counters, seconds, minutes, & hours buffers. +; +; Comments: The counter buffer should be compared to 400, but for the simulator, +; the counter is compared to 200 to better simulate 1 second on my computer. +; + +rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + ldx counter ; Load counter into X + inx ; Increment counter by 1 + stx counter ; Save X to counter + 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 + inx ; Increment the seconds by 1 + stx seconds ; Save the new seconds to the location + cpx #60 ; Compare X to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the seconds + stx seconds ; Save the new seconds to the location + ldx minutes ; load the minutes into X + inx ; Increment the minutes by 1 + stx minutes ; Save the updated minutes + cpx #60 ; Compare the minutes to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the minutes + stx minutes ; Save the updated minutes + ldx hours ; Load the hours into X + inx ; Increment the hours by 1 + stx hours ; Save the updated hours + cpx #24 ; Compare the hours to 24 + bne rtidone ; If X != 24, exit the isr + ldx #0 ; Reset the hours + stx hours ; Save the updated hours +rtidone jsr PrintTime ; Jump to PrintTime +rtiSkip RTI ; Return from RTI ISR + +;************************************************************************* +; PrintTime subroutine +; +; This subroutine will print the time, command prompt, and maybe an error prompt. +; +; Input: No input. +; Output: The time prompt, time, command prompt, the current input, +; and/or an error on the serial console. +; Registers in use: A for the characters to print, X for buffer addresses, +; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB +; Memory locations in use: Memory Address for serial line, Buffer words for counters, +; seconds, minutes, & hours buffers, and buffer to print time, +; outputBuf for tracking what to output on PORTB. +; +; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine +; will print the current user input if its not finished. +; + +PrintTime + pshd ; Save D to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack + ldaa #CR ; Load the character CR into A + jsr putchar ; Write the character to the serial + ldaa #LF ; Load the character LF into A + jsr putchar ; Write the character to the serial + ldx #clock ; Load the address of the clock prompt into X + jsr WriteString ; Write the string to serial + ldd hours ; Load the hours into D + cpd #10 ; Compare D to 10 + bhs goodHours ; If D >= goodHours + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodHours ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd minutes ; Load the minutes into D + cpd #10 ; Compare D to 10 + bhs goodMins ; If D >= goodMins + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodMins ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd seconds ; Load the seconds into D + cpd #10 ; Compare D to 10 + bhs goodSecs ; If D >= goodSecs + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodSecs ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #' ' ; Load ' ' character into A + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + 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 + 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 subroutine +; +; This subroutine will output the time given on on PORTB for two seven segment displays. +; +; Input: Two Digit Decimal number in register D. +; Output: The given two digit decimal number on PORTB for two 7 segment displays. +; Registers in use: D for the input, and for math to split the digits, X for math to split digits. +; Memory locations in use: PORTB memory location. +; +; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal +; numbers (leading zeros will be added). +; + +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 subroutine +; +; This subroutine will parse user input and execute the proper command or error out. +; +; Input: An address of a NULL terminated string in X. +; Output: The output of the proper command or an error message. +; Registers in use: X for the address of the user input, A for individual characters, +; D & Y for numbers read from user input. +; Memory locations in use: Serial console memory locations. +; +; Comments: This subroutine will disable interrupts while setting the time and will +; reenable them after setting the time. +; + +ExecuteCommand + pshd ; Save D to the stack + pshy ; Save Y to the stack + ldaa 1,x+ ; Load the character from X into A + lbeq ecDone ; If A == 0, jump to ecDone + cmpa #'t' ; Compare A to 't' + bne isH ; If A != 't', branch to isH +skipSpaces ldaa 1,+x ; Load the next character into X + cmpa #' ' ; Compare A to ' ' character + beq skipSpaces ; If A == ' ', loop to skipSpaces + sei ; Disable interrupts + ldd hours ; Load hours into D + pshd ; Save hours to the stack + jsr ReadDecimal ; Read Hour number + exg y,d ; Exchange Y and D + cpd #24 ; Compare D to 24 + lbhs badHours ; If D >= 24, badHours + cpd #0 ; Compare D to 0 + lblt badHours ; If D < 0, badHours + std hours ; Save D to hours + ldaa -1,x ; Load the next character into A + cmpa #':' ; Compare A to ':' + lbne badHours ; If A != ':', badHours + ldd minutes ; Load minutes into D + pshd ; Save minutes to the stack + jsr ReadDecimal ; Read minute number + exg y,d ; Exchange Y and D + cpd #60 ; Compare D to 60 + bhs badMinutes ; If D >= 60, badMinutes + cpd #0 ; Compare D to 0 + blt 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 + 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 + cpd #0 ; Compare D to 0 + blt 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 + 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 +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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra ecDone ; Branch to ecDone +isQ cmpa #'q' ; Compare A to 'q' + bne isEquation ; If A != 'q', branch to isEquation + ldab 1,x+ ; Load next character into B + cmpb #NULL ; Compare B to NULL + bne 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 +badSeconds puld ; Restore Seconds from the stack + std seconds ; Restore seconds before change +badMinutes puld ; Restore minutes from the stack + std minutes ; Restore minutes before change +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 +ecDone puly ; Restore Y from the stack + puld ; Restore D 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 + pulx ; Restore X from the stack + jsr WriteString ; Write original equation to serial console + 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 + ldaa #CR ; Load CR into A + jsr putchar ; Jump to putchar to write CR + ldaa #LF ; Load LF into A + jsr putchar ; Jump to putchar to write CR + puld ; Restore D from the stack + puly ; Restore Y from the stack + rts ; Return to caller +sOverflow pulx ; Restore X from the stack + pshx ; Save X to the stack + jsr WriteString ; Write original string to serial console + ldaa #CR ; Load CR into A + jsr putchar ; Jump to putchar to write CR + ldaa #LF ; Load LF into A + jsr putchar ; Jump to putchar to write CR + 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 +; its value. +; +; Input: A memory address in register X. +; Output: The value of the number in the Y register, and any errors printed +; to the serial line. Zero bit is set if error occurs. +; Registers in use: X for the address of the contents and for a buffer while printing, +; D for multiplication, B for the character, Y for output value. +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine will return the value in the Y register, and if an error occurs, +; the Zero bit in the CCR will be set. +; + +ReadDecimal + pshd ; Save D to the stack + ldy #0 ; Clear Y register +dHLoop ldab 1,x+ ; Read Next character from X + beq dHDone ; If B == 0, exit loop + cmpb #'+' ; Compare B to '+' + beq dHDone ; If B == '+', end of number + cmpb #'-' ; Compare B to '-' + beq dHDone ; If B == '-', end of number + cmpb #'*' ; Compare B to '*' + beq dHDone ; If B == '+', end of number + cmpb #'/' ; Compare B to '/' + beq dHDone ; If B == '-', end of number + cmpb #':' ; Compare B to ':' + beq dHDone ; If B == '-', end of number + cmpb #' ' ; Compare B to space character + beq dHDone ; If B == ' ', exit loop + cmpb #'0' ; Compare B to '0' character + blt dHError ; If B < '0', bad address, exit loop + cmpb #'9' ; Compare B to '9' character + bhi dHError ; If B > '9', check if 'A'-'F' characters + subb #'0' ; Subtract '0' from B to get true value + pshb ; Save B to the stack + ldd #10 ; load 10 into D + emul ; Multiply Y and D + exg d,y ; Transfer data from D to Y + pulb ; Restore b from the stack + aby ; Add B to Y + bra dHLoop ; Branch always to rHLoop +dHDone clra ; clear A accumulator + tap ; Transfer A into CCR to clear zero bit + puld ; Restore D from the stack + rts ; Return to caller +dHError ldaa #4 ; Load 4 into A to set zero bit in CCR + tap ; Transfer A into CCR to set zero bit and warn error + puld ; Restore D from the stack + rts ; Return to caller + +;************************************************************************* +; strrev subroutine +; +; This subroutine will reverse a string from one buffer into another. +; +; Input: Address of null terminated string in X, address of a large enough +; buffer in Y. +; Output: The string in X reversed in Y. +; Registers in use: X for the address of the string, Y for the address of the buffer, +; A to read characters from the string. +; Memory locations in use: Memory Address for serial line, address of the string & buffer +; +; Comments: This subroutine will not check that the output buffer is large enough, that +; is the job of the caller. +; + +strrev + pshx ; Save X to the stack + pshy ; Save Y to the stack + psha ; Save A to the stack +revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y + beq revDone ; If Character is 0, exit loop + staa 1,x+ ; Save character in address in X, increment X + bra revLoop ; Loop back always + clra ; Set A to Zero +revDone staa 1,x+ ; Copy Null terminator into new string + pula ; Restore A from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller + +;************************************************************************* +; PrintDecimalWord subroutine +; +; This subroutine will print a given word of data to the serial in binary. +; +; Input: 1 word of data in register D, Buffer Address in Y +; Output: Decimal representation of the data on the serial console +; Registers in use: Y for the address of the buffer, X to count the number of bits +; written and for division, D for the input, A for characters. +; Memory locations in use: Memory addresses for serial, and operator to hold sign +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +PrintDecimalWord + pshx ; Save X to the stack + pshy ; Save Y to the stack + pshd ; Save D (A:B) to the stack + cpd #0 ; Compare D to zero + beq dIsZero ; Branch to hIsZero + blt dIsNegative ; If D < 0, Jump to dIsNegative +dAfterNeg psha ; Save A to the stack + pshy ; Save Y to the stack + pshx ; Save x to the stack + ldaa #'0' ; Load the '0' character into A + ldx #buffer2 ; Load the address of buffer2 into X + ldy #5 ; Load 5 into Y + jsr memset ; Write '0' to the first 5 bytes in buffer2 + pulx ; Restore X from the stack + puly ; Restore Y from the stack + clra ; Set A to zero + staa 0,y ; Load Zero into Y for Null Terminator + pula ; Restore A from the stack +dPrintLoop ldx #10 ; Load 10 in X for division + idiv ; Divide D / 10 to get Hex Digit + cpx #0 ; Compare X to 0 + beq dCheck ; If X == 0, branch to check D is zero +dDNotZero addb #'0' ; Add '0' to B to get ASCII Character + stab 1,+y ; Save character from B to Y + exg X,D ; Swap values in X and D + bra dPrintLoop ; Loop to hPrintLoop +dCheck cpd #0 ; Compare D to 0 + bne dDNotZero ; If D != 0, branch back to hDNotZero +dPrintDone ldaa operator ; Load operator into A to see if negative + cmpa #'-' ; Compare A to '-' + bne dNotNeg ; If A != '-', jump to dNotNeg + staa 1,+y ; Save '-' into buffer +dNotNeg ldx #buffer2 ; Load the address of buffer2 in X + jsr strrev ; Reverse string in Y in buffer in X + jsr WriteString ; Jump to write string to write the number + ldy lenBuf2 ; Load the length of buffer2 into Y + ldx #buffer2 ; Load the address of buffer2 into X + jsr Zeros ; Fill buffer2 with zeros + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsZero ldaa #'0' ; Load '0' character into A + jsr putchar ; Print character to the screen + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsNegative psha ; Save A to the stack + ldaa #'-' ; Load '-' into A + staa operator ; Save '-' to operator buffer + pula ; Restore A from the stack + nega ; Two's complement of A + suba #1 ; Subtract 1 from A + negb ; Two'complement of B + subb #1 ; Subtract 1 from B + addd #1 ; Add 1 to D + bra dAfterNeg ; Jump back to dAfterNeg + +;************************************************************************* +; Zeros subroutine +; +; This subroutine will write zeros to every byte in a given array. +; +; Input: Address of an array in X and its length in Y +; Output: Zeros in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for 0 +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +Zeros + psha ; Save A to the Stack + clra ; Clear A +zerosLoop staa 1,x+ ; Load A into byte at X + dbne y,zerosLoop ; Decrement Y and loop if Y != 0 + pula ; Restore A from the stack + rts ; Return to caller + +;************************************************************************* +; memset subroutine +; +; This subroutine will write a given byte to every byte in a given array. +; +; Input: Address of an array in X and its length in Y, the byte in A +; Output: The given byte in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for the given byte +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +memset + staa 1,x+ ; Load A into byte at X + dbne y,memset ; Decrement Y and loop if Y != 0 + rts ; Return to caller + +;************************************************************************* +; WriteString subroutine +; +; This subroutine will write a given null terminated string to the serial. +; +; Input: Address of null terminated string in X +; Output: Null terminated string written to serial +; Registers in use: X for the address of the string and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +WriteString + psha ; Save A to the stack +writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 + beq doneWrite ; if A == 0, branch to doneWrite + jsr putchar ; Jump to putchar to write byte to serial + bra writeLoop ; branch always to writeLoop +doneWrite pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; ReadString subroutine +; +; This subroutine will read a string from the serial line to a given address. +; +; Input: Address of an array in X +; Output: Null terminated string in the given array +; Registers in use: X for the address of the string Y for the length of the string, +; and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and getchar subroutine. +; + +ReadString + psha ; Save accumulator A to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack +readLoop jsr getchar ; Jump to putchar to write byte to serial + beq readLoop ; While A == 0, loop + cmpa #CR ; If A == CR, exit loop + beq doneRead ; Branch to doneRead if A == CR + staa 1,x+ ; Save the byte to the addr in X, then add 1 + jsr putchar ; Write Character back to the terminal + 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 + pulY ; Restore Y from the stack + pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine writes a single byte to a serial line +; +; Input: A single ASCII byte in accumulator A +; Output: Sends one character to SCI port +; Registers in use: Accumulator A with input byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty + staa SCIDRL ; send a character + rts ; Return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine reads one byte from the SCI port +; +; Input: One byte from the SCI port +; Output: One byte in accumulator A +; Registers in use: Accumulator A for output byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 + ldaa SCIDRL ; Read one byte from SCI port into A + rts ; Return to caller +getchar7 clra ; Set A to 0 + rts ; Return to caller + +* +************************************************************************** +* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory +* + +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',NULL ; Invalid Input Prompt + +overflow dc.b 'Overflow Error',CR,LF,NULL ; Overflow error message + +; 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 + +; msg: this is the main option menu string +msg dc.b 'Commands:',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 + dc.b 's: Display the seconds on the 7 segment displays',CR,LF + dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL + + end ; last line of the file diff --git a/cmpen472hw9_McDonnell/bin/Project.abs b/cmpen472hw9_McDonnell/bin/Project.abs new file mode 100644 index 0000000..782e71a Binary files /dev/null and b/cmpen472hw9_McDonnell/bin/Project.abs differ diff --git a/cmpen472hw9_McDonnell/bin/Project.abs.phy b/cmpen472hw9_McDonnell/bin/Project.abs.phy new file mode 100644 index 0000000..6675b33 --- /dev/null +++ b/cmpen472hw9_McDonnell/bin/Project.abs.phy @@ -0,0 +1,3 @@ +S0580000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877395F4D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627347 +S2060FFFF0316A60 +S9030000FC diff --git a/cmpen472hw9_McDonnell/bin/Project.abs.s19 b/cmpen472hw9_McDonnell/bin/Project.abs.s19 new file mode 100644 index 0000000..60fd630 --- /dev/null +++ b/cmpen472hw9_McDonnell/bin/Project.abs.s19 @@ -0,0 +1,52 @@ +S0580000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877395F4D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627347 +S123300000000000000000000000000000000000000010000000000000000000000000009C +S123302000000000001000000000000000000000000000000000000000000000000000007C +S106304000106811 +S1233100CF310086F15A03860C5ACBCC00015CC8CE35BF16350E4C3B194C38804C378086E7 +S1233120FF5A03CE3030FD30401634FF10EF1631B9CE3030FD304016351ACE303016326670 +S1233140CE3030FD30401634FF14101631B910EF20DF14104D3880CE357916350E16353BE1 +S12331609727FA5A0116353420F34C3780FE302C087E302C8E00C8263FCE00007E302CFE06 +S1233180302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C2618CE000027 +S12331A07E3028FE3026087E30268E00182606CE00007E30261631B90B3B3534860D163504 +S12331C034860A163534CE354416350EFC30268C000A240736863016353432CD3000163411 +S12331E090863A163534FC30288C000A240736863016353432CD3000163490863A16353434 +S1233200FC302A8C000A240736863016353432CD30001634908620163534163534163534FC +S1233220163534CE354C16350ECE303016350EB6304281682605FC3026200C816D2605FC0D +S123324030282003FC302A16324E30313A3D3B34CE000A181037B7D4CE000A58585858EAD8 +S1233260B05B01303A3D3B35A630182700E08174266DA620812027FA1410FC30263B163427 +S12332803DB7E48C0018182400A28C0000182D009B7C3026A61F813A18260090FC30283BB5 +S12332A016343DB7E48C003C247E8C00002D797C3028A61F813A2670FC302A3B16343DB793 +S12332C0E48C003C245E8C00002D597C302AA61F81002650877A302C10EF3A3A3A206F81FE +S12332E068260BE630C10026497A30422060816D260BE630C100263A7A30422051817326B2 +S12333000BE630C100262B7A3042204281712609E630C100261C063152091633D4271316EF +S12333203351202A3A7C302A3A7C30283A7C302610EF3486201635341635341635341635F0 +S123334034CE355216350ECE355A16350E30313A3D353B3416343D35A61F16343D812B277A +S123336013812D271A812A2721B7E531B7E41810B7D4201F7D302E31B7E4F3302E20147D51 +S1233380302E31B7E4B3302E2009B7E431138D000026288C270F2E238CD8F12D1E301635DD +S12333A00E36863D16353432CD3000163490860D163534860A1635343A313D303416350EF4 +S12333C0860D163534860A163534CE356816350E303A313D353B34C77B302FCD0000A63044 +S12333E08139222081302D08028D0004221620EE812B271B812D2717812A2713812F270F69 +S123340081002723876A008604B702303A313D7A302FA61E81302DEC813922E8CB01C10118 +S123342022E2CD000020B7A61E81302DD7813922D3B6302F27CE87B702303A313D3BCD008E +S123344000E630272EC12B272AC12D2726C12A2722C12F271EC13A271AC1202716C1302DA4 +S123346017C1392213C03037CC000A13B7C63319ED20CE87B7023A3D8604B7023A3D343574 +S123348036A67F27056A3020F8876A303231303D34353B8C0000274C2D533635348630CEB8 +S12334A03013CD00051635083031876A4032CE000A18108E00002708CB306B60B7D420EEC0 +S12334C08C000026F3B6302F812D26026A60CE301316347E16350EFD3024CE30131634FFB1 +S12334E03A31303D86301635343A31303D36862D7A302F3240800150C001C30001209B3668 +S1233500876A300436FB323D6A300436FB3D36A630270516353420F7323D36353416353B74 +S123352027FB810D270A6A3016353403270220ED3031323D4FCC80FC5ACF3D4FCC200396B3 +S1233540CF3D873D436C6F636B3E2000434D443E20004572726F723E2000496E76616C6950 +S12335606420496E707574004F766572666C6F77204572726F720D0A000D0A436C6F636B1B +S12335802073746F7070656420616E64205479706577726974652070726F6772616D20731D +S12335A07461727465642E0D0A596F75206D617920747970652062656C6F772E0D0A0043F7 +S12335C06F6D6D616E64733A0D0A743A20536574207468652074696D6520696E20666F721F +S12335E06D61742048483A4D4D3A53530D0A683A20446973706C61792074686520686F75A5 +S12336007273206F6E207468652037207365676D656E7420646973706C6179730D0A6D3AB2 +S123362020446973706C617920746865206D696E75746573206F6E2074686520372073655D +S1233640676D656E7420646973706C6179730D0A733A20446973706C617920746865207314 +S123366065636F6E6473206F6E207468652037207365676D656E7420646973706C61797379 +S12336800D0A713A2053746F702074686520636C6F636B20616E6420656E74657220747973 +S10E36A070657772697465720D0A0092 +S105FFF0316A70 +S9030000FC diff --git a/cmpen472hw9_McDonnell/bin/main.dbg b/cmpen472hw9_McDonnell/bin/main.dbg new file mode 100644 index 0000000..5a7a005 --- /dev/null +++ b/cmpen472hw9_McDonnell/bin/main.dbg @@ -0,0 +1,928 @@ +************************************************************************** +* +* Title: Calculator Clock +* +* Objective: CMPEN 472 Homework 9 +* +* Revision: V1.0 +* +* Date: Apr. 2, 2025 +* +* Programmer: Jacob McDonnell +* +* Company: The Pennsylvania State University +* Department of Computer Science and Engineering +* +* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking +* +* Register Use: A & B to current byte, etc, +* X & Y holds address of strings and length of string, +* D to hold data for printing, reading, and updating time. +* +* Memory Use: RAM Locations from $3000 for data, +* RAM Locations from $3100 for program +* +* Input: Serial Port for User Input +* +* Output: Serial Port for String Output +* +* Observation: The HC12 will output the time and a command prompt every second. +* The user can input commands and the program will output a response +* based on the input. +* +* Note: ON CSM-12C128 board, +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H +SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L +SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 +SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 +SCIDRL equ $00CF ; Serial port (SCI) Data Register + +CRGFLG EQU $0037 ; Clock and Reset Generator Flags +CRGINT EQU $0038 ; Clock and Reset Generator Interrupts +RTICTL EQU $003B ; Real Time Interrupt Control + +CR equ $0d ; carriage return, ASCII 'Return' key +LF equ $0a ; line feed, ASCII 'next line' character +NULL equ $00 ; NULL Terminator character + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +buffer ds.b $0010 ; Array of 16 bytes to read a string + dc.b NULL ; NULL terminated +lenBuf dc.w $0010 ; Length of buffer array + +buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal + dc.b NULL ; NULL terminated +lenBuf2 dc.w $0010 ; length of buffer2 + +hours dc.w $0000 ; Buffer to hold the hours of the time + +minutes dc.w $0000 ; Buffer to hold the minutes of the time + +seconds dc.w $0000 ; Buffer to hold the seconds of the time + +counter dc.w $0000 ; Counter for RTI ISR for 1 second + +numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers + +operator dc.b $0000 ; Used by ReadDecimal for reading numbers + +inputBuffer ds.b $0010 ; Input Buffer Length + +lenInput dc.w $0010 ; Length of the Input Buffer + +outputBuf dc.b 'h' ; Used to control what to output on 7 segment display + +* +* There is a section Data Section at the end of the file +************************************************************************** +* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory +* + org $FFF0 ; Memory location for RTI interrupt vector section for simulator + dc.w rtiisr ; Real Time Interrupt vector +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #$0C ; Enable SCI port Tx and Rx units + staa SCICR2 ; disable SCI interrupts + + ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) + std SCIBDH ; SCI port baud rate change + + ldx #msg ; Load the address of the welcome message into X + jsr WriteString ; Write the string to the serial console + + bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board + ; 4MHz quartz oscillator clock + 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 + cli ; Enable interrupts + jsr PrintTime ; Jump to PrintTime to write to serial console +mainLoop + 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 + + ldx #inputBuffer ; Load the address of inputBuffer into X + jsr ExecuteCommand ; Jump to ExecuteCommand + + ldx #inputBuffer ; Load the address of inputBuffer into X + ldy lenInput ; Load the length of inputBuffer into Y + jsr Zeros ; Zero out inputBuffer + + sei ; Disable interrupts + jsr PrintTime ; Jump to PrintTime to print new time + cli ; Enable interrupts + + bra mainLoop ; Loop back to mainLoop always + +TypeWrite + sei ; Disable Interrupts + bclr CRGINT,%10000000; Disable RTI interrupt + ldx #twMsg ; Load the address of twMsg into X + jsr WriteString ; Write the string to the serial console +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 + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +;************************************************************************* +; rtiisr subroutine +; +; This subroutine will increment the counter, seconds, minutes, & hours counters +; to track the time. This subroutine will be called ~400 times a second. +; +; Input: No input other than the timer to call the isr. +; Output: The counter, seconds, minutes, & hours buffers will +; be updated to track the time, the time & prompt will be +; printed every second. +; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. +; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, +; Buffer words for counters, seconds, minutes, & hours buffers. +; +; Comments: The counter buffer should be compared to 400, but for the simulator, +; the counter is compared to 200 to better simulate 1 second on my computer. +; + +rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + ldx counter ; Load counter into X + inx ; Increment counter by 1 + stx counter ; Save X to counter + 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 + inx ; Increment the seconds by 1 + stx seconds ; Save the new seconds to the location + cpx #60 ; Compare X to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the seconds + stx seconds ; Save the new seconds to the location + ldx minutes ; load the minutes into X + inx ; Increment the minutes by 1 + stx minutes ; Save the updated minutes + cpx #60 ; Compare the minutes to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the minutes + stx minutes ; Save the updated minutes + ldx hours ; Load the hours into X + inx ; Increment the hours by 1 + stx hours ; Save the updated hours + cpx #24 ; Compare the hours to 24 + bne rtidone ; If X != 24, exit the isr + ldx #0 ; Reset the hours + stx hours ; Save the updated hours +rtidone jsr PrintTime ; Jump to PrintTime +rtiSkip RTI ; Return from RTI ISR + +;************************************************************************* +; PrintTime subroutine +; +; This subroutine will print the time, command prompt, and maybe an error prompt. +; +; Input: No input. +; Output: The time prompt, time, command prompt, the current input, +; and/or an error on the serial console. +; Registers in use: A for the characters to print, X for buffer addresses, +; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB +; Memory locations in use: Memory Address for serial line, Buffer words for counters, +; seconds, minutes, & hours buffers, and buffer to print time, +; outputBuf for tracking what to output on PORTB. +; +; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine +; will print the current user input if its not finished. +; + +PrintTime + pshd ; Save D to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack + ldaa #CR ; Load the character CR into A + jsr putchar ; Write the character to the serial + ldaa #LF ; Load the character LF into A + jsr putchar ; Write the character to the serial + ldx #clock ; Load the address of the clock prompt into X + jsr WriteString ; Write the string to serial + ldd hours ; Load the hours into D + cpd #10 ; Compare D to 10 + bhs goodHours ; If D >= goodHours + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodHours ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd minutes ; Load the minutes into D + cpd #10 ; Compare D to 10 + bhs goodMins ; If D >= goodMins + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodMins ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd seconds ; Load the seconds into D + cpd #10 ; Compare D to 10 + bhs goodSecs ; If D >= goodSecs + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodSecs ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #' ' ; Load ' ' character into A + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + 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 + 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 subroutine +; +; This subroutine will output the time given on on PORTB for two seven segment displays. +; +; Input: Two Digit Decimal number in register D. +; Output: The given two digit decimal number on PORTB for two 7 segment displays. +; Registers in use: D for the input, and for math to split the digits, X for math to split digits. +; Memory locations in use: PORTB memory location. +; +; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal +; numbers (leading zeros will be added). +; + +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 subroutine +; +; This subroutine will parse user input and execute the proper command or error out. +; +; Input: An address of a NULL terminated string in X. +; Output: The output of the proper command or an error message. +; Registers in use: X for the address of the user input, A for individual characters, +; D & Y for numbers read from user input. +; Memory locations in use: Serial console memory locations. +; +; Comments: This subroutine will disable interrupts while setting the time and will +; reenable them after setting the time. +; + +ExecuteCommand + pshd ; Save D to the stack + pshy ; Save Y to the stack + ldaa 1,x+ ; Load the character from X into A + lbeq ecDone ; If A == 0, jump to ecDone + cmpa #'t' ; Compare A to 't' + bne isH ; If A != 't', branch to isH +skipSpaces ldaa 1,+x ; Load the next character into X + cmpa #' ' ; Compare A to ' ' character + beq skipSpaces ; If A == ' ', loop to skipSpaces + sei ; Disable interrupts + ldd hours ; Load hours into D + pshd ; Save hours to the stack + jsr ReadDecimal ; Read Hour number + exg y,d ; Exchange Y and D + cpd #24 ; Compare D to 24 + lbhs badHours ; If D >= 24, badHours + cpd #0 ; Compare D to 0 + lblt badHours ; If D < 0, badHours + std hours ; Save D to hours + ldaa -1,x ; Load the next character into A + cmpa #':' ; Compare A to ':' + lbne badHours ; If A != ':', badHours + ldd minutes ; Load minutes into D + pshd ; Save minutes to the stack + jsr ReadDecimal ; Read minute number + exg y,d ; Exchange Y and D + cpd #60 ; Compare D to 60 + bhs badMinutes ; If D >= 60, badMinutes + cpd #0 ; Compare D to 0 + blt 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 + 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 + cpd #0 ; Compare D to 0 + blt 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 + 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 +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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra ecDone ; Branch to ecDone +isQ cmpa #'q' ; Compare A to 'q' + bne isEquation ; If A != 'q', branch to isEquation + ldab 1,x+ ; Load next character into B + cmpb #NULL ; Compare B to NULL + bne 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 +badSeconds puld ; Restore Seconds from the stack + std seconds ; Restore seconds before change +badMinutes puld ; Restore minutes from the stack + std minutes ; Restore minutes before change +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 +ecDone puly ; Restore Y from the stack + puld ; Restore D 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 + pulx ; Restore X from the stack + jsr WriteString ; Write original equation to serial console + 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 + ldaa #CR ; Load CR into A + jsr putchar ; Jump to putchar to write CR + ldaa #LF ; Load LF into A + jsr putchar ; Jump to putchar to write CR + puld ; Restore D from the stack + puly ; Restore Y from the stack + rts ; Return to caller +sOverflow pulx ; Restore X from the stack + pshx ; Save X to the stack + jsr WriteString ; Write original string to serial console + ldaa #CR ; Load CR into A + jsr putchar ; Jump to putchar to write CR + ldaa #LF ; Load LF into A + jsr putchar ; Jump to putchar to write CR + 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 +; its value. +; +; Input: A memory address in register X. +; Output: The value of the number in the Y register, and any errors printed +; to the serial line. Zero bit is set if error occurs. +; Registers in use: X for the address of the contents and for a buffer while printing, +; D for multiplication, B for the character, Y for output value. +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine will return the value in the Y register, and if an error occurs, +; the Zero bit in the CCR will be set. +; + +ReadDecimal + pshd ; Save D to the stack + ldy #0 ; Clear Y register +dHLoop ldab 1,x+ ; Read Next character from X + beq dHDone ; If B == 0, exit loop + cmpb #'+' ; Compare B to '+' + beq dHDone ; If B == '+', end of number + cmpb #'-' ; Compare B to '-' + beq dHDone ; If B == '-', end of number + cmpb #'*' ; Compare B to '*' + beq dHDone ; If B == '+', end of number + cmpb #'/' ; Compare B to '/' + beq dHDone ; If B == '-', end of number + cmpb #':' ; Compare B to ':' + beq dHDone ; If B == '-', end of number + cmpb #' ' ; Compare B to space character + beq dHDone ; If B == ' ', exit loop + cmpb #'0' ; Compare B to '0' character + blt dHError ; If B < '0', bad address, exit loop + cmpb #'9' ; Compare B to '9' character + bhi dHError ; If B > '9', check if 'A'-'F' characters + subb #'0' ; Subtract '0' from B to get true value + pshb ; Save B to the stack + ldd #10 ; load 10 into D + emul ; Multiply Y and D + exg d,y ; Transfer data from D to Y + pulb ; Restore b from the stack + aby ; Add B to Y + bra dHLoop ; Branch always to rHLoop +dHDone clra ; clear A accumulator + tap ; Transfer A into CCR to clear zero bit + puld ; Restore D from the stack + rts ; Return to caller +dHError ldaa #4 ; Load 4 into A to set zero bit in CCR + tap ; Transfer A into CCR to set zero bit and warn error + puld ; Restore D from the stack + rts ; Return to caller + +;************************************************************************* +; strrev subroutine +; +; This subroutine will reverse a string from one buffer into another. +; +; Input: Address of null terminated string in X, address of a large enough +; buffer in Y. +; Output: The string in X reversed in Y. +; Registers in use: X for the address of the string, Y for the address of the buffer, +; A to read characters from the string. +; Memory locations in use: Memory Address for serial line, address of the string & buffer +; +; Comments: This subroutine will not check that the output buffer is large enough, that +; is the job of the caller. +; + +strrev + pshx ; Save X to the stack + pshy ; Save Y to the stack + psha ; Save A to the stack +revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y + beq revDone ; If Character is 0, exit loop + staa 1,x+ ; Save character in address in X, increment X + bra revLoop ; Loop back always + clra ; Set A to Zero +revDone staa 1,x+ ; Copy Null terminator into new string + pula ; Restore A from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller + +;************************************************************************* +; PrintDecimalWord subroutine +; +; This subroutine will print a given word of data to the serial in binary. +; +; Input: 1 word of data in register D, Buffer Address in Y +; Output: Decimal representation of the data on the serial console +; Registers in use: Y for the address of the buffer, X to count the number of bits +; written and for division, D for the input, A for characters. +; Memory locations in use: Memory addresses for serial, and operator to hold sign +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +PrintDecimalWord + pshx ; Save X to the stack + pshy ; Save Y to the stack + pshd ; Save D (A:B) to the stack + cpd #0 ; Compare D to zero + beq dIsZero ; Branch to hIsZero + blt dIsNegative ; If D < 0, Jump to dIsNegative +dAfterNeg psha ; Save A to the stack + pshy ; Save Y to the stack + pshx ; Save x to the stack + ldaa #'0' ; Load the '0' character into A + ldx #buffer2 ; Load the address of buffer2 into X + ldy #5 ; Load 5 into Y + jsr memset ; Write '0' to the first 5 bytes in buffer2 + pulx ; Restore X from the stack + puly ; Restore Y from the stack + clra ; Set A to zero + staa 0,y ; Load Zero into Y for Null Terminator + pula ; Restore A from the stack +dPrintLoop ldx #10 ; Load 10 in X for division + idiv ; Divide D / 10 to get Hex Digit + cpx #0 ; Compare X to 0 + beq dCheck ; If X == 0, branch to check D is zero +dDNotZero addb #'0' ; Add '0' to B to get ASCII Character + stab 1,+y ; Save character from B to Y + exg X,D ; Swap values in X and D + bra dPrintLoop ; Loop to hPrintLoop +dCheck cpd #0 ; Compare D to 0 + bne dDNotZero ; If D != 0, branch back to hDNotZero +dPrintDone ldaa operator ; Load operator into A to see if negative + cmpa #'-' ; Compare A to '-' + bne dNotNeg ; If A != '-', jump to dNotNeg + staa 1,+y ; Save '-' into buffer +dNotNeg ldx #buffer2 ; Load the address of buffer2 in X + jsr strrev ; Reverse string in Y in buffer in X + jsr WriteString ; Jump to write string to write the number + ldy lenBuf2 ; Load the length of buffer2 into Y + ldx #buffer2 ; Load the address of buffer2 into X + jsr Zeros ; Fill buffer2 with zeros + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsZero ldaa #'0' ; Load '0' character into A + jsr putchar ; Print character to the screen + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsNegative psha ; Save A to the stack + ldaa #'-' ; Load '-' into A + staa operator ; Save '-' to operator buffer + pula ; Restore A from the stack + nega ; Two's complement of A + suba #1 ; Subtract 1 from A + negb ; Two'complement of B + subb #1 ; Subtract 1 from B + addd #1 ; Add 1 to D + bra dAfterNeg ; Jump back to dAfterNeg + +;************************************************************************* +; Zeros subroutine +; +; This subroutine will write zeros to every byte in a given array. +; +; Input: Address of an array in X and its length in Y +; Output: Zeros in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for 0 +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +Zeros + psha ; Save A to the Stack + clra ; Clear A +zerosLoop staa 1,x+ ; Load A into byte at X + dbne y,zerosLoop ; Decrement Y and loop if Y != 0 + pula ; Restore A from the stack + rts ; Return to caller + +;************************************************************************* +; memset subroutine +; +; This subroutine will write a given byte to every byte in a given array. +; +; Input: Address of an array in X and its length in Y, the byte in A +; Output: The given byte in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for the given byte +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +memset + staa 1,x+ ; Load A into byte at X + dbne y,memset ; Decrement Y and loop if Y != 0 + rts ; Return to caller + +;************************************************************************* +; WriteString subroutine +; +; This subroutine will write a given null terminated string to the serial. +; +; Input: Address of null terminated string in X +; Output: Null terminated string written to serial +; Registers in use: X for the address of the string and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +WriteString + psha ; Save A to the stack +writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 + beq doneWrite ; if A == 0, branch to doneWrite + jsr putchar ; Jump to putchar to write byte to serial + bra writeLoop ; branch always to writeLoop +doneWrite pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; ReadString subroutine +; +; This subroutine will read a string from the serial line to a given address. +; +; Input: Address of an array in X +; Output: Null terminated string in the given array +; Registers in use: X for the address of the string Y for the length of the string, +; and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and getchar subroutine. +; + +ReadString + psha ; Save accumulator A to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack +readLoop jsr getchar ; Jump to putchar to write byte to serial + beq readLoop ; While A == 0, loop + cmpa #CR ; If A == CR, exit loop + beq doneRead ; Branch to doneRead if A == CR + staa 1,x+ ; Save the byte to the addr in X, then add 1 + jsr putchar ; Write Character back to the terminal + 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 + pulY ; Restore Y from the stack + pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine writes a single byte to a serial line +; +; Input: A single ASCII byte in accumulator A +; Output: Sends one character to SCI port +; Registers in use: Accumulator A with input byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty + staa SCIDRL ; send a character + rts ; Return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine reads one byte from the SCI port +; +; Input: One byte from the SCI port +; Output: One byte in accumulator A +; Registers in use: Accumulator A for output byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 + ldaa SCIDRL ; Read one byte from SCI port into A + rts ; Return to caller +getchar7 clra ; Set A to 0 + rts ; Return to caller + +* +************************************************************************** +* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory +* + +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',NULL ; Invalid Input Prompt + +overflow dc.b 'Overflow Error',CR,LF,NULL ; Overflow error message + +; 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 + +; msg: this is the main option menu string +msg dc.b 'Commands:',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 + dc.b 's: Display the seconds on the 7 segment displays',CR,LF + dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL + diff --git a/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd new file mode 100644 index 0000000..ac4d359 --- /dev/null +++ b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Postload.cmd @@ -0,0 +1 @@ +// After load the commands written below will be executed diff --git a/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd new file mode 100644 index 0000000..0bed464 --- /dev/null +++ b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Preload.cmd @@ -0,0 +1 @@ +// Before load the commands written below will be executed diff --git a/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd new file mode 100644 index 0000000..bf55944 --- /dev/null +++ b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Reset.cmd @@ -0,0 +1 @@ +// After reset the commands written below will be executed diff --git a/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_SetCPU.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/cmpen472hw9_McDonnell/cmd/Full_Chip_Simulation_Startup.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell.mcp b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell.mcp new file mode 100644 index 0000000..9377caf Binary files /dev/null and b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell.mcp differ diff --git a/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/CWSettingsWindows.stg b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/CWSettingsWindows.stg new file mode 100644 index 0000000..1f2028b Binary files /dev/null and b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/CWSettingsWindows.stg differ diff --git a/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/ObjectCode/main.asm.o new file mode 100644 index 0000000..782e71a Binary files /dev/null and b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/ObjectCode/main.asm.o differ diff --git a/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/ObjectCode/main.asm.sx new file mode 100644 index 0000000..ade6ef0 --- /dev/null +++ b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/ObjectCode/main.asm.sx @@ -0,0 +1,52 @@ +S0840000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877395F4D63446F6E6E656C6C5C636D70656E3437326877395F4D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726DC7 +S123300000000000000000000000000000000000000010000000000000000000000000009C +S123302000000000001000000000000000000000000000000000000000000000000000007C +S106304000106811 +S105FFF0316A70 +S1233100CF310086F15A03860C5ACBCC00015CC8CE35BF16350E4C3B194C38804C378086E7 +S1233120FF5A03CE3030FD30401634FF10EF1631B9CE3030FD304016351ACE303016326670 +S1233140CE3030FD30401634FF14101631B910EF20DF14104D3880CE357916350E16353BE1 +S12331609727FA5A0116353420F34C3780FE302C087E302C8E00C8263FCE00007E302CFE06 +S1233180302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C2618CE000027 +S12331A07E3028FE3026087E30268E00182606CE00007E30261631B90B3B3534860D163504 +S12331C034860A163534CE354416350EFC30268C000A240736863016353432CD3000163411 +S12331E090863A163534FC30288C000A240736863016353432CD3000163490863A16353434 +S1233200FC302A8C000A240736863016353432CD30001634908620163534163534163534FC +S1233220163534CE354C16350ECE303016350EB6304281682605FC3026200C816D2605FC0D +S123324030282003FC302A16324E30313A3D3B34CE000A181037B7D4CE000A58585858EAD8 +S1233260B05B01303A3D3B35A630182700E08174266DA620812027FA1410FC30263B163427 +S12332803DB7E48C0018182400A28C0000182D009B7C3026A61F813A18260090FC30283BB5 +S12332A016343DB7E48C003C247E8C00002D797C3028A61F813A2670FC302A3B16343DB793 +S12332C0E48C003C245E8C00002D597C302AA61F81002650877A302C10EF3A3A3A206F81FE +S12332E068260BE630C10026497A30422060816D260BE630C100263A7A30422051817326B2 +S12333000BE630C100262B7A3042204281712609E630C100261C063152091633D4271316EF +S12333203351202A3A7C302A3A7C30283A7C302610EF3486201635341635341635341635F0 +S123334034CE355216350ECE355A16350E30313A3D353B3416343D35A61F16343D812B277A +S123336013812D271A812A2721B7E531B7E41810B7D4201F7D302E31B7E4F3302E20147D51 +S1233380302E31B7E4B3302E2009B7E431138D000026288C270F2E238CD8F12D1E301635DD +S12333A00E36863D16353432CD3000163490860D163534860A1635343A313D303416350EF4 +S12333C0860D163534860A163534CE356816350E303A313D353B34C77B302FCD0000A63044 +S12333E08139222081302D08028D0004221620EE812B271B812D2717812A2713812F270F69 +S123340081002723876A008604B702303A313D7A302FA61E81302DEC813922E8CB01C10118 +S123342022E2CD000020B7A61E81302DD7813922D3B6302F27CE87B702303A313D3BCD008E +S123344000E630272EC12B272AC12D2726C12A2722C12F271EC13A271AC1202716C1302DA4 +S123346017C1392213C03037CC000A13B7C63319ED20CE87B7023A3D8604B7023A3D343574 +S123348036A67F27056A3020F8876A303231303D34353B8C0000274C2D533635348630CEB8 +S12334A03013CD00051635083031876A4032CE000A18108E00002708CB306B60B7D420EEC0 +S12334C08C000026F3B6302F812D26026A60CE301316347E16350EFD3024CE30131634FFB1 +S12334E03A31303D86301635343A31303D36862D7A302F3240800150C001C30001209B3668 +S1233500876A300436FB323D6A300436FB3D36A630270516353420F7323D36353416353B74 +S123352027FB810D270A6A3016353403270220ED3031323D4FCC80FC5ACF3D4FCC200396B3 +S1233540CF3D873D436C6F636B3E2000434D443E20004572726F723E2000496E76616C6950 +S12335606420496E707574004F766572666C6F77204572726F720D0A000D0A436C6F636B1B +S12335802073746F7070656420616E64205479706577726974652070726F6772616D20731D +S12335A07461727465642E0D0A596F75206D617920747970652062656C6F772E0D0A0043F7 +S12335C06F6D6D616E64733A0D0A743A20536574207468652074696D6520696E20666F721F +S12335E06D61742048483A4D4D3A53530D0A683A20446973706C61792074686520686F75A5 +S12336007273206F6E207468652037207365676D656E7420646973706C6179730D0A6D3AB2 +S123362020446973706C617920746865206D696E75746573206F6E2074686520372073655D +S1233640676D656E7420646973706C6179730D0A733A20446973706C617920746865207314 +S123366065636F6E6473206F6E207468652037207365676D656E7420646973706C61797379 +S12336800D0A713A2053746F702074686520636C6F636B20616E6420656E74657220747973 +S10E36A070657772697465720D0A0092 +S9033100CB diff --git a/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/TargetDataWindows.tdt new file mode 100644 index 0000000..f951fc3 Binary files /dev/null and b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/Standard/TargetDataWindows.tdt differ diff --git a/cmpen472hw9_McDonnell/prm/burner.bbl b/cmpen472hw9_McDonnell/prm/burner.bbl new file mode 100644 index 0000000..0c57619 --- /dev/null +++ b/cmpen472hw9_McDonnell/prm/burner.bbl @@ -0,0 +1,157 @@ +/* logical s-record file */ +OPENFILE "%ABS_FILE%.s19" +format=motorola +busWidth=1 +origin=0 +len=0x1000000 +destination=0 +SRECORD=Sx +SENDBYTE 1 "%ABS_FILE%" +CLOSE + + +/* physical s-record file */ +OPENFILE "%ABS_FILE%.phy" +format = motorola +busWidth = 1 +len = 0x4000 + +/* logical non banked flash at $4000 and $C000 to physical */ +origin = 0x004000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" + +origin = 0x00C000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +/* physical FTS512K flash window to physical +origin = 0x008000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS256K parts flash window to physical +origin = 0x008000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS128K parts flash window to physical +origin = 0x008000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS64K parts flash window to physical +origin = 0x008000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS32K parts flash window to physical +origin = 0x008000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* logical 512 kB banked flash to physical */ +origin = 0x208000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x218000 +destination = 0x084000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x228000 +destination = 0x088000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x238000 +destination = 0x08C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x248000 +destination = 0x090000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x258000 +destination = 0x094000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x268000 +destination = 0x098000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x278000 +destination = 0x09C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x288000 +destination = 0x0A0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x298000 +destination = 0x0A4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2A8000 +destination = 0x0A8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2B8000 +destination = 0x0AC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2C8000 +destination = 0x0B0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2D8000 +destination = 0x0B4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2E8000 +destination = 0x0B8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2F8000 +destination = 0x0BC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x308000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x318000 +destination = 0x0C4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x328000 +destination = 0x0C8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x338000 +destination = 0x0CC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x348000 +destination = 0x0D0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x358000 +destination = 0x0D4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x368000 +destination = 0x0D8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x378000 +destination = 0x0DC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x388000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x398000 +destination = 0x0E4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3A8000 +destination = 0x0E8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3B8000 +destination = 0x0EC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3C8000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3D8000 +destination = 0x0F4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3E8000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3F8000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +CLOSE + diff --git a/exam2prep/ASM_layout.hwl b/exam2prep/ASM_layout.hwl new file mode 100644 index 0000000..22795c3 --- /dev/null +++ b/exam2prep/ASM_layout.hwl @@ -0,0 +1,27 @@ +OPEN source 0 0 60 42 +Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off +OPEN assembly 60 0 40 30 +Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0x3100 +OPEN procedure 60 60 40 17 +Procedure < attributes VALUES on,TYPES off +OPEN register 60 30 40 30 +Register < attributes FORMAT AUTO,COMPLEMENT None +OPEN memory 60 77 40 23 +Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,ADDRESS 0x80 +OPEN data 0 42 60 28 +Data < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16 +OPEN command 0 70 60 30 +Command < attributes CACHESIZE 1000 +OPEN Terminal 10 20 40 69 +Terminal < attributes CACHESIZE 1000 +Terminal < attributes SCI_DEFAULT_TEXT "Virtual SCI",SCI_CONNECTION 0,1,SCI_CONNECTION 1,0,SCI_CONNECTION 1,3,SCI_CONNECTION 3,1,SCI_PORT COM1,SCI_BAUD 9600,SCI_SHOW_PROTOCOL OFF,SCI_VIRTUAL_IN "Sci:2.SerialOutput",SCI_VIRTUAL_OUT "Sci:2.SerialInput",SCI_FILENAME_IN "",SCI_FILENAME_OUT "" +OPEN Visualizationtool 76 37 11 29 +VisualizationTool< Attributes [stEditM="0",swRefresh="3",refCycles="1"] +VisualizationTool< LoadInstrument Seg7[BoundX="26",BoundY="12",Port="0x1",swDM="2"] +VisualizationTool< LoadInstrument Seg7[BoundX="67",BoundY="14",Port="0x1",swDM="1"] +VisualizationTool< LoadInstrument DILSwitch[BoundX="25",BoundY="106",Port="0x1"] +VisualizationTool< ResetVT Undo +bckcolor 50331647 +font 'Courier New' 9 BLACK +AUTOSIZE on +ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Source" "Procedure" "Terminal" "VisualizationTool" diff --git a/exam2prep/Default.mem b/exam2prep/Default.mem new file mode 100644 index 0000000..bf49148 Binary files /dev/null and b/exam2prep/Default.mem differ diff --git a/exam2prep/Full_Chip_Simulation.hwc b/exam2prep/Full_Chip_Simulation.hwc new file mode 100644 index 0000000..f3ce7c9 --- /dev/null +++ b/exam2prep/Full_Chip_Simulation.hwc @@ -0,0 +1 @@ +LOADMEM default.mem diff --git a/exam2prep/Full_Chip_Simulation.ini b/exam2prep/Full_Chip_Simulation.ini new file mode 100644 index 0000000..7eb98ae --- /dev/null +++ b/exam2prep/Full_Chip_Simulation.ini @@ -0,0 +1,42 @@ +[Environment Variables] +GENPATH={Project}Sources;{Compiler}lib\hc12c\src;{Compiler}lib\hc12c\include;{Compiler}lib\hc12c\lib;{Compiler}lib\xgatec\src;{Compiler}lib\xgatec\include;{Compiler}lib\xgatec\lib +LIBPATH={Compiler}lib\hc12c\include;{Compiler}lib\xgatec\include +OBJPATH={Project}bin +TEXTPATH={Project}bin +ABSPATH={Project}bin + +[HI-WAVE] +Target=sim +Layout=ASM_layout.hwl +LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD +CPU=HC12 +MainFrame=0,1,-1,-1,-1,-1,625,183,1726,1199 +Configuration=Full_Chip_Simulation.hwc +Statusbar=1 +ShowToolbar=1 +Smallborder=0 +Hideheadline=0 +Hidetitle=0 +TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806 + + + + + + + + + +[Simulator] +CMDFILE0=CMDFILE STARTUP ON ".\cmd\Full_Chip_Simulation_startup.cmd" + +[Simulator HC12] +CMDFILE0=CMDFILE RESET ON ".\cmd\Full_Chip_Simulation_reset.cmd" +CMDFILE1=CMDFILE PRELOAD ON ".\cmd\Full_Chip_Simulation_preload.cmd" +CMDFILE2=CMDFILE POSTLOAD ON ".\cmd\Full_Chip_Simulation_postload.cmd" +CMDFILE3=CMDFILE SETCPU ON ".\cmd\Full_Chip_Simulation_setcpu.cmd" +HCS12_SUPPORT=1 +FCS=MC9S12C32 +ZEROTIMEATRESET=1 +OSCFREQUENCY=48000000 +DISPLAYTIME=0 diff --git a/exam2prep/Sources/cmpen472hw8_McDonnell.asm b/exam2prep/Sources/cmpen472hw8_McDonnell.asm new file mode 100644 index 0000000..cbfe22a --- /dev/null +++ b/exam2prep/Sources/cmpen472hw8_McDonnell.asm @@ -0,0 +1,764 @@ +************************************************************************** +* +* Title: Calculator +* +* Objective: CMPEN 472 Homework 8 +* +* Revision: V1.0 +* +* Date: Mar. 24, 2025 +* +* Programmer: Jacob McDonnell +* +* Company: The Pennsylvania State University +* Department of Computer Science and Engineering +* +* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking +* +* Register Use: A & B to current byte, etc, +* X & Y holds address of strings and length of string, +* D to hold data for printing, reading, and updating time. +* +* Memory Use: RAM Locations from $3000 for data, +* RAM Locations from $3100 for program +* +* Input: Serial Port for User Input +* +* Output: Serial Port for String Output +* +* Observation: The HC12 will output the time and a command prompt every second. +* The user can input commands and the program will output a response +* based on the input. +* +* Note: ON CSM-12C128 board, +* +* 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 + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H +SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L +SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 +SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 +SCIDRL equ $00CF ; Serial port (SCI) Data Register + +CRGFLG EQU $0037 ; Clock and Reset Generator Flags +CRGINT EQU $0038 ; Clock and Reset Generator Interrupts +RTICTL EQU $003B ; Real Time Interrupt Control + +CR equ $0d ; carriage return, ASCII 'Return' key +LF equ $0a ; line feed, ASCII 'next line' character +NULL equ $00 ; NULL Terminator character + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +buffer ds.b $0010 ; Array of 16 bytes to read a string + dc.b NULL ; NULL terminated +lenBuf dc.w $0010 ; Length of buffer array + +buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal + dc.b NULL ; NULL terminated +lenBuf2 dc.w $0010 ; length of buffer2 + +hours dc.w $0000 ; Buffer to hold the hours of the time + +minutes dc.w $0000 ; Buffer to hold the minutes of the time + +seconds dc.w $0000 ; Buffer to hold the seconds of the time + +counter dc.w $0000 ; Counter for RTI ISR for 1 second + +numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers + +operator dc.b $0000 ; Used by ReadDecimal for reading numbers + +inputBuffer ds.b $0010 ; Input Buffer Length + +lenInput dc.w $0010 ; Length of the Input Buffer + +outputBuf dc.b 'h' ; Used to control what to output on 7 segment display + +* +* There is a section Data Section at the end of the file +************************************************************************** +* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory +* + org $FFF0 ; Memory location for RTI interrupt vector section for simulator + dc.w rtiisr ; Real Time Interrupt vector +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #$0C ; Enable SCI port Tx and Rx units + staa SCICR2 ; disable SCI interrupts + + ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) + std SCIBDH ; SCI port baud rate change + + ldx #msg ; Load the address of the welcome message into X + jsr WriteString ; Write the string to the serial console + + bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board + ; 4MHz quartz oscillator clock + 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 + cli ; Enable interrupts + jsr PrintTime ; Jump to PrintTime to write to serial console +mainLoop + 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 + + ldx #inputBuffer ; Load the address of inputBuffer into X + jsr ExecuteCommand ; Jump to ExecuteCommand + + ldx #inputBuffer ; Load the address of inputBuffer into X + ldy lenInput ; Load the length of inputBuffer into Y + jsr Zeros ; Zero out inputBuffer + + sei ; Disable interrupts + jsr PrintTime ; Jump to PrintTime to print new time + cli ; Enable interrupts + + bra mainLoop ; Loop back to mainLoop always + +TypeWrite + sei ; Disable Interrupts + bclr CRGINT,%10000000; Disable RTI interrupt + ldx #twMsg ; Load the address of twMsg into X + jsr WriteString ; Write the string to the serial console +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 + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +;************************************************************************* +; rtiisr subroutine +; +; This subroutine will increment the counter, seconds, minutes, & hours counters +; to track the time. This subroutine will be called ~400 times a second. +; +; Input: No input other than the timer to call the isr. +; Output: The counter, seconds, minutes, & hours buffers will +; be updated to track the time, the time & prompt will be +; printed every second. +; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. +; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, +; Buffer words for counters, seconds, minutes, & hours buffers. +; +; Comments: The counter buffer should be compared to 400, but for the simulator, +; the counter is compared to 200 to better simulate 1 second on my computer. +; + +rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + ldx counter ; Load counter into X + inx ; Increment counter by 1 + stx counter ; Save X to counter + 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 + inx ; Increment the seconds by 1 + stx seconds ; Save the new seconds to the location + cpx #60 ; Compare X to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the seconds + stx seconds ; Save the new seconds to the location + ldx minutes ; load the minutes into X + inx ; Increment the minutes by 1 + stx minutes ; Save the updated minutes + cpx #60 ; Compare the minutes to 60 + bne rtidone ; If X != 60, exit isr + ldx #0 ; Reset the minutes + stx minutes ; Save the updated minutes + ldx hours ; Load the hours into X + inx ; Increment the hours by 1 + stx hours ; Save the updated hours + cpx #24 ; Compare the hours to 24 + bne rtidone ; If X != 24, exit the isr + ldx #0 ; Reset the hours + stx hours ; Save the updated hours +rtidone jsr PrintTime ; Jump to PrintTime +rtiSkip RTI ; Return from RTI ISR + +;************************************************************************* +; PrintTime subroutine +; +; This subroutine will print the time, command prompt, and maybe an error prompt. +; +; Input: No input. +; Output: The time prompt, time, command prompt, the current input, +; and/or an error on the serial console. +; Registers in use: A for the characters to print, X for buffer addresses, +; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB +; Memory locations in use: Memory Address for serial line, Buffer words for counters, +; seconds, minutes, & hours buffers, and buffer to print time, +; outputBuf for tracking what to output on PORTB. +; +; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine +; will print the current user input if its not finished. +; + +PrintTime + pshd ; Save D to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack + ldaa #CR ; Load the character CR into A + jsr putchar ; Write the character to the serial + ldaa #LF ; Load the character LF into A + jsr putchar ; Write the character to the serial + ldx #clock ; Load the address of the clock prompt into X + jsr WriteString ; Write the string to serial + ldd hours ; Load the hours into D + cpd #10 ; Compare D to 10 + bhs goodHours ; If D >= goodHours + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodHours ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd minutes ; Load the minutes into D + cpd #10 ; Compare D to 10 + bhs goodMins ; If D >= goodMins + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodMins ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd seconds ; Load the seconds into D + cpd #10 ; Compare D to 10 + bhs goodSecs ; If D >= goodSecs + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodSecs ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #' ' ; Load ' ' character into A + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + 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 + 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 subroutine +; +; This subroutine will output the time given on on PORTB for two seven segment displays. +; +; Input: Two Digit Decimal number in register D. +; Output: The given two digit decimal number on PORTB for two 7 segment displays. +; Registers in use: D for the input, and for math to split the digits, X for math to split digits. +; Memory locations in use: PORTB memory location. +; +; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal +; numbers (leading zeros will be added). +; + +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 subroutine +; +; This subroutine will parse user input and execute the proper command or error out. +; +; Input: An address of a NULL terminated string in X. +; Output: The output of the proper command or an error message. +; Registers in use: X for the address of the user input, A for individual characters, +; D & Y for numbers read from user input. +; Memory locations in use: Serial console memory locations. +; +; Comments: This subroutine will disable interrupts while setting the time and will +; reenable them after setting the time. +; + +ExecuteCommand + pshd ; Save D to the stack + pshy ; Save Y to the stack + ldaa 1,x+ ; Load the character from X into A + lbeq ecDone ; If A == 0, jump to ecDone + cmpa #'t' ; Compare A to 't' + bne isH ; If A != 't', branch to isH +skipSpaces ldaa 1,+x ; Load the next character into X + cmpa #' ' ; Compare A to ' ' character + beq skipSpaces ; If A == ' ', loop to skipSpaces + sei ; Disable interrupts + ldd hours ; Load hours into D + pshd ; Save hours to the stack + jsr ReadDecimal ; Read Hour number + exg y,d ; Exchange Y and D + cpd #24 ; Compare D to 24 + lbhs badHours ; If D >= 24, badHours + cpd #0 ; Compare D to 0 + lblt badHours ; If D < 0, badHours + std hours ; Save D to hours + ldaa -1,x ; Load the next character into A + cmpa #':' ; Compare A to ':' + lbne badHours ; If A != ':', badHours + ldd minutes ; Load minutes into D + pshd ; Save minutes to the stack + jsr ReadDecimal ; Read minute number + exg y,d ; Exchange Y and D + cpd #60 ; Compare D to 60 + bhs badMinutes ; If D >= 60, badMinutes + cpd #0 ; Compare D to 0 + blt 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 + 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 + cpd #0 ; Compare D to 0 + blt 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 + 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 +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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra 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 + staa outputBuf ; Store A into outputBuf + bra ecDone ; Branch to ecDone +isQ cmpa #'q' ; Compare A to 'q' + bne badCommand ; If A != 'q', branch to badCommand + ldab 1,x+ ; Load next character into B + cmpb #NULL ; Compare B to NULL + bne badCommand ; If B != NULL, branch to ecDone + jmp TypeWrite ; Jump to TypeWrite +badSeconds puld ; Restore Seconds from the stack + std seconds ; Restore seconds before change +badMinutes puld ; Restore minutes from the stack + std minutes ; Restore minutes before change +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 +ecDone puly ; Restore Y from the stack + puld ; Restore D 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 +; its value. +; +; Input: A memory address in register X. +; Output: The value of the number in the Y register, and any errors printed +; to the serial line. Zero bit is set if error occurs. +; Registers in use: X for the address of the contents and for a buffer while printing, +; D for multiplication, B for the character, Y for output value. +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine will return the value in the Y register, and if an error occurs, +; the Zero bit in the CCR will be set. +; + +ReadDecimal + pshd ; Save D to the stack + ldy #0 ; Clear Y register +dHLoop ldab 1,x+ ; Read Next character from X + beq dHDone ; If B == 0, exit loop + cmpb #'+' ; Compare B to '+' + beq dHDone ; If B == '+', end of number + cmpb #'-' ; Compare B to '-' + beq dHDone ; If B == '-', end of number + cmpb #'*' ; Compare B to '*' + beq dHDone ; If B == '+', end of number + cmpb #'/' ; Compare B to '/' + beq dHDone ; If B == '-', end of number + cmpb #':' ; Compare B to ':' + beq dHDone ; If B == '-', end of number + cmpb #' ' ; Compare B to space character + beq dHDone ; If B == ' ', exit loop + cmpb #'0' ; Compare B to '0' character + blt dHError ; If B < '0', bad address, exit loop + cmpb #'9' ; Compare B to '9' character + bhi dHError ; If B > '9', check if 'A'-'F' characters + subb #'0' ; Subtract '0' from B to get true value + pshb ; Save B to the stack + ldd #10 ; load 10 into D + emul ; Multiply Y and D + exg d,y ; Transfer data from D to Y + pulb ; Restore b from the stack + aby ; Add B to Y + bra dHLoop ; Branch always to rHLoop +dHDone clra ; clear A accumulator + tap ; Transfer A into CCR to clear zero bit + puld ; Restore D from the stack + rts ; Return to caller +dHError ldaa #4 ; Load 4 into A to set zero bit in CCR + tap ; Transfer A into CCR to set zero bit and warn error + puld ; Restore D from the stack + rts ; Return to caller + +;************************************************************************* +; strrev subroutine +; +; This subroutine will reverse a string from one buffer into another. +; +; Input: Address of null terminated string in X, address of a large enough +; buffer in Y. +; Output: The string in X reversed in Y. +; Registers in use: X for the address of the string, Y for the address of the buffer, +; A to read characters from the string. +; Memory locations in use: Memory Address for serial line, address of the string & buffer +; +; Comments: This subroutine will not check that the output buffer is large enough, that +; is the job of the caller. +; + +strrev + pshx ; Save X to the stack + pshy ; Save Y to the stack + psha ; Save A to the stack +revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y + beq revDone ; If Character is 0, exit loop + staa 1,x+ ; Save character in address in X, increment X + bra revLoop ; Loop back always + clra ; Set A to Zero +revDone staa 1,x+ ; Copy Null terminator into new string + pula ; Restore A from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller + +;************************************************************************* +; PrintDecimalWord subroutine +; +; This subroutine will print a given word of data to the serial in binary. +; +; Input: 1 word of data in register D, Buffer Address in Y +; Output: Decimal representation of the data on the serial console +; Registers in use: Y for the address of the buffer, X to count the number of bits +; written and for division, D for the input, A for characters. +; Memory locations in use: Memory addresses for serial, and operator to hold sign +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +PrintDecimalWord + pshx ; Save X to the stack + pshy ; Save Y to the stack + pshd ; Save D (A:B) to the stack + cpd #0 ; Compare D to zero + beq dIsZero ; Branch to hIsZero + blt dIsNegative ; If D < 0, Jump to dIsNegative +dAfterNeg psha ; Save A to the stack + pshy ; Save Y to the stack + pshx ; Save x to the stack + ldaa #'0' ; Load the '0' character into A + ldx #buffer2 ; Load the address of buffer2 into X + ldy #5 ; Load 5 into Y + jsr memset ; Write '0' to the first 5 bytes in buffer2 + pulx ; Restore X from the stack + puly ; Restore Y from the stack + clra ; Set A to zero + staa 0,y ; Load Zero into Y for Null Terminator + pula ; Restore A from the stack +dPrintLoop ldx #10 ; Load 10 in X for division + idiv ; Divide D / 10 to get Hex Digit + cpx #0 ; Compare X to 0 + beq dCheck ; If X == 0, branch to check D is zero +dDNotZero addb #'0' ; Add '0' to B to get ASCII Character + stab 1,+y ; Save character from B to Y + exg X,D ; Swap values in X and D + bra dPrintLoop ; Loop to hPrintLoop +dCheck cpd #0 ; Compare D to 0 + bne dDNotZero ; If D != 0, branch back to hDNotZero +dPrintDone ldaa operator ; Load operator into A to see if negative + cmpa #'-' ; Compare A to '-' + bne dNotNeg ; If A != '-', jump to dNotNeg + staa 1,+y ; Save '-' into buffer +dNotNeg ldx #buffer2 ; Load the address of buffer2 in X + jsr strrev ; Reverse string in Y in buffer in X + jsr WriteString ; Jump to write string to write the number + ldy lenBuf2 ; Load the length of buffer2 into Y + ldx #buffer2 ; Load the address of buffer2 into X + jsr Zeros ; Fill buffer2 with zeros + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsZero ldaa #'0' ; Load '0' character into A + jsr putchar ; Print character to the screen + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsNegative psha ; Save A to the stack + ldaa #'-' ; Load '-' into A + staa operator ; Save '-' to operator buffer + pula ; Restore A from the stack + nega ; Two's complement of A + suba #1 ; Subtract 1 from A + negb ; Two'complement of B + subb #1 ; Subtract 1 from B + addd #1 ; Add 1 to D + bra dAfterNeg ; Jump back to dAfterNeg + +;************************************************************************* +; Zeros subroutine +; +; This subroutine will write zeros to every byte in a given array. +; +; Input: Address of an array in X and its length in Y +; Output: Zeros in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for 0 +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +Zeros + psha ; Save A to the Stack + clra ; Clear A +zerosLoop staa 1,x+ ; Load A into byte at X + dbne y,zerosLoop ; Decrement Y and loop if Y != 0 + pula ; Restore A from the stack + rts ; Return to caller + +;************************************************************************* +; memset subroutine +; +; This subroutine will write a given byte to every byte in a given array. +; +; Input: Address of an array in X and its length in Y, the byte in A +; Output: The given byte in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for the given byte +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +memset + staa 1,x+ ; Load A into byte at X + dbne y,memset ; Decrement Y and loop if Y != 0 + rts ; Return to caller + +;************************************************************************* +; WriteString subroutine +; +; This subroutine will write a given null terminated string to the serial. +; +; Input: Address of null terminated string in X +; Output: Null terminated string written to serial +; Registers in use: X for the address of the string and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +WriteString + psha ; Save A to the stack +writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 + beq doneWrite ; if A == 0, branch to doneWrite + jsr putchar ; Jump to putchar to write byte to serial + bra writeLoop ; branch always to writeLoop +doneWrite pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; ReadString subroutine +; +; This subroutine will read a string from the serial line to a given address. +; +; Input: Address of an array in X +; Output: Null terminated string in the given array +; Registers in use: X for the address of the string Y for the length of the string, +; and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and getchar subroutine. +; + +ReadString + psha ; Save accumulator A to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack +readLoop jsr getchar ; Jump to putchar to write byte to serial + beq readLoop ; While A == 0, loop + cmpa #CR ; If A == CR, exit loop + beq doneRead ; Branch to doneRead if A == CR + staa 1,x+ ; Save the byte to the addr in X, then add 1 + jsr putchar ; Write Character back to the terminal + 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 + pulY ; Restore Y from the stack + pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine writes a single byte to a serial line +; +; Input: A single ASCII byte in accumulator A +; Output: Sends one character to SCI port +; Registers in use: Accumulator A with input byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty + staa SCIDRL ; send a character + rts ; Return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine reads one byte from the SCI port +; +; Input: One byte from the SCI port +; Output: One byte in accumulator A +; Registers in use: Accumulator A for output byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 + ldaa SCIDRL ; Read one byte from SCI port into A + rts ; Return to caller +getchar7 clra ; Set A to 0 + rts ; Return to caller + +* +************************************************************************** +* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory +* + +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',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 + +; msg: this is the main option menu string +msg dc.b 'Commands:',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 + dc.b 's: Display the seconds on the 7 segment displays',CR,LF + dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL + + end ; last line of the file diff --git a/exam2prep/Sources/derivative.inc b/exam2prep/Sources/derivative.inc new file mode 100644 index 0000000..988343b --- /dev/null +++ b/exam2prep/Sources/derivative.inc @@ -0,0 +1,10 @@ + + ; Note: This file is recreated by the project wizard whenever the MCU is + ; changed and should not be edited by hand + ; + + ; include derivative specific macros + INCLUDE 'mc9s12c32.inc' + + + diff --git a/exam2prep/Sources/main.asm b/exam2prep/Sources/main.asm new file mode 100644 index 0000000..fb88f69 --- /dev/null +++ b/exam2prep/Sources/main.asm @@ -0,0 +1,640 @@ +************************************************************************** +* Parameter Declearation Section +* +* Export Symbols + xdef pgstart ; export 'pgstart' symbol + absentry pgstart ; for assembly entry point + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H +SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L +SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 +SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 +SCIDRL equ $00CF ; Serial port (SCI) Data Register + +CRGFLG EQU $0037 ; Clock and Reset Generator Flags +CRGINT EQU $0038 ; Clock and Reset Generator Interrupts +RTICTL EQU $003B ; Real Time Interrupt Control + +CR equ $0d ; carriage return, ASCII 'Return' key +LF equ $0a ; line feed, ASCII 'next line' character +NULL equ $00 ; NULL Terminator character + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +buffer ds.b $0010 ; Array of 16 bytes to read a string + dc.b NULL ; NULL terminated +lenBuf dc.w $0010 ; Length of buffer array + +buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal + dc.b NULL ; NULL terminated +lenBuf2 dc.w $0010 ; length of buffer2 + +hours dc.w $0000 ; Buffer to hold the hours of the time + +minutes dc.w $0000 ; Buffer to hold the minutes of the time + +seconds dc.w $0000 ; Buffer to hold the seconds of the time + +counter dc.w $0000 ; Counter for RTI ISR for 1 second + +numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers + +operator dc.b $0000 ; Used by ReadDecimal for reading numbers + +inputBuffer ds.b $0010 ; Input Buffer Length + +lenInput dc.w $0010 ; Length of the Input Buffer + +outputBuf dc.b 'h' ; Used to control what to output on 7 segment display + +n1 dc.b $03 + dc.b $04 + dc.b $05 + +n2 dc.b $06 + dc.b $07 + dc.b $08 + + + +* +************************************************************************** +* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory +* + org $FFF0 ; Memory location for RTI interrupt vector section for simulator + dc.w rtiisr ; Real Time Interrupt vector +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #$0C ; Enable SCI port Tx and Rx units + staa SCICR2 ; disable SCI interrupts + + ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) + std SCIBDH ; SCI port baud rate change + + bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board + ; 4MHz quartz oscillator clock + 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 + + cli + +mainLoop + ldaa #3 + psha + + ldaa #4 + psha + + ldaa #5 + psha + + ldd #0 + jsr SORT + + pula + pula + pula + + jsr add3 + + ldaa #200 + clrb +loopy incb + suba #$01 + ble loopy + + ldaa #$65 + ldab #$43 + ldx #256 + idiv + tba + jsr putchar + xgdx + tba + jsr putchar + + bra mainLoop ; Loop back to mainLoop always + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +SORT + pshb + ldab 3,sp + cmpb 4,sp + bls skip + movb 4,sp,3,sp + stab 4,sp +skip ldab 4,sp + cmpb 5,sp + bls done + movb 5,sp,4,sp + stab 5,sp + ldab 3,sp + cmpb 4,sp + bls done + movb 4,sp,3,sp + stab 4,sp +done pulb + rts + +add3 + pshx + pshy + pshd + ldx #n1 + ldy #n2 + inx + inx + iny + iny + ldab #4 +aloop dbeq b,adone + ldaa 0,x + adca 1,y- + staa 1,x- + bra aloop +adone puld + puly + pulx + rts + +;************************************************************************* +; rtiisr subroutine +; +; This subroutine will increment the counter, seconds, minutes, & hours counters +; to track the time. This subroutine will be called ~400 times a second. +; +; Input: No input other than the timer to call the isr. +; Output: The counter, seconds, minutes, & hours buffers will +; be updated to track the time, the time & prompt will be +; printed every second. +; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. +; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, +; Buffer words for counters, seconds, minutes, & hours buffers. +; +; Comments: The counter buffer should be compared to 400, but for the simulator, +; the counter is compared to 200 to better simulate 1 second on my computer. +; + +rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + ldx counter + inx + stx counter + cpx #100 + bne rtiSkip + ldx #0 + stx counter + ldaa PORTB + eora #%00010000 + staa PORTB +rtiSkip RTI ; Return from RTI ISR + +;************************************************************************* +; PrintTime subroutine +; +; This subroutine will print the time, command prompt, and maybe an error prompt. +; +; Input: No input. +; Output: The time prompt, time, command prompt, the current input, +; and/or an error on the serial console. +; Registers in use: A for the characters to print, X for buffer addresses, +; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB +; Memory locations in use: Memory Address for serial line, Buffer words for counters, +; seconds, minutes, & hours buffers, and buffer to print time, +; outputBuf for tracking what to output on PORTB. +; +; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine +; will print the current user input if its not finished. +; + +PrintTime + pshd ; Save D to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack + ldaa #CR ; Load the character CR into A + jsr putchar ; Write the character to the serial + ldaa #LF ; Load the character LF into A + jsr putchar ; Write the character to the serial + ldx #clock ; Load the address of the clock prompt into X + jsr WriteString ; Write the string to serial + ldd hours ; Load the hours into D + cpd #10 ; Compare D to 10 + bhs goodHours ; If D >= goodHours + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodHours ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd minutes ; Load the minutes into D + cpd #10 ; Compare D to 10 + bhs goodMins ; If D >= goodMins + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodMins ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd seconds ; Load the seconds into D + cpd #10 ; Compare D to 10 + bhs goodSecs ; If D >= goodSecs + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodSecs ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #' ' ; Load ' ' character into A + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + 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 + 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 subroutine +; +; This subroutine will output the time given on on PORTB for two seven segment displays. +; +; Input: Two Digit Decimal number in register D. +; Output: The given two digit decimal number on PORTB for two 7 segment displays. +; Registers in use: D for the input, and for math to split the digits, X for math to split digits. +; Memory locations in use: PORTB memory location. +; +; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal +; numbers (leading zeros will be added). +; + +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 + +;************************************************************************* +; ReadDecimal subroutine +; +; This subroutine will read an ASCII string of a number in decimal and convert it to +; its value. +; +; Input: A memory address in register X. +; Output: The value of the number in the Y register, and any errors printed +; to the serial line. Zero bit is set if error occurs. +; Registers in use: X for the address of the contents and for a buffer while printing, +; D for multiplication, B for the character, Y for output value. +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine will return the value in the Y register, and if an error occurs, +; the Zero bit in the CCR will be set. +; + +ReadDecimal + pshd ; Save D to the stack + ldy #0 ; Clear Y register +dHLoop ldab 1,x+ ; Read Next character from X + beq dHDone ; If B == 0, exit loop + cmpb #'+' ; Compare B to '+' + beq dHDone ; If B == '+', end of number + cmpb #'-' ; Compare B to '-' + beq dHDone ; If B == '-', end of number + cmpb #'*' ; Compare B to '*' + beq dHDone ; If B == '+', end of number + cmpb #'/' ; Compare B to '/' + beq dHDone ; If B == '-', end of number + cmpb #':' ; Compare B to ':' + beq dHDone ; If B == '-', end of number + cmpb #' ' ; Compare B to space character + beq dHDone ; If B == ' ', exit loop + cmpb #'0' ; Compare B to '0' character + blt dHError ; If B < '0', bad address, exit loop + cmpb #'9' ; Compare B to '9' character + bhi dHError ; If B > '9', check if 'A'-'F' characters + subb #'0' ; Subtract '0' from B to get true value + pshb ; Save B to the stack + ldd #10 ; load 10 into D + emul ; Multiply Y and D + exg d,y ; Transfer data from D to Y + pulb ; Restore b from the stack + aby ; Add B to Y + bra dHLoop ; Branch always to rHLoop +dHDone clra ; clear A accumulator + tap ; Transfer A into CCR to clear zero bit + puld ; Restore D from the stack + rts ; Return to caller +dHError ldaa #4 ; Load 4 into A to set zero bit in CCR + tap ; Transfer A into CCR to set zero bit and warn error + puld ; Restore D from the stack + rts ; Return to caller + +;************************************************************************* +; strrev subroutine +; +; This subroutine will reverse a string from one buffer into another. +; +; Input: Address of null terminated string in X, address of a large enough +; buffer in Y. +; Output: The string in X reversed in Y. +; Registers in use: X for the address of the string, Y for the address of the buffer, +; A to read characters from the string. +; Memory locations in use: Memory Address for serial line, address of the string & buffer +; +; Comments: This subroutine will not check that the output buffer is large enough, that +; is the job of the caller. +; + +strrev + pshx ; Save X to the stack + pshy ; Save Y to the stack + psha ; Save A to the stack +revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y + beq revDone ; If Character is 0, exit loop + staa 1,x+ ; Save character in address in X, increment X + bra revLoop ; Loop back always + clra ; Set A to Zero +revDone staa 1,x+ ; Copy Null terminator into new string + pula ; Restore A from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller + +;************************************************************************* +; PrintDecimalWord subroutine +; +; This subroutine will print a given word of data to the serial in binary. +; +; Input: 1 word of data in register D, Buffer Address in Y +; Output: Decimal representation of the data on the serial console +; Registers in use: Y for the address of the buffer, X to count the number of bits +; written and for division, D for the input, A for characters. +; Memory locations in use: Memory addresses for serial, and operator to hold sign +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +PrintDecimalWord + pshx ; Save X to the stack + pshy ; Save Y to the stack + pshd ; Save D (A:B) to the stack + cpd #0 ; Compare D to zero + beq dIsZero ; Branch to hIsZero + blt dIsNegative ; If D < 0, Jump to dIsNegative +dAfterNeg psha ; Save A to the stack + pshy ; Save Y to the stack + pshx ; Save x to the stack + ldaa #'0' ; Load the '0' character into A + ldx #buffer2 ; Load the address of buffer2 into X + ldy #5 ; Load 5 into Y + jsr memset ; Write '0' to the first 5 bytes in buffer2 + pulx ; Restore X from the stack + puly ; Restore Y from the stack + clra ; Set A to zero + staa 0,y ; Load Zero into Y for Null Terminator + pula ; Restore A from the stack +dPrintLoop ldx #10 ; Load 10 in X for division + idiv ; Divide D / 10 to get Hex Digit + cpx #0 ; Compare X to 0 + beq dCheck ; If X == 0, branch to check D is zero +dDNotZero addb #'0' ; Add '0' to B to get ASCII Character + stab 1,+y ; Save character from B to Y + exg X,D ; Swap values in X and D + bra dPrintLoop ; Loop to hPrintLoop +dCheck cpd #0 ; Compare D to 0 + bne dDNotZero ; If D != 0, branch back to hDNotZero +dPrintDone ldaa operator ; Load operator into A to see if negative + cmpa #'-' ; Compare A to '-' + bne dNotNeg ; If A != '-', jump to dNotNeg + staa 1,+y ; Save '-' into buffer +dNotNeg ldx #buffer2 ; Load the address of buffer2 in X + jsr strrev ; Reverse string in Y in buffer in X + jsr WriteString ; Jump to write string to write the number + ldy lenBuf2 ; Load the length of buffer2 into Y + ldx #buffer2 ; Load the address of buffer2 into X + jsr Zeros ; Fill buffer2 with zeros + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsZero ldaa #'0' ; Load '0' character into A + jsr putchar ; Print character to the screen + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsNegative psha ; Save A to the stack + ldaa #'-' ; Load '-' into A + staa operator ; Save '-' to operator buffer + pula ; Restore A from the stack + nega ; Two's complement of A + suba #1 ; Subtract 1 from A + negb ; Two'complement of B + subb #1 ; Subtract 1 from B + addd #1 ; Add 1 to D + bra dAfterNeg ; Jump back to dAfterNeg + +;************************************************************************* +; Zeros subroutine +; +; This subroutine will write zeros to every byte in a given array. +; +; Input: Address of an array in X and its length in Y +; Output: Zeros in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for 0 +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +Zeros + psha ; Save A to the Stack + clra ; Clear A +zerosLoop staa 1,x+ ; Load A into byte at X + dbne y,zerosLoop ; Decrement Y and loop if Y != 0 + pula ; Restore A from the stack + rts ; Return to caller + +;************************************************************************* +; memset subroutine +; +; This subroutine will write a given byte to every byte in a given array. +; +; Input: Address of an array in X and its length in Y, the byte in A +; Output: The given byte in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for the given byte +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +memset + staa 1,x+ ; Load A into byte at X + dbne y,memset ; Decrement Y and loop if Y != 0 + rts ; Return to caller + +;************************************************************************* +; WriteString subroutine +; +; This subroutine will write a given null terminated string to the serial. +; +; Input: Address of null terminated string in X +; Output: Null terminated string written to serial +; Registers in use: X for the address of the string and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +WriteString + psha ; Save A to the stack +writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 + beq doneWrite ; if A == 0, branch to doneWrite + jsr putchar ; Jump to putchar to write byte to serial + bra writeLoop ; branch always to writeLoop +doneWrite pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; ReadString subroutine +; +; This subroutine will read a string from the serial line to a given address. +; +; Input: Address of an array in X +; Output: Null terminated string in the given array +; Registers in use: X for the address of the string Y for the length of the string, +; and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and getchar subroutine. +; + +ReadString + psha ; Save accumulator A to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack +readLoop jsr getchar ; Jump to putchar to write byte to serial + beq readLoop ; While A == 0, loop + cmpa #CR ; If A == CR, exit loop + beq doneRead ; Branch to doneRead if A == CR + staa 1,x+ ; Save the byte to the addr in X, then add 1 + jsr putchar ; Write Character back to the terminal + 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 + pulY ; Restore Y from the stack + pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine writes a single byte to a serial line +; +; Input: A single ASCII byte in accumulator A +; Output: Sends one character to SCI port +; Registers in use: Accumulator A with input byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty + staa SCIDRL ; send a character + rts ; Return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine reads one byte from the SCI port +; +; Input: One byte from the SCI port +; Output: One byte in accumulator A +; Registers in use: Accumulator A for output byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 + ldaa SCIDRL ; Read one byte from SCI port into A + rts ; Return to caller +getchar7 clra ; Set A to 0 + rts ; Return to caller + +* +************************************************************************** +* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory +* + +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',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 + +; msg: this is the main option menu string +msg dc.b 'Commands:',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 + dc.b 's: Display the seconds on the 7 segment displays',CR,LF + dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL + + end ; last line of the file diff --git a/exam2prep/bin/Project.abs b/exam2prep/bin/Project.abs new file mode 100644 index 0000000..bb6ebcd Binary files /dev/null and b/exam2prep/bin/Project.abs differ diff --git a/exam2prep/bin/Project.abs.phy b/exam2prep/bin/Project.abs.phy new file mode 100644 index 0000000..4c72d17 --- /dev/null +++ b/exam2prep/bin/Project.abs.phy @@ -0,0 +1,3 @@ +S04C0000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C6578616D32707265705C62696E5C50726F6A6563742E61627362 +S2060FFFF0319832 +S9030000FC diff --git a/exam2prep/bin/Project.abs.s19 b/exam2prep/bin/Project.abs.s19 new file mode 100644 index 0000000..58ce038 --- /dev/null +++ b/exam2prep/bin/Project.abs.s19 @@ -0,0 +1,36 @@ +S04C0000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C6578616D32707265705C62696E5C50726F6A6563742E61627362 +S123300000000000000000000000000000000000000010000000000000000000000000009C +S123302000000000001000000000000000000000000000000000000000000000000000007C +S10C3040001068030405060708EA +S1233100CF310086F15A03860C5ACBCC00015CC84C3B194C38804C378086FF5A0310EF8621 +S12331200336860436860536CC000016315332323216317A86C8C75280012FFB8665C6430E +S1233140CE01001810180F163358B7C5180F16335820CC37E683E1842306180A84836B8436 +S1233160E684E1852312180A85846B85E683E1842306180A84836B84333D34353BCE3043C7 +S1233180CD304608080202C604040108A600A97F6A3F20F53A31303D4C3780FE302C087EB6 +S12331A0302C8E0064260CCE00007E302C960188105A010B3B3534860D163358860A16339D +S12331C058CE3368163332FC30268C000A240736863016335832CD30001632B4863A1633DB +S12331E058FC30288C000A240736863016335832CD30001632B4863A163358FC302A8C0063 +S12332000A240736863016335832CD30001632B48620163358163358163358163358CE3392 +S123322070163332CE3030163332B6304281682605FC3026200C816D2605FC30282003FCB0 +S1233240302A16324930313A3D3B34CE000A181037B7D4CE000A58585858EAB05B01303ADE +S12332603D3BCD0000E630272EC12B272AC12D2726C12A2722C12F271EC13A271AC1202775 +S123328016C1302D17C1392213C03037CC000A13B7C63319ED20CE87B7023A3D8604B70202 +S12332A03A3D343536A67F27056A3020F8876A303231303D34353B8C0000274C2D53363572 +S12332C0348630CE3013CD000516332C3031876A4032CE000A18108E00002708CB306B6061 +S12332E0B7D420EE8C000026F3B6302F812D26026A60CE30131632A2163332FD3024CE3012 +S1233300131633233A31303D86301633583A31303D36862D7A302F3240800150C001C3009A +S123332001209B36876A300436FB323D6A300436FB3D36A630270516335820F7323D3635FC +S12333403416335F27FB810D270A6A3016335803270220ED3031323D4FCC80FC5ACF3D4F1C +S1233360CC200396CF3D873D436C6F636B3E2000434D443E20004572726F723E2000496E59 +S123338076616C696420496E707574000D0A436C6F636B2073746F7070656420616E642054 +S12333A05479706577726974652070726F6772616D20737461727465642E0D0A596F75206B +S12333C06D617920747970652062656C6F772E0D0A00436F6D6D616E64733A0D0A743A20F1 +S12333E0536574207468652074696D6520696E20666F726D61742048483A4D4D3A53530D5C +S12334000A683A20446973706C61792074686520686F757273206F6E20746865203720730C +S123342065676D656E7420646973706C6179730D0A6D3A20446973706C617920746865204A +S12334406D696E75746573206F6E207468652037207365676D656E7420646973706C617985 +S1233460730D0A733A20446973706C617920746865207365636F6E6473206F6E207468654D +S12334802037207365676D656E7420646973706C6179730D0A713A2053746F70207468654C +S12134A020636C6F636B20616E6420656E74657220747970657772697465720D0A00B7 +S105FFF0319842 +S9030000FC diff --git a/exam2prep/bin/main.dbg b/exam2prep/bin/main.dbg new file mode 100644 index 0000000..fc82e9a --- /dev/null +++ b/exam2prep/bin/main.dbg @@ -0,0 +1,639 @@ +************************************************************************** +* Parameter Declearation Section +* +* Export Symbols + xdef pgstart ; export 'pgstart' symbol + absentry pgstart ; for assembly entry point + +* Symbols and Macros +PORTA equ $0000 ; i/o port A addresses +DDRA equ $0002 ; data direction register for PORTA +PORTB equ $0001 ; i/o port B addresses +DDRB equ $0003 ; data direction register for PORTB + +SCIBDH equ $00C8 ; Serial port (SCI) Baud Register H +SCIBDL equ $00C9 ; Serial port (SCI) Baud Register L +SCICR2 equ $00CB ; Serial port (SCI) Control Register 2 +SCISR1 equ $00CC ; Serial port (SCI) Status Register 1 +SCIDRL equ $00CF ; Serial port (SCI) Data Register + +CRGFLG EQU $0037 ; Clock and Reset Generator Flags +CRGINT EQU $0038 ; Clock and Reset Generator Interrupts +RTICTL EQU $003B ; Real Time Interrupt Control + +CR equ $0d ; carriage return, ASCII 'Return' key +LF equ $0a ; line feed, ASCII 'next line' character +NULL equ $00 ; NULL Terminator character + +************************************************************************** +* Data Section: address used [ $3000 to $30FF ] RAM Memory +* + org $3000 ; Reserved RAM memory starting address + ; for Data for CMPEN 472 class +buffer ds.b $0010 ; Array of 16 bytes to read a string + dc.b NULL ; NULL terminated +lenBuf dc.w $0010 ; Length of buffer array + +buffer2 ds.b $0010 ; Array of 16 bytes for reading and reversal + dc.b NULL ; NULL terminated +lenBuf2 dc.w $0010 ; length of buffer2 + +hours dc.w $0000 ; Buffer to hold the hours of the time + +minutes dc.w $0000 ; Buffer to hold the minutes of the time + +seconds dc.w $0000 ; Buffer to hold the seconds of the time + +counter dc.w $0000 ; Counter for RTI ISR for 1 second + +numBuf dc.b $0000 ; Used by ReadDecimal for reading numbers + +operator dc.b $0000 ; Used by ReadDecimal for reading numbers + +inputBuffer ds.b $0010 ; Input Buffer Length + +lenInput dc.w $0010 ; Length of the Input Buffer + +outputBuf dc.b 'h' ; Used to control what to output on 7 segment display + +n1 dc.b $03 + dc.b $04 + dc.b $05 + +n2 dc.b $06 + dc.b $07 + dc.b $08 + + + +* +************************************************************************** +* RTI Vector Section: address used [ $FFF0 to $FFF1 ] RAM Memory +* + org $FFF0 ; Memory location for RTI interrupt vector section for simulator + dc.w rtiisr ; Real Time Interrupt vector +* +************************************************************************** +* Program Section: address used [ $3100 to $3FFF ] RAM Memory +* + org $3100 ; Program start address, in RAM +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 #$0C ; Enable SCI port Tx and Rx units + staa SCICR2 ; disable SCI interrupts + + ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) + std SCIBDH ; SCI port baud rate change + + bset RTICTL,%00011001; set RTI: dev=10*(2**10)=2.555msec for C128 board + ; 4MHz quartz oscillator clock + 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 + + cli + +mainLoop + ldaa #3 + psha + + ldaa #4 + psha + + ldaa #5 + psha + + ldd #0 + jsr SORT + + pula + pula + pula + + jsr add3 + + ldaa #200 + clrb +loopy incb + suba #$01 + ble loopy + + ldaa #$65 + ldab #$43 + ldx #256 + idiv + tba + jsr putchar + xgdx + tba + jsr putchar + + bra mainLoop ; Loop back to mainLoop always + +************************************************************************** +* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory +* + +SORT + pshb + ldab 3,sp + cmpb 4,sp + bls skip + movb 4,sp,3,sp + stab 4,sp +skip ldab 4,sp + cmpb 5,sp + bls done + movb 5,sp,4,sp + stab 5,sp + ldab 3,sp + cmpb 4,sp + bls done + movb 4,sp,3,sp + stab 4,sp +done pulb + rts + +add3 + pshx + pshy + pshd + ldx #n1 + ldy #n2 + inx + inx + iny + iny + ldab #4 +aloop dbeq b,adone + ldaa 0,x + adca 1,y- + staa 1,x- + bra aloop +adone puld + puly + pulx + rts + +;************************************************************************* +; rtiisr subroutine +; +; This subroutine will increment the counter, seconds, minutes, & hours counters +; to track the time. This subroutine will be called ~400 times a second. +; +; Input: No input other than the timer to call the isr. +; Output: The counter, seconds, minutes, & hours buffers will +; be updated to track the time, the time & prompt will be +; printed every second. +; Registers in use: X for adding to the counter, seconds, minutes, & hours buffers. +; Memory locations in use: Memory Address for serial line, Memory addresses for RTIISR control, +; Buffer words for counters, seconds, minutes, & hours buffers. +; +; Comments: The counter buffer should be compared to 400, but for the simulator, +; the counter is compared to 200 to better simulate 1 second on my computer. +; + +rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + ldx counter + inx + stx counter + cpx #100 + bne rtiSkip + ldx #0 + stx counter + ldaa PORTB + eora #%00010000 + staa PORTB +rtiSkip RTI ; Return from RTI ISR + +;************************************************************************* +; PrintTime subroutine +; +; This subroutine will print the time, command prompt, and maybe an error prompt. +; +; Input: No input. +; Output: The time prompt, time, command prompt, the current input, +; and/or an error on the serial console. +; Registers in use: A for the characters to print, X for buffer addresses, +; Y for buffer lengths, D for the seconds/minutes/hours for calling TimeOnPortB +; Memory locations in use: Memory Address for serial line, Buffer words for counters, +; seconds, minutes, & hours buffers, and buffer to print time, +; outputBuf for tracking what to output on PORTB. +; +; Comments: This subroutine requires TimeOnPortB subroutine and to be setup. The subroutine +; will print the current user input if its not finished. +; + +PrintTime + pshd ; Save D to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack + ldaa #CR ; Load the character CR into A + jsr putchar ; Write the character to the serial + ldaa #LF ; Load the character LF into A + jsr putchar ; Write the character to the serial + ldx #clock ; Load the address of the clock prompt into X + jsr WriteString ; Write the string to serial + ldd hours ; Load the hours into D + cpd #10 ; Compare D to 10 + bhs goodHours ; If D >= goodHours + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodHours ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd minutes ; Load the minutes into D + cpd #10 ; Compare D to 10 + bhs goodMins ; If D >= goodMins + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodMins ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #':' ; Load the character ':' into A + jsr putchar ; Write the character to the serial + ldd seconds ; Load the seconds into D + cpd #10 ; Compare D to 10 + bhs goodSecs ; If D >= goodSecs + psha ; Save A to the stack + ldaa #'0' ; Load '0' character into A + jsr putchar ; Print '0' to the serial + pula ; Restore A from the stack +goodSecs ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the number to the serial + ldaa #' ' ; Load ' ' character into A + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + jsr putchar ; Write the character to the serial console + 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 + 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 subroutine +; +; This subroutine will output the time given on on PORTB for two seven segment displays. +; +; Input: Two Digit Decimal number in register D. +; Output: The given two digit decimal number on PORTB for two 7 segment displays. +; Registers in use: D for the input, and for math to split the digits, X for math to split digits. +; Memory locations in use: PORTB memory location. +; +; Comments: This subroutine will only work with two digit decimal numbers, and one digit decimal +; numbers (leading zeros will be added). +; + +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 + +;************************************************************************* +; ReadDecimal subroutine +; +; This subroutine will read an ASCII string of a number in decimal and convert it to +; its value. +; +; Input: A memory address in register X. +; Output: The value of the number in the Y register, and any errors printed +; to the serial line. Zero bit is set if error occurs. +; Registers in use: X for the address of the contents and for a buffer while printing, +; D for multiplication, B for the character, Y for output value. +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine will return the value in the Y register, and if an error occurs, +; the Zero bit in the CCR will be set. +; + +ReadDecimal + pshd ; Save D to the stack + ldy #0 ; Clear Y register +dHLoop ldab 1,x+ ; Read Next character from X + beq dHDone ; If B == 0, exit loop + cmpb #'+' ; Compare B to '+' + beq dHDone ; If B == '+', end of number + cmpb #'-' ; Compare B to '-' + beq dHDone ; If B == '-', end of number + cmpb #'*' ; Compare B to '*' + beq dHDone ; If B == '+', end of number + cmpb #'/' ; Compare B to '/' + beq dHDone ; If B == '-', end of number + cmpb #':' ; Compare B to ':' + beq dHDone ; If B == '-', end of number + cmpb #' ' ; Compare B to space character + beq dHDone ; If B == ' ', exit loop + cmpb #'0' ; Compare B to '0' character + blt dHError ; If B < '0', bad address, exit loop + cmpb #'9' ; Compare B to '9' character + bhi dHError ; If B > '9', check if 'A'-'F' characters + subb #'0' ; Subtract '0' from B to get true value + pshb ; Save B to the stack + ldd #10 ; load 10 into D + emul ; Multiply Y and D + exg d,y ; Transfer data from D to Y + pulb ; Restore b from the stack + aby ; Add B to Y + bra dHLoop ; Branch always to rHLoop +dHDone clra ; clear A accumulator + tap ; Transfer A into CCR to clear zero bit + puld ; Restore D from the stack + rts ; Return to caller +dHError ldaa #4 ; Load 4 into A to set zero bit in CCR + tap ; Transfer A into CCR to set zero bit and warn error + puld ; Restore D from the stack + rts ; Return to caller + +;************************************************************************* +; strrev subroutine +; +; This subroutine will reverse a string from one buffer into another. +; +; Input: Address of null terminated string in X, address of a large enough +; buffer in Y. +; Output: The string in X reversed in Y. +; Registers in use: X for the address of the string, Y for the address of the buffer, +; A to read characters from the string. +; Memory locations in use: Memory Address for serial line, address of the string & buffer +; +; Comments: This subroutine will not check that the output buffer is large enough, that +; is the job of the caller. +; + +strrev + pshx ; Save X to the stack + pshy ; Save Y to the stack + psha ; Save A to the stack +revLoop ldaa 1,y- ; Load Character from Y into A, decrement Y + beq revDone ; If Character is 0, exit loop + staa 1,x+ ; Save character in address in X, increment X + bra revLoop ; Loop back always + clra ; Set A to Zero +revDone staa 1,x+ ; Copy Null terminator into new string + pula ; Restore A from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller + +;************************************************************************* +; PrintDecimalWord subroutine +; +; This subroutine will print a given word of data to the serial in binary. +; +; Input: 1 word of data in register D, Buffer Address in Y +; Output: Decimal representation of the data on the serial console +; Registers in use: Y for the address of the buffer, X to count the number of bits +; written and for division, D for the input, A for characters. +; Memory locations in use: Memory addresses for serial, and operator to hold sign +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +PrintDecimalWord + pshx ; Save X to the stack + pshy ; Save Y to the stack + pshd ; Save D (A:B) to the stack + cpd #0 ; Compare D to zero + beq dIsZero ; Branch to hIsZero + blt dIsNegative ; If D < 0, Jump to dIsNegative +dAfterNeg psha ; Save A to the stack + pshy ; Save Y to the stack + pshx ; Save x to the stack + ldaa #'0' ; Load the '0' character into A + ldx #buffer2 ; Load the address of buffer2 into X + ldy #5 ; Load 5 into Y + jsr memset ; Write '0' to the first 5 bytes in buffer2 + pulx ; Restore X from the stack + puly ; Restore Y from the stack + clra ; Set A to zero + staa 0,y ; Load Zero into Y for Null Terminator + pula ; Restore A from the stack +dPrintLoop ldx #10 ; Load 10 in X for division + idiv ; Divide D / 10 to get Hex Digit + cpx #0 ; Compare X to 0 + beq dCheck ; If X == 0, branch to check D is zero +dDNotZero addb #'0' ; Add '0' to B to get ASCII Character + stab 1,+y ; Save character from B to Y + exg X,D ; Swap values in X and D + bra dPrintLoop ; Loop to hPrintLoop +dCheck cpd #0 ; Compare D to 0 + bne dDNotZero ; If D != 0, branch back to hDNotZero +dPrintDone ldaa operator ; Load operator into A to see if negative + cmpa #'-' ; Compare A to '-' + bne dNotNeg ; If A != '-', jump to dNotNeg + staa 1,+y ; Save '-' into buffer +dNotNeg ldx #buffer2 ; Load the address of buffer2 in X + jsr strrev ; Reverse string in Y in buffer in X + jsr WriteString ; Jump to write string to write the number + ldy lenBuf2 ; Load the length of buffer2 into Y + ldx #buffer2 ; Load the address of buffer2 into X + jsr Zeros ; Fill buffer2 with zeros + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsZero ldaa #'0' ; Load '0' character into A + jsr putchar ; Print character to the screen + puld ; Restore D (A:B) from the stack + puly ; Restore Y from the stack + pulx ; Restore X from the stack + rts ; Return to caller +dIsNegative psha ; Save A to the stack + ldaa #'-' ; Load '-' into A + staa operator ; Save '-' to operator buffer + pula ; Restore A from the stack + nega ; Two's complement of A + suba #1 ; Subtract 1 from A + negb ; Two'complement of B + subb #1 ; Subtract 1 from B + addd #1 ; Add 1 to D + bra dAfterNeg ; Jump back to dAfterNeg + +;************************************************************************* +; Zeros subroutine +; +; This subroutine will write zeros to every byte in a given array. +; +; Input: Address of an array in X and its length in Y +; Output: Zeros in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for 0 +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +Zeros + psha ; Save A to the Stack + clra ; Clear A +zerosLoop staa 1,x+ ; Load A into byte at X + dbne y,zerosLoop ; Decrement Y and loop if Y != 0 + pula ; Restore A from the stack + rts ; Return to caller + +;************************************************************************* +; memset subroutine +; +; This subroutine will write a given byte to every byte in a given array. +; +; Input: Address of an array in X and its length in Y, the byte in A +; Output: The given byte in every byte of an array. +; Registers in use: X for the address of the array, Y for the length, and A for the given byte +; Memory locations in use: Memory Address of the array +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +memset + staa 1,x+ ; Load A into byte at X + dbne y,memset ; Decrement Y and loop if Y != 0 + rts ; Return to caller + +;************************************************************************* +; WriteString subroutine +; +; This subroutine will write a given null terminated string to the serial. +; +; Input: Address of null terminated string in X +; Output: Null terminated string written to serial +; Registers in use: X for the address of the string and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and putchar subroutine. +; + +WriteString + psha ; Save A to the stack +writeLoop ldaa 1,x+ ; Load the byte at addr in X, then add 1 + beq doneWrite ; if A == 0, branch to doneWrite + jsr putchar ; Jump to putchar to write byte to serial + bra writeLoop ; branch always to writeLoop +doneWrite pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; ReadString subroutine +; +; This subroutine will read a string from the serial line to a given address. +; +; Input: Address of an array in X +; Output: Null terminated string in the given array +; Registers in use: X for the address of the string Y for the length of the string, +; and A for the current byte +; Memory locations in use: Memory Address for serial line, address of the string +; +; Comments: This subroutine requires serial to be setup and getchar subroutine. +; + +ReadString + psha ; Save accumulator A to the stack + pshy ; Save Y to the stack + pshx ; Save X to the stack +readLoop jsr getchar ; Jump to putchar to write byte to serial + beq readLoop ; While A == 0, loop + cmpa #CR ; If A == CR, exit loop + beq doneRead ; Branch to doneRead if A == CR + staa 1,x+ ; Save the byte to the addr in X, then add 1 + jsr putchar ; Write Character back to the terminal + 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 + pulY ; Restore Y from the stack + pula ; restore A from the stack + rts ; return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine writes a single byte to a serial line +; +; Input: A single ASCII byte in accumulator A +; Output: Sends one character to SCI port +; Registers in use: Accumulator A with input byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty + staa SCIDRL ; send a character + rts ; Return to caller + +;************************************************************************* +; putchar subroutine +; +; This subroutine reads one byte from the SCI port +; +; Input: One byte from the SCI port +; Output: One byte in accumulator A +; Registers in use: Accumulator A for output byte +; Memory locations in use: SCISR1 and SCIDRL status and data registers +; + +getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, return 0 + ldaa SCIDRL ; Read one byte from SCI port into A + rts ; Return to caller +getchar7 clra ; Set A to 0 + rts ; Return to caller + +* +************************************************************************** +* Data Section 2: address used [ $3100 to $3FFF ] RAM Memory +* + +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',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 + +; msg: this is the main option menu string +msg dc.b 'Commands:',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 + dc.b 's: Display the seconds on the 7 segment displays',CR,LF + dc.b 'q: Stop the clock and enter typewriter',CR,LF,NULL + diff --git a/exam2prep/cmd/Full_Chip_Simulation_Postload.cmd b/exam2prep/cmd/Full_Chip_Simulation_Postload.cmd new file mode 100644 index 0000000..ac4d359 --- /dev/null +++ b/exam2prep/cmd/Full_Chip_Simulation_Postload.cmd @@ -0,0 +1 @@ +// After load the commands written below will be executed diff --git a/exam2prep/cmd/Full_Chip_Simulation_Preload.cmd b/exam2prep/cmd/Full_Chip_Simulation_Preload.cmd new file mode 100644 index 0000000..0bed464 --- /dev/null +++ b/exam2prep/cmd/Full_Chip_Simulation_Preload.cmd @@ -0,0 +1 @@ +// Before load the commands written below will be executed diff --git a/exam2prep/cmd/Full_Chip_Simulation_Reset.cmd b/exam2prep/cmd/Full_Chip_Simulation_Reset.cmd new file mode 100644 index 0000000..bf55944 --- /dev/null +++ b/exam2prep/cmd/Full_Chip_Simulation_Reset.cmd @@ -0,0 +1 @@ +// After reset the commands written below will be executed diff --git a/exam2prep/cmd/Full_Chip_Simulation_SetCPU.cmd b/exam2prep/cmd/Full_Chip_Simulation_SetCPU.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/exam2prep/cmd/Full_Chip_Simulation_SetCPU.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/exam2prep/cmd/Full_Chip_Simulation_Startup.cmd b/exam2prep/cmd/Full_Chip_Simulation_Startup.cmd new file mode 100644 index 0000000..6a1549a --- /dev/null +++ b/exam2prep/cmd/Full_Chip_Simulation_Startup.cmd @@ -0,0 +1 @@ +// At startup the commands written below will be executed diff --git a/exam2prep/cmpen472_hw8McDonnell.mcp b/exam2prep/cmpen472_hw8McDonnell.mcp new file mode 100644 index 0000000..9377caf Binary files /dev/null and b/exam2prep/cmpen472_hw8McDonnell.mcp differ diff --git a/exam2prep/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg b/exam2prep/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg new file mode 100644 index 0000000..d39991e Binary files /dev/null and b/exam2prep/cmpen472_hw8McDonnell_Data/CWSettingsWindows.stg differ diff --git a/exam2prep/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o b/exam2prep/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o new file mode 100644 index 0000000..bb6ebcd Binary files /dev/null and b/exam2prep/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.o differ diff --git a/exam2prep/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx b/exam2prep/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx new file mode 100644 index 0000000..e65b901 --- /dev/null +++ b/exam2prep/cmpen472_hw8McDonnell_Data/Standard/ObjectCode/main.asm.sx @@ -0,0 +1,36 @@ +S0780000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C6578616D32707265705C636D70656E3437325F6877384D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726DE3 +S123300000000000000000000000000000000000000010000000000000000000000000009C +S123302000000000001000000000000000000000000000000000000000000000000000007C +S10C3040001068030405060708EA +S105FFF0319842 +S1233100CF310086F15A03860C5ACBCC00015CC84C3B194C38804C378086FF5A0310EF8621 +S12331200336860436860536CC000016315332323216317A86C8C75280012FFB8665C6430E +S1233140CE01001810180F163358B7C5180F16335820CC37E683E1842306180A84836B8436 +S1233160E684E1852312180A85846B85E683E1842306180A84836B84333D34353BCE3043C7 +S1233180CD304608080202C604040108A600A97F6A3F20F53A31303D4C3780FE302C087EB6 +S12331A0302C8E0064260CCE00007E302C960188105A010B3B3534860D163358860A16339D +S12331C058CE3368163332FC30268C000A240736863016335832CD30001632B4863A1633DB +S12331E058FC30288C000A240736863016335832CD30001632B4863A163358FC302A8C0063 +S12332000A240736863016335832CD30001632B48620163358163358163358163358CE3392 +S123322070163332CE3030163332B6304281682605FC3026200C816D2605FC30282003FCB0 +S1233240302A16324930313A3D3B34CE000A181037B7D4CE000A58585858EAB05B01303ADE +S12332603D3BCD0000E630272EC12B272AC12D2726C12A2722C12F271EC13A271AC1202775 +S123328016C1302D17C1392213C03037CC000A13B7C63319ED20CE87B7023A3D8604B70202 +S12332A03A3D343536A67F27056A3020F8876A303231303D34353B8C0000274C2D53363572 +S12332C0348630CE3013CD000516332C3031876A4032CE000A18108E00002708CB306B6061 +S12332E0B7D420EE8C000026F3B6302F812D26026A60CE30131632A2163332FD3024CE3012 +S1233300131633233A31303D86301633583A31303D36862D7A302F3240800150C001C3009A +S123332001209B36876A300436FB323D6A300436FB3D36A630270516335820F7323D3635FC +S12333403416335F27FB810D270A6A3016335803270220ED3031323D4FCC80FC5ACF3D4F1C +S1233360CC200396CF3D873D436C6F636B3E2000434D443E20004572726F723E2000496E59 +S123338076616C696420496E707574000D0A436C6F636B2073746F7070656420616E642054 +S12333A05479706577726974652070726F6772616D20737461727465642E0D0A596F75206B +S12333C06D617920747970652062656C6F772E0D0A00436F6D6D616E64733A0D0A743A20F1 +S12333E0536574207468652074696D6520696E20666F726D61742048483A4D4D3A53530D5C +S12334000A683A20446973706C61792074686520686F757273206F6E20746865203720730C +S123342065676D656E7420646973706C6179730D0A6D3A20446973706C617920746865204A +S12334406D696E75746573206F6E207468652037207365676D656E7420646973706C617985 +S1233460730D0A733A20446973706C617920746865207365636F6E6473206F6E207468654D +S12334802037207365676D656E7420646973706C6179730D0A713A2053746F70207468654C +S12134A020636C6F636B20616E6420656E74657220747970657772697465720D0A00B7 +S9033100CB diff --git a/exam2prep/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt b/exam2prep/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt new file mode 100644 index 0000000..4201423 Binary files /dev/null and b/exam2prep/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt differ diff --git a/exam2prep/prm/burner.bbl b/exam2prep/prm/burner.bbl new file mode 100644 index 0000000..0c57619 --- /dev/null +++ b/exam2prep/prm/burner.bbl @@ -0,0 +1,157 @@ +/* logical s-record file */ +OPENFILE "%ABS_FILE%.s19" +format=motorola +busWidth=1 +origin=0 +len=0x1000000 +destination=0 +SRECORD=Sx +SENDBYTE 1 "%ABS_FILE%" +CLOSE + + +/* physical s-record file */ +OPENFILE "%ABS_FILE%.phy" +format = motorola +busWidth = 1 +len = 0x4000 + +/* logical non banked flash at $4000 and $C000 to physical */ +origin = 0x004000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" + +origin = 0x00C000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +/* physical FTS512K flash window to physical +origin = 0x008000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS256K parts flash window to physical +origin = 0x008000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS128K parts flash window to physical +origin = 0x008000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS64K parts flash window to physical +origin = 0x008000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* physical FTS32K parts flash window to physical +origin = 0x008000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +*/ + +/* logical 512 kB banked flash to physical */ +origin = 0x208000 +destination = 0x080000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x218000 +destination = 0x084000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x228000 +destination = 0x088000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x238000 +destination = 0x08C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x248000 +destination = 0x090000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x258000 +destination = 0x094000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x268000 +destination = 0x098000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x278000 +destination = 0x09C000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x288000 +destination = 0x0A0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x298000 +destination = 0x0A4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2A8000 +destination = 0x0A8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2B8000 +destination = 0x0AC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2C8000 +destination = 0x0B0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2D8000 +destination = 0x0B4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2E8000 +destination = 0x0B8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x2F8000 +destination = 0x0BC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x308000 +destination = 0x0C0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x318000 +destination = 0x0C4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x328000 +destination = 0x0C8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x338000 +destination = 0x0CC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x348000 +destination = 0x0D0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x358000 +destination = 0x0D4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x368000 +destination = 0x0D8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x378000 +destination = 0x0DC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x388000 +destination = 0x0E0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x398000 +destination = 0x0E4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3A8000 +destination = 0x0E8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3B8000 +destination = 0x0EC000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3C8000 +destination = 0x0F0000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3D8000 +destination = 0x0F4000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3E8000 +destination = 0x0F8000 +SENDBYTE 1 "%ABS_FILE%" +origin = 0x3F8000 +destination = 0x0FC000 +SENDBYTE 1 "%ABS_FILE%" + +CLOSE + -- cgit v1.2.3