summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmpen472hw5_McDonnell/Sources/main.asm78
1 files changed, 43 insertions, 35 deletions
diff --git a/cmpen472hw5_McDonnell/Sources/main.asm b/cmpen472hw5_McDonnell/Sources/main.asm
index 06b44c8..5ad91b3 100644
--- a/cmpen472hw5_McDonnell/Sources/main.asm
+++ b/cmpen472hw5_McDonnell/Sources/main.asm
@@ -65,6 +65,7 @@ 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
@@ -78,6 +79,16 @@ 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
+
*
**************************************************************************
* Program Section: address used [ $3100 to $3FFF ] RAM Memory
@@ -89,6 +100,8 @@ pgstart lds #$3100 ; initialize the stack pointer
staa DDRB ; set PORTB bit 4,5,6,7 as output
mainLoop
+ ldx msg
+ jsr WriteString
bra mainLoop ; Loop back to mainLoop always
**************************************************************************
@@ -283,43 +296,38 @@ innerLoop dex ; decrement register x by 1
nop ; extra nop to make exactly 10 usec
rts ; return to caller
-;***************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*****************
+;*************************************************************************
+; 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
-;****************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****************
end ; last line of the file