summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2025-02-19 11:44:00 -0500
committerJacob McDonnell <jacob@jacobmcdonnell.com>2025-02-19 11:44:00 -0500
commit2ed987d75b46bac8457b2836b3bd64dcc77ea90c (patch)
tree74e72f6729e934f089cdab198c6a35f49b8d5b69
parent9503fe39e53e9c7a2147be9bdb22479035130966 (diff)
HW 5 Final???
-rw-r--r--cmpen472hw5_McDonnell/ASM_layout.hwl12
-rw-r--r--cmpen472hw5_McDonnell/Full_Chip_Simulation.ini5
-rw-r--r--cmpen472hw5_McDonnell/Sources/example.asm211
-rw-r--r--cmpen472hw5_McDonnell/Sources/main.asm284
-rw-r--r--cmpen472hw5_McDonnell/bin/Project.absbin4062 -> 7222 bytes
-rw-r--r--cmpen472hw5_McDonnell/bin/Project.abs.s1936
-rw-r--r--cmpen472hw5_McDonnell/bin/main.dbg365
-rw-r--r--cmpen472hw5_McDonnell/cmpen472hw5_McDonnell.mcpbin57065 -> 57065 bytes
-rw-r--r--cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/CWSettingsWindows.stgbin2088 -> 4263 bytes
-rw-r--r--cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.obin4062 -> 7222 bytes
-rw-r--r--cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.sx36
-rw-r--r--cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/TargetDataWindows.tdtbin62658 -> 64875 bytes
12 files changed, 866 insertions, 83 deletions
diff --git a/cmpen472hw5_McDonnell/ASM_layout.hwl b/cmpen472hw5_McDonnell/ASM_layout.hwl
index e6b105c..5ba4378 100644
--- a/cmpen472hw5_McDonnell/ASM_layout.hwl
+++ b/cmpen472hw5_McDonnell/ASM_layout.hwl
@@ -1,7 +1,7 @@
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 0x3125
+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
@@ -12,12 +12,16 @@ 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 66 17 16 45
+OPEN Visualizationtool 79 26 11 31
VisualizationTool< Attributes [stEditM="0",swRefresh="3",refCycles="1"]
VisualizationTool< LoadInstrument DILSwitch[BoundX="24",BoundY="108",Port="0x1"]
-VisualizationTool< LoadInstrument LED[BoundX="28",BoundY="44",Port="0x1",swBIT="7"]
+VisualizationTool< LoadInstrument Seg7[BoundX="21",BoundY="16",Port="0x1",swDM="2"]
+VisualizationTool< LoadInstrument Seg7[BoundX="60",BoundY="17",Port="0x1",swDM="1"]
VisualizationTool< ResetVT Undo
+OPEN Terminal 58 53 37 47
+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 ""
bckcolor 50331647
font 'Courier New' 9 BLACK
AUTOSIZE on
-ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Procedure" "Source" "VisualizationTool"
+ACTIVATE "Assembly" "Memory" "Register" "Command" "Data" "Procedure" "Source" "VisualizationTool" "Terminal"
diff --git a/cmpen472hw5_McDonnell/Full_Chip_Simulation.ini b/cmpen472hw5_McDonnell/Full_Chip_Simulation.ini
index dd82fbd..508e9c0 100644
--- a/cmpen472hw5_McDonnell/Full_Chip_Simulation.ini
+++ b/cmpen472hw5_McDonnell/Full_Chip_Simulation.ini
@@ -10,7 +10,7 @@ Target=sim
Layout=ASM_layout.hwl
LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD
CPU=HC12
-MainFrame=0,1,-1,-1,-1,-1,260,260,2180,1283
+MainFrame=0,1,-1,-1,-1,-1,454,107,2374,1130
Configuration=Full_Chip_Simulation.hwc
Statusbar=1
ShowToolbar=1
@@ -37,3 +37,6 @@ 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/cmpen472hw5_McDonnell/Sources/example.asm b/cmpen472hw5_McDonnell/Sources/example.asm
new file mode 100644
index 0000000..323f7ce
--- /dev/null
+++ b/cmpen472hw5_McDonnell/Sources/example.asm
@@ -0,0 +1,211 @@
+***********************************************************************
+*
+* Title: SCI Serial Port and 7-segment Display at PORTB
+*
+* Objective: CMPEN 472 Homework 5, in-class-room demonstration
+* program
+*
+* Revision: V3.2 for CodeWarrior 5.2 Debugger Simulation
+*
+* Date: Sep. 16, 2020
+*
+* Programmer: Kyusun Choi
+*
+* Company: The Pennsylvania State University
+* Department of Computer Science and Engineering
+*
+* Program: Simple SCI Serial Port I/O and Demonstration
+* Typewriter program and 7-Segment display, at PORTB
+*
+*
+* Algorithm: Simple Serial I/O use, typewriter
+*
+* Register use: A: Serial port data
+* X,Y: Delay loop counters
+*
+* Memory use: RAM Locations from $3000 for data,
+* RAM Locations from $3100 for program
+*
+* Output:
+* PORTB bit 7 to bit 4, 7-segment MSB
+* PORTB bit 3 to bit 0, 7-segment LSB
+*
+* Observation: This is a typewriter program that displays ASCII
+* data on PORTB - 7-segment displays.
+*
+***********************************************************************
+* Parameter Declearation Section
+*
+* Export Symbols
+ XDEF pstart ; export 'pstart' symbol
+ ABSENTRY pstart ; for assembly entry point
+
+* Symbols and Macros
+PORTB EQU $0001 ; i/o port B addresses
+DDRB EQU $0003
+
+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
+
+CR equ $0d ; carriage return, ASCII 'Return' key
+LF equ $0a ; line feed, ASCII 'next line' character
+
+***********************************************************************
+* 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 $008F ; X register count number for time delay
+ ; inner loop for msec
+Counter2 DC.W $000C ; Y register count number for time delay
+ ; outer loop for sec
+msg1 DC.B 'Hello', $00
+msg2 DC.B 'You may type below', $00
+; Each message ends with $00 (NULL ASCII character) for your program.
+;
+; There are 256 bytes from $3000 to $3100. If you need more bytes for
+; your messages, you can put more messages 'msg3' and 'msg4' at the end of
+; the program - before the last "END" line.
+ ; Remaining data memory space for stack,
+ ; up to program memory start
+
+*
+***********************************************************************
+* Program Section: address used [ $3100 to $3FFF ] RAM memory
+*
+ ORG $3100 ; Program start address, in RAM
+pstart LDS #$3100 ; initialize the stack pointer
+
+ LDAA #%11111111 ; Set PORTB bit 0,1,2,3,4,5,6,7
+ STAA DDRB ; as output
+
+ LDAA #%00000000
+ STAA PORTB ; clear all bits of PORTB
+
+ 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)
+; ldd #$0002 ; Set SCI Baud Register = $0002 => 750K baud at 24MHz
+; ldd #$000D ; Set SCI Baud Register = $000D => 115200 baud at 24MHz
+; ldd #$009C ; Set SCI Baud Register = $009C => 9600 baud at 24MHz
+ std SCIBDH ; SCI port baud rate change
+
+ ldx #msg1 ; print the first message, 'Hello'
+ jsr printmsg
+
+ ldaa #CR ; move the cursor to beginning of the line
+ jsr putchar ; Cariage Return/Enter key
+ ldaa #LF ; move the cursor to next line, Line Feed
+ jsr putchar
+
+ ldx #msg2 ; print the second message
+ jsr printmsg
+
+ ldaa #CR ; move the cursor to beginning of the line
+ jsr putchar ; Cariage Return/Enter key
+ ldaa #LF ; move the cursor to next line, Line Feed
+ jsr putchar
+
+looop jsr getchar ; type writer - check the key board
+ cmpa #$00 ; if nothing typed, keep checking
+ beq looop
+ ; otherwise - what is typed on key board
+ jsr putchar ; is displayed on the terminal window - echo print
+
+ staa PORTB ; show the character on PORTB
+
+ cmpa #CR
+ bne looop ; if Enter/Return key is pressed, move the
+ ldaa #LF ; cursor to next line
+ jsr putchar
+ bra looop
+
+
+;subroutine section below
+
+;***********printmsg***************************
+;* Program: Output character string to SCI port, print message
+;* Input: Register X points to ASCII characters in memory
+;* Output: message printed on the terminal connected to SCI port
+;*
+;* Registers modified: CCR
+;* Algorithm:
+; Pick up 1 byte from memory where X register is pointing
+; Send it out to SCI port
+; Update X register to point to the next byte
+; Repeat until the byte data $00 is encountered
+; (String is terminated with NULL=$00)
+;**********************************************
+NULL equ $00
+printmsg psha ;Save registers
+ pshx
+printmsgloop ldaa 1,X+ ;pick up an ASCII character from string
+ ; pointed by X register
+ ;then update the X register to point to
+ ; the next byte
+ cmpa #NULL
+ beq printmsgdone ;end of strint yet?
+ jsr putchar ;if not, print character and do next
+ bra printmsgloop
+
+printmsgdone pulx
+ pula
+ rts
+;***********end of printmsg********************
+
+
+;***************putchar************************
+;* Program: Send one character to SCI port, terminal
+;* Input: Accumulator A contains an ASCII character, 8bit
+;* Output: Send one character to SCI port, terminal
+;* Registers modified: CCR
+;* Algorithm:
+; Wait for transmit buffer become empty
+; Transmit buffer empty is indicated by TDRE bit
+; TDRE = 1 : empty - Transmit Data Register Empty, ready to transmit
+; TDRE = 0 : not empty, transmission in progress
+;**********************************************
+putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty
+ staa SCIDRL ; send a character
+ rts
+;***************end of putchar*****************
+
+
+;****************getchar***********************
+;* Program: Input one character from SCI port (terminal/keyboard)
+;* if a character is received, other wise return NULL
+;* Input: none
+;* Output: Accumulator A containing the received ASCII character
+;* if a character is received.
+;* Otherwise Accumulator A will contain a NULL character, $00.
+;* Registers modified: CCR
+;* Algorithm:
+; Check for receive buffer become full
+; Receive buffer full is indicated by RDRF bit
+; RDRF = 1 : full - Receive Data Register Full, 1 byte received
+; RDRF = 0 : not full, 0 byte received
+;**********************************************
+getchar brclr SCISR1,#%00100000,getchar7
+ ldaa SCIDRL
+ rts
+getchar7 clra
+ rts
+;****************end of getchar****************
+
+
+;OPTIONAL
+;more variable/data section below
+; this is after the program code section
+; of the RAM. RAM ends at $3FFF
+; in MC9S12C128 chip
+
+msg3 DC.B 'Enter your command below:', $00
+msg4 DC.B 'Error: Invalid command', $00
+
+
+ END ; this is end of assembly source file
+ ; lines below are ignored - not assembled/compiled
diff --git a/cmpen472hw5_McDonnell/Sources/main.asm b/cmpen472hw5_McDonnell/Sources/main.asm
index 5ad91b3..7991c58 100644
--- a/cmpen472hw5_McDonnell/Sources/main.asm
+++ b/cmpen472hw5_McDonnell/Sources/main.asm
@@ -1,40 +1,38 @@
**************************************************************************
*
-* Title: LED Light Dimmer Loop
+* Title: Hardware Controller
*
-* Objective: CMPEN 472 Homework 4
+* Objective: CMPEN 472 Homework 5
*
* Revision: V1.0
*
-* Date: Feb. 14, 2025
+* Date: Feb. 21, 2025
*
* Programmer: Jacob McDonnell
*
* Company: The Pennsylvania State University
* Department of Computer Science and Engineering
*
-* Algorithm: Simple Parallel I/O use, time delay-loop, and PWM control
+* Algorithm: Simple Serial I/O, Parallel I/O use, time delay-loop, and PWM control
*
-* Register Use: A to control LEDS initially and for Light Level
-* X to hold the counter in the loop.
+* Register Use: A & B to control LEDS initially, Light Level, current byte, etc
+* X & Y to hold the counter in the loop and address of strings and length of string.
*
* 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
+* Serial Port for User Input
*
* 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
+* Serial Port for String Output
*
-* Observation: This program will decrease LED 4 from 100% to 0% in 400ms
-* and then increase LED 4 from 0% to 100% in 400ms. The program
-* will loop forever.
+* Observation: This program will respond to user input to turn on and off LEDs 1, 2, & 3,
+* Dim LED 4 from 100% to 0%, Dim LED 4 from 0% to 100%, and echo user input
+* back to the terminal in Type Writer Mode.
*
* Note: ON CSM-12C128 board,
* Switch 1 is at PORTB bit 0, and
@@ -79,16 +77,10 @@ Counter dc.w $0036 ; X register count number for time Delay
LEVEL dc.b $0005 ; Light Level that the LED should be
-msg dc.b 'L1: Turn on LED1',CR,LF,
- 'F1: Turn off LED1',CR,LF
- 'L2: Turn on LED2',CR,LF
- 'F2: Turn off LED2',CR,LF
- 'L3: Turn on LED3',CR,LF
- 'F3: Turn off LED3',CR,LF
- 'L4: LED4 goes from 0% light level to 100% light level in 0.4 seconds',CR,LF
- 'F4: LED4 goes from 100% light level to 0% light level in 0.4 seconds',CR,LF
- 'QUIT: Quit menu program, run \'Type writer\' program.',CR,LF,NULL
-
+str ds.b $0005 ; Array of 5 bytes to read a string
+ dc.b NULL
+lenStr dc.w $0005 ; Length of str array
+* There is a second Data Section at the end of the file.
*
**************************************************************************
* Program Section: address used [ $3100 to $3FFF ] RAM Memory
@@ -99,16 +91,195 @@ 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
+
+
mainLoop
- ldx msg
- jsr WriteString
+ ldx #msg ; Load the address of msg into X
+ jsr WriteString ; Jump to WriteString to output message on serial
+
+ ldx #str ; Load the address of str into X
+ ldy lenStr ; Load length of str into Y
+ jsr Zeros ; jump to Zeros to zero out str
+
+ ldx #str ; Reload address of str into X
+ jsr ReadString ; Jump to ReadString to read user input into str
+
+ ldx #str ; Reload Address of str into X
+ jsr CheckInput ; Jump to CheckInput to handle user input
bra mainLoop ; Loop back to mainLoop always
+TypeWriter ldx #twMsg ; Load Type Writer welcome message address
+ jsr WriteString ; Jump to WriteString to write message to serial
+twReadLoop jsr getchar ; Read Character from Serial
+ beq twReadLoop ; While Character == 0, branch to twReadLoop
+ jsr putchar ; Write Character back to terminal
+ staa PORTB ; Write Character to PORTB
+ bra twReadLoop ; Branch always to twReadLoop
**************************************************************************
* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory
*
;*************************************************************************
+; CheckInput subroutine
+;
+; This subroutine will check the input string and match the option.
+;
+; 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, Y for the address of the
+; option to compare against, and A for the return value of strcmp
+; Memory locations in use: Memory Address for serial line, address of the string
+;
+; Comments: This subroutine will not return a value, it will jump to the proper subroutine
+; based on the input given.
+;
+
+CheckInput
+ pshy ; Save Y to the stack
+ psha ; Save A to the stack
+ ldy #option1 ; Load address of option1 string into Y
+ jsr strcmp ; Compare input string and option1 string
+ bne check2 ; If not equal, branch to next check
+ ldaa #1 ; Load 1 into A to specify LED number
+ jsr TurnOnLED ; Jump to TurnOnLED to turn on LED 1
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check2 ldy #option2 ; Load address of option2 string into Y
+ jsr strcmp ; Compare input string and option2 string
+ bne check3 ; If not equal, branch to next check
+ ldaa #1 ; Load 1 into A to specify LED number
+ jsr TurnOffLED ; Jump to TurnOffLED to turn on LED 1
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check3 ldy #option3 ; Load address of option3 string into Y
+ jsr strcmp ; Compare input string and option3 string
+ bne check4 ; If not equal, branch to next check
+ ldaa #2 ; Load 2 into A to specify LED number
+ jsr TurnOnLED ; Jump to TurnOnLED to turn on LED 2
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check4 ldy #option4 ; Load address of option4 string into Y
+ jsr strcmp ; Compare input string and option4 string
+ bne check5 ; If not equal, branch to next check
+ ldaa #2 ; Load 2 into A to specify LED number
+ jsr TurnOffLED ; Jump to TurnOffLED to turn on LED 2
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check5 ldy #option5 ; Load address of option5 string into Y
+ jsr strcmp ; Compare input string and option5 string
+ bne check6 ; If not equal, branch to next check
+ ldaa #3 ; Load 3 into A to specify LED number
+ jsr TurnOnLED ; Jump to TurnOnLED to turn on LED 3
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check6 ldy #option6 ; Load address of option6 string into Y
+ jsr strcmp ; Compare input string and option6 string
+ bne check7 ; If not equal, branch to next check
+ ldaa #3 ; Load 3 into A to specify LED number
+ jsr TurnOffLED ; Jump to TurnOffLED to turn off LED 3
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check7 ldy #option7 ; Load address of option7 string into Y
+ jsr strcmp ; Compare input string and option7 string
+ bne check8 ; If not equal, branch to next check
+ jsr LowToHigh ; Jump to LowToHigh to dim LED 4 from 0% to 100%
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check8 ldy #option8 ; Load address of option8 string into Y
+ jsr strcmp ; Compare input string and option8 string
+ bne check9 ; If not equal, branch to next check
+ jsr HighToLow ; Jump to LowToHigh to dim LED 4 from 100% to 0%
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check9 ldy #option9 ; Load address of option9 string into Y
+ jsr strcmp ; Compare input string and option9 string
+ bne none ; If not equal, branch to unknown result
+ jmp TypeWriter ; Jump to TypeWriter portion of main routine
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+none ldx #unknown ; Load address of uknown command string into X
+ jsr WriteString ; Write unknown command string to serial
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+
+;*************************************************************************
+; 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
+
+;*************************************************************************
+; strcmp subroutine
+;
+; This subroutine will compare two null terminated strings.
+;
+; Input: Address of 2 null terminated strings in X & Y
+; Output: 0 or 1 in accumulator A to signal same and different respectively
+; Registers in use: X & Y for the address of the strings and A & B for the current bytes
+; Memory locations in use: Memory Address for serial line, address of the strings
+;
+; Comments: This subroutine requires null terminated strings otherwise it will not work.
+;
+
+strcmp
+ pshb ; Save A to the Stack
+ pshx ; Save X to the Stack
+ pshy ; Save Y to the Stack
+cmpLoop ldaa 1,x+ ; Load byte at X into A
+ beq diffX ; If A == 0, branch to diffX
+ ldab 1,y+ ; Load byte at Y into B
+ beq diffY ; If B == 0, branch to diffY
+ sba ; Subtract B from A and store in A
+ beq cmpLoop ; If zero Loop, the characters are the same
+ ldaa #1 ; Load 1 into A to signal difference
+ puly ; Restore Y from the Stack
+ pulx ; Restore X from the Stack
+ pulb ; Restore B from the Stack
+ rts ; Return to Caller
+diffX ldaa y ; Load character at Y into A
+ beq equal ; If A == 0, Y and X are the same, branch to equal
+diffY ldaa #1 ; Load 1 into A to signal difference
+ puly ; Restore Y from the Stack
+ pulx ; Restore X from the Stack
+ pulb ; Restore B from the stack
+ rts ; Return to caller
+equal clra ; Clear A to signal similarity
+ puly ; Restore Y from the Stack
+ pulx ; Restore X from the Stack
+ pulb ; Restore B from the stack
+ rts ; Return to caller
+
+;*************************************************************************
; WriteString subroutine
;
; This subroutine will write a given null terminated string to the serial.
@@ -131,6 +302,35 @@ 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 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
+ 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
+ bra readLoop ; branch always to readLoop
+doneRead ldaa #LF ; Load Line Feed into A
+ jsr putchar ; Write LF to terminal
+ pulx ; Restore X from the stack
+ pula ; restore A from the stack
+ rts ; return to caller
+
+;*************************************************************************
; TurnOnLED subroutine
;
; This subroutine will dim turn on a specified LED
@@ -224,7 +424,7 @@ LowToHigh
psha ; Save accumulator A to the stack
ldaa #0 ; load 100 into accumulator A
increase cmpa #100 ; Compare A to 100
- beq mainLoop ; Test if A == 100, jump to mainLoop
+ beq doneInc ; Test if A == 100, jump to doneInc
staa LEVEL ; Save A to LEVEL
jsr dimmer ; jump to dimmer subroutine
jsr dimmer ; jump to dimmer subroutine
@@ -328,6 +528,38 @@ getchar brclr SCISR1,#%00100000,getchar7 ; If no input on SCI port, r
getchar7 clra ; Set A to 0
rts ; Return to caller
+**************************************************************************
+* Data Section: address used [ $3100 to $3FFF ] RAM Memory
+*
+
+; unknown: string to warn the user of unknown output
+unknown dc.b 'Error: Unknown Command',CR,LF,NULL
+
+; twMsg: welcome message when type writer loads
+twMsg dc.b 'Welcome to Type Writer, you may type below.',CR,LF,NULL
+
+; Below are strings of the options to compare in CheckInput
+option1 dc.b 'L1',NULL
+option2 dc.b 'F1',NULL
+option3 dc.b 'L2',NULL
+option4 dc.b 'F2',NULL
+option5 dc.b 'L3',NULL
+option6 dc.b 'F3',NULL
+option7 dc.b 'L4',NULL
+option8 dc.b 'F4',NULL
+option9 dc.b 'QUIT',NULL
+
+; msg: this is the main option menu string
+msg dc.b 'L1: Turn on LED1',CR,LF
+ dc.b 'F1: Turn off LED1',CR,LF
+ dc.b 'L2: Turn on LED2',CR,LF
+ dc.b 'F2: Turn off LED2',CR,LF
+ dc.b 'L3: Turn on LED3',CR,LF
+ dc.b 'F3: Turn off LED3',CR,LF
+ dc.b 'L4: LED4 goes from 0% light level to 100% light level in 0.4 seconds',CR,LF
+ dc.b 'F4: LED4 goes from 100% light level to 0% light level in 0.4 seconds',CR,LF
+ dc.b 'QUIT: Quit menu program, run Type writer program.',CR,LF,NULL
+
end ; last line of the file
diff --git a/cmpen472hw5_McDonnell/bin/Project.abs b/cmpen472hw5_McDonnell/bin/Project.abs
index 079cf26..fcca2ff 100644
--- a/cmpen472hw5_McDonnell/bin/Project.abs
+++ b/cmpen472hw5_McDonnell/bin/Project.abs
Binary files differ
diff --git a/cmpen472hw5_McDonnell/bin/Project.abs.s19 b/cmpen472hw5_McDonnell/bin/Project.abs.s19
index 102dafa..ffd9990 100644
--- a/cmpen472hw5_McDonnell/bin/Project.abs.s19
+++ b/cmpen472hw5_McDonnell/bin/Project.abs.s19
@@ -1,10 +1,30 @@
S0580000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877355F4D63446F6E6E656C6C5C62696E5C50726F6A6563742E6162734B
-S10630000036058E
-S1233100CF310086F15A0386011631338602163133860316313386011631498602163149A2
-S1233120860316314916315F16315F16317916317920D4810126054C0110200C81022605CE
-S12331404C012020034C01403D810126054D0110200C810226054D012020034D01403D369A
-S123316086640440127A30021631941631941631941631944320EB323D36860081642787E7
-S12331807A30021631941631941631941631944220EA323D4C018036B630020440061631DC
-S12331A0B74320F74D01808664B030020440061631B74320F7323D34FE30000926FD30A7EA
-S10431C03DCD
+S10E3000003605000000000000000581
+S1233100CF310086F15A03860C5ACBCC00015CC8CE3329163201CE3003FD30091631D4CE9C
+S1233120300316320DCE300316313F20E3CE32DE1632011632BC27FB1632B55A0120F4358B
+S123314036CD330C1631DD2608860116322732313DCD330F1631DD2608860116323D323171
+S12331603DCD33121631DD2608860216322732313DCD33151631DD2608860216323D32313C
+S12331803DCD33181631DD2608860316322732313DCD331B1631DD2608860316323D32310E
+S12331A03DCD331E1631DD260616326D32313DCD33211631DD260616325332313DCD33243B
+S12331C01631DD260606312D32313DCE32C516320132313D36876A300436FB323D3734354E
+S12331E0A630270EE670270E181627F486013130333DA640270686013130333D873130330E
+S12332003D36A63027051632B520F7323D36341632BC27FB810D27076A301632B520F08639
+S12332200A1632B530323D810126054C0110200C810226054C012020034C01403D810126FE
+S1233240054D0110200C810226054D012020034D01403D3686640440127A300216328816C9
+S123326032881632881632884320EB323D368600816427127A30021632881632881632883D
+S12332801632884220EA323D4C018036B630020440061632AB4320F74D01808664B0300283
+S12332A00440061632AB4320F7323D34FE30000926FD30A73D4FCC80FC5ACF3D4FCC200327
+S12332C096CF3D873D4572726F723A20556E6B6E6F776E20436F6D6D616E640D0A0057657E
+S12332E06C636F6D6520746F2054797065205772697465722C20796F75206D61792074793B
+S123330070652062656C6F772E0D0A004C31004631004C32004632004C33004633004C34F4
+S12333200046340051554954004C313A205475726E206F6E204C4544310D0A46313A2054ED
+S123334075726E206F6666204C4544310D0A4C323A205475726E206F6E204C4544320D0AC0
+S123336046323A205475726E206F6666204C4544320D0A4C333A205475726E206F6E204C4A
+S12333804544330D0A46333A205475726E206F6666204C4544330D0A4C343A204C4544345D
+S12333A020676F65732066726F6D203025206C69676874206C6576656C20746F20313030CE
+S12333C025206C69676874206C6576656C20696E20302E34207365636F6E64730D0A46340B
+S12333E03A204C45443420676F65732066726F6D2031303025206C69676874206C657665EA
+S12334006C20746F203025206C69676874206C6576656C20696E20302E34207365636F6E73
+S123342064730D0A515549543A2051756974206D656E752070726F6772616D2C2072756ECC
+S11B34402054797065207772697465722070726F6772616D2E0D0A0094
S9030000FC
diff --git a/cmpen472hw5_McDonnell/bin/main.dbg b/cmpen472hw5_McDonnell/bin/main.dbg
index 5582c28..b4bf1c4 100644
--- a/cmpen472hw5_McDonnell/bin/main.dbg
+++ b/cmpen472hw5_McDonnell/bin/main.dbg
@@ -1,40 +1,38 @@
**************************************************************************
*
-* Title: LED Light Dimmer Loop
+* Title: Hardware Controller
*
-* Objective: CMPEN 472 Homework 4
+* Objective: CMPEN 472 Homework 5
*
* Revision: V1.0
*
-* Date: Feb. 14, 2025
+* Date: Feb. 21, 2025
*
* Programmer: Jacob McDonnell
*
* Company: The Pennsylvania State University
* Department of Computer Science and Engineering
*
-* Algorithm: Simple Parallel I/O use, time delay-loop, and PWM control
+* Algorithm: Simple Serial I/O, Parallel I/O use, time delay-loop, and PWM control
*
-* Register Use: A to control LEDS initially and for Light Level
-* X to hold the counter in the loop.
+* Register Use: A & B to control LEDS initially, Light Level, current byte, etc
+* X & Y to hold the counter in the loop and address of strings and length of string.
*
* 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
+* Serial Port for User Input
*
* 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
+* Serial Port for String Output
*
-* Observation: This program will decrease LED 4 from 100% to 0% in 400ms
-* and then increase LED 4 from 0% to 100% in 400ms. The program
-* will loop forever.
+* Observation: This program will respond to user input to turn on and off LEDs 1, 2, & 3,
+* Dim LED 4 from 100% to 0%, Dim LED 4 from 0% to 100%, and echo user input
+* back to the terminal in Type Writer Mode.
*
* Note: ON CSM-12C128 board,
* Switch 1 is at PORTB bit 0, and
@@ -57,6 +55,16 @@ 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
+
+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
*
@@ -66,9 +74,13 @@ Counter dc.w $0036 ; 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.
-
+
LEVEL dc.b $0005 ; Light Level that the LED should be
+str ds.b $0005 ; Array of 5 bytes to read a string
+ dc.b NULL
+lenStr dc.w $0005 ; Length of str array
+* There is a second Data Section at the end of the file.
*
**************************************************************************
* Program Section: address used [ $3100 to $3FFF ] RAM Memory
@@ -79,30 +91,246 @@ 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
+
+
mainLoop
- ldaa #1
- jsr TurnOnLED
- ldaa #2
- jsr TurnOnLED
- ldaa #3
- jsr TurnOnLED
- ldaa #1
- jsr TurnOffLED
- ldaa #2
- jsr TurnOffLED
- ldaa #3
- jsr TurnOffLED
- jsr HighToLow
- jsr HighToLow
- jsr LowToHigh
- jsr LowToHigh
+ ldx #msg ; Load the address of msg into X
+ jsr WriteString ; Jump to WriteString to output message on serial
+
+ ldx #str ; Load the address of str into X
+ ldy lenStr ; Load length of str into Y
+ jsr Zeros ; jump to Zeros to zero out str
+
+ ldx #str ; Reload address of str into X
+ jsr ReadString ; Jump to ReadString to read user input into str
+
+ ldx #str ; Reload Address of str into X
+ jsr CheckInput ; Jump to CheckInput to handle user input
bra mainLoop ; Loop back to mainLoop always
+TypeWriter ldx #twMsg ; Load Type Writer welcome message address
+ jsr WriteString ; Jump to WriteString to write message to serial
+twReadLoop jsr getchar ; Read Character from Serial
+ beq twReadLoop ; While Character == 0, branch to twReadLoop
+ jsr putchar ; Write Character back to terminal
+ staa PORTB ; Write Character to PORTB
+ bra twReadLoop ; Branch always to twReadLoop
**************************************************************************
* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory
*
;*************************************************************************
+; CheckInput subroutine
+;
+; This subroutine will check the input string and match the option.
+;
+; 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, Y for the address of the
+; option to compare against, and A for the return value of strcmp
+; Memory locations in use: Memory Address for serial line, address of the string
+;
+; Comments: This subroutine will not return a value, it will jump to the proper subroutine
+; based on the input given.
+;
+
+CheckInput
+ pshy ; Save Y to the stack
+ psha ; Save A to the stack
+ ldy #option1 ; Load address of option1 string into Y
+ jsr strcmp ; Compare input string and option1 string
+ bne check2 ; If not equal, branch to next check
+ ldaa #1 ; Load 1 into A to specify LED number
+ jsr TurnOnLED ; Jump to TurnOnLED to turn on LED 1
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check2 ldy #option2 ; Load address of option2 string into Y
+ jsr strcmp ; Compare input string and option2 string
+ bne check3 ; If not equal, branch to next check
+ ldaa #1 ; Load 1 into A to specify LED number
+ jsr TurnOffLED ; Jump to TurnOffLED to turn on LED 1
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check3 ldy #option3 ; Load address of option3 string into Y
+ jsr strcmp ; Compare input string and option3 string
+ bne check4 ; If not equal, branch to next check
+ ldaa #2 ; Load 2 into A to specify LED number
+ jsr TurnOnLED ; Jump to TurnOnLED to turn on LED 2
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check4 ldy #option4 ; Load address of option4 string into Y
+ jsr strcmp ; Compare input string and option4 string
+ bne check5 ; If not equal, branch to next check
+ ldaa #2 ; Load 2 into A to specify LED number
+ jsr TurnOffLED ; Jump to TurnOffLED to turn on LED 2
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check5 ldy #option5 ; Load address of option5 string into Y
+ jsr strcmp ; Compare input string and option5 string
+ bne check6 ; If not equal, branch to next check
+ ldaa #3 ; Load 3 into A to specify LED number
+ jsr TurnOnLED ; Jump to TurnOnLED to turn on LED 3
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check6 ldy #option6 ; Load address of option6 string into Y
+ jsr strcmp ; Compare input string and option6 string
+ bne check7 ; If not equal, branch to next check
+ ldaa #3 ; Load 3 into A to specify LED number
+ jsr TurnOffLED ; Jump to TurnOffLED to turn off LED 3
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check7 ldy #option7 ; Load address of option7 string into Y
+ jsr strcmp ; Compare input string and option7 string
+ bne check8 ; If not equal, branch to next check
+ jsr LowToHigh ; Jump to LowToHigh to dim LED 4 from 0% to 100%
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check8 ldy #option8 ; Load address of option8 string into Y
+ jsr strcmp ; Compare input string and option8 string
+ bne check9 ; If not equal, branch to next check
+ jsr HighToLow ; Jump to LowToHigh to dim LED 4 from 100% to 0%
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+check9 ldy #option9 ; Load address of option9 string into Y
+ jsr strcmp ; Compare input string and option9 string
+ bne none ; If not equal, branch to unknown result
+ jmp TypeWriter ; Jump to TypeWriter portion of main routine
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+none ldx #unknown ; Load address of uknown command string into X
+ jsr WriteString ; Write unknown command string to serial
+ pula ; Restore A from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+
+;*************************************************************************
+; 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
+
+;*************************************************************************
+; strcmp subroutine
+;
+; This subroutine will compare two null terminated strings.
+;
+; Input: Address of 2 null terminated strings in X & Y
+; Output: 0 or 1 in accumulator A to signal same and different respectively
+; Registers in use: X & Y for the address of the strings and A & B for the current bytes
+; Memory locations in use: Memory Address for serial line, address of the strings
+;
+; Comments: This subroutine requires null terminated strings otherwise it will not work.
+;
+
+strcmp
+ pshb ; Save A to the Stack
+ pshx ; Save X to the Stack
+ pshy ; Save Y to the Stack
+cmpLoop ldaa 1,x+ ; Load byte at X into A
+ beq diffX ; If A == 0, branch to diffX
+ ldab 1,y+ ; Load byte at Y into B
+ beq diffY ; If B == 0, branch to diffY
+ sba ; Subtract B from A and store in A
+ beq cmpLoop ; If zero Loop, the characters are the same
+ ldaa #1 ; Load 1 into A to signal difference
+ puly ; Restore Y from the Stack
+ pulx ; Restore X from the Stack
+ pulb ; Restore B from the Stack
+ rts ; Return to Caller
+diffX ldaa y ; Load character at Y into A
+ beq equal ; If A == 0, Y and X are the same, branch to equal
+diffY ldaa #1 ; Load 1 into A to signal difference
+ puly ; Restore Y from the Stack
+ pulx ; Restore X from the Stack
+ pulb ; Restore B from the stack
+ rts ; Return to caller
+equal clra ; Clear A to signal similarity
+ puly ; Restore Y from the Stack
+ pulx ; Restore X from the Stack
+ pulb ; Restore B from the stack
+ 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 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
+ 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
+ bra readLoop ; branch always to readLoop
+doneRead ldaa #LF ; Load Line Feed into A
+ jsr putchar ; Write LF to terminal
+ pulx ; Restore X from the stack
+ pula ; restore A from the stack
+ rts ; return to caller
+
+;*************************************************************************
; TurnOnLED subroutine
;
; This subroutine will dim turn on a specified LED
@@ -124,7 +352,7 @@ onCheckTwo cmpa #2 ; Compare A to 2
bne onCheckThr ; If A != 2, check next number
bset PORTB,%00100000 ; Turn On LED 2
bra onDone ; Jump to onDone
-onCheckThr bset PORTB,%01000000 ; Turn On LED 3
+onCheckThr bset PORTB,%01000000 ; Turn On LED 3
onDone rts ; Return to caller
;*************************************************************************
@@ -149,7 +377,7 @@ ofCheckTwo cmpa #2 ; Compare A to 2
bne ofCheckThr ; If A != 2, check next number
bclr PORTB,%00100000 ; Turn Off LED 2
bra ofDone ; Jump to onDone
-ofCheckThr bclr PORTB,%01000000 ; Turn Off LED 3
+ofCheckThr bclr PORTB,%01000000 ; Turn Off LED 3
ofDone rts ; Return to caller
;*************************************************************************
@@ -178,7 +406,7 @@ decrease tbeq A,doneDec ; Test if A == 0, skip loop if so
bra decrease ; loop to decrease always
doneDec pula ; Restore A from the stack
rts ; Return to caller
-
+
;*************************************************************************
; HighToLow subroutine
;
@@ -196,7 +424,7 @@ LowToHigh
psha ; Save accumulator A to the stack
ldaa #0 ; load 100 into accumulator A
increase cmpa #100 ; Compare A to 100
- beq mainLoop ; Test if A == 100, jump to mainLoop
+ beq doneInc ; Test if A == 100, jump to doneInc
staa LEVEL ; Save A to LEVEL
jsr dimmer ; jump to dimmer subroutine
jsr dimmer ; jump to dimmer subroutine
@@ -252,9 +480,9 @@ doneLoop pula ; restore A from the stack
; 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.
;
@@ -268,3 +496,68 @@ innerLoop dex ; decrement register x by 1
nop ; extra nop to make exactly 10 usec
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: address used [ $3100 to $3FFF ] RAM Memory
+*
+
+; unknown: string to warn the user of unknown output
+unknown dc.b 'Error: Unknown Command',CR,LF,NULL
+
+; twMsg: welcome message when type writer loads
+twMsg dc.b 'Welcome to Type Writer, you may type below.',CR,LF,NULL
+
+; Below are strings of the options to compare in CheckInput
+option1 dc.b 'L1',NULL
+option2 dc.b 'F1',NULL
+option3 dc.b 'L2',NULL
+option4 dc.b 'F2',NULL
+option5 dc.b 'L3',NULL
+option6 dc.b 'F3',NULL
+option7 dc.b 'L4',NULL
+option8 dc.b 'F4',NULL
+option9 dc.b 'QUIT',NULL
+
+; msg: this is the main option menu string
+msg dc.b 'L1: Turn on LED1',CR,LF
+ dc.b 'F1: Turn off LED1',CR,LF
+ dc.b 'L2: Turn on LED2',CR,LF
+ dc.b 'F2: Turn off LED2',CR,LF
+ dc.b 'L3: Turn on LED3',CR,LF
+ dc.b 'F3: Turn off LED3',CR,LF
+ dc.b 'L4: LED4 goes from 0% light level to 100% light level in 0.4 seconds',CR,LF
+ dc.b 'F4: LED4 goes from 100% light level to 0% light level in 0.4 seconds',CR,LF
+ dc.b 'QUIT: Quit menu program, run Type writer program.',CR,LF,NULL
+
+
diff --git a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell.mcp b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell.mcp
index f325553..ded6ff3 100644
--- a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell.mcp
+++ b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell.mcp
Binary files differ
diff --git a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/CWSettingsWindows.stg b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/CWSettingsWindows.stg
index 1d0d370..a8536b0 100644
--- a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/CWSettingsWindows.stg
+++ b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/CWSettingsWindows.stg
Binary files differ
diff --git a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.o
index 079cf26..fcca2ff 100644
--- a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.o
+++ b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.o
Binary files differ
diff --git a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.sx
index 540e06c..75a580d 100644
--- a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.sx
+++ b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/ObjectCode/main.asm.sx
@@ -1,10 +1,30 @@
S0840000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877355F4D63446F6E6E656C6C5C636D70656E3437326877355F4D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726DCF
-S10630000036058E
-S1233100CF310086F15A0386011631338602163133860316313386011631498602163149A2
-S1233120860316314916315F16315F16317916317920D4810126054C0110200C81022605CE
-S12331404C012020034C01403D810126054D0110200C810226054D012020034D01403D369A
-S123316086640440127A30021631941631941631941631944320EB323D36860081642787E7
-S12331807A30021631941631941631941631944220EA323D4C018036B630020440061631DC
-S12331A0B74320F74D01808664B030020440061631B74320F7323D34FE30000926FD30A7EA
-S10431C03DCD
+S10E3000003605000000000000000581
+S1233100CF310086F15A03860C5ACBCC00015CC8CE3329163201CE3003FD30091631D4CE9C
+S1233120300316320DCE300316313F20E3CE32DE1632011632BC27FB1632B55A0120F4358B
+S123314036CD330C1631DD2608860116322732313DCD330F1631DD2608860116323D323171
+S12331603DCD33121631DD2608860216322732313DCD33151631DD2608860216323D32313C
+S12331803DCD33181631DD2608860316322732313DCD331B1631DD2608860316323D32310E
+S12331A03DCD331E1631DD260616326D32313DCD33211631DD260616325332313DCD33243B
+S12331C01631DD260606312D32313DCE32C516320132313D36876A300436FB323D3734354E
+S12331E0A630270EE670270E181627F486013130333DA640270686013130333D873130330E
+S12332003D36A63027051632B520F7323D36341632BC27FB810D27076A301632B520F08639
+S12332200A1632B530323D810126054C0110200C810226054C012020034C01403D810126FE
+S1233240054D0110200C810226054D012020034D01403D3686640440127A300216328816C9
+S123326032881632881632884320EB323D368600816427127A30021632881632881632883D
+S12332801632884220EA323D4C018036B630020440061632AB4320F74D01808664B0300283
+S12332A00440061632AB4320F7323D34FE30000926FD30A73D4FCC80FC5ACF3D4FCC200327
+S12332C096CF3D873D4572726F723A20556E6B6E6F776E20436F6D6D616E640D0A0057657E
+S12332E06C636F6D6520746F2054797065205772697465722C20796F75206D61792074793B
+S123330070652062656C6F772E0D0A004C31004631004C32004632004C33004633004C34F4
+S12333200046340051554954004C313A205475726E206F6E204C4544310D0A46313A2054ED
+S123334075726E206F6666204C4544310D0A4C323A205475726E206F6E204C4544320D0AC0
+S123336046323A205475726E206F6666204C4544320D0A4C333A205475726E206F6E204C4A
+S12333804544330D0A46333A205475726E206F6666204C4544330D0A4C343A204C4544345D
+S12333A020676F65732066726F6D203025206C69676874206C6576656C20746F20313030CE
+S12333C025206C69676874206C6576656C20696E20302E34207365636F6E64730D0A46340B
+S12333E03A204C45443420676F65732066726F6D2031303025206C69676874206C657665EA
+S12334006C20746F203025206C69676874206C6576656C20696E20302E34207365636F6E73
+S123342064730D0A515549543A2051756974206D656E752070726F6772616D2C2072756ECC
+S11B34402054797065207772697465722070726F6772616D2E0D0A0094
S9033100CB
diff --git a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/TargetDataWindows.tdt
index 1eb3593..1a420fc 100644
--- a/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/TargetDataWindows.tdt
+++ b/cmpen472hw5_McDonnell/cmpen472hw5_McDonnell_Data/Standard/TargetDataWindows.tdt
Binary files differ