summaryrefslogtreecommitdiff
path: root/cmpen472hw12_McDonnell/Sources/main.asm
diff options
context:
space:
mode:
Diffstat (limited to 'cmpen472hw12_McDonnell/Sources/main.asm')
-rw-r--r--cmpen472hw12_McDonnell/Sources/main.asm48
1 files changed, 38 insertions, 10 deletions
diff --git a/cmpen472hw12_McDonnell/Sources/main.asm b/cmpen472hw12_McDonnell/Sources/main.asm
index 3abe95a..a5935af 100644
--- a/cmpen472hw12_McDonnell/Sources/main.asm
+++ b/cmpen472hw12_McDonnell/Sources/main.asm
@@ -98,10 +98,6 @@ pgstart lds #$3100 ; initialize the stack pointer
jsr WriteString ; Write the string to the serial console
mainLoop
- ldx #$3000
- ldy #$0100
- jsr MDCommand
-
ldx #buffer ; Load the address of the buffer into X
ldy lenBuf ; Load the length of the buffer into Y
jsr Zeros ; Fill the buffer with zeros
@@ -151,16 +147,18 @@ CheckInput
pshd ; Save D to the stack
ldaa 1,x+ ; Read Character from the string in X
cmpa #'W' ; Compare Character to 'W'
- beq cWrite ; If A == 'W', branch to cWrite
+ lbeq cWrite ; If A == 'W', branch to cWrite
cmpa #'Q' ; Compare A to 'Q'
- beq cTypeWrite ; If A == 'Q', branch to cTypeWrite
+ lbeq cTypeWrite ; If A == 'Q', branch to cTypeWrite
+ cmpa #'M' ; Compare A to 'M'
+ beq cMDCommand ; If A != 'M', Check if MD command
cmpa #'S' ; Compare A to 'S'
- bne cUnknownCMD ; If A != 'S', Command unknown
+ lbne cUnknownCMD ; If A != 'S', Command unknown
ldaa 0,x ; Load next character but don't increment
cmpa #'$' ; Compare A to '$'
- bne cUnknownCMD ; If A != '$', branch to unknown command
+ lbne cUnknownCMD ; If A != '$', branch to unknown command
jsr ReadHex ; ReadHex to Read the memory Address
- beq cBadAddr ; If Z == 1, branch to cBadAddr
+ lbeq cBadAddr ; If Z == 1, branch to cBadAddr
exg Y,X ; Exchange Y for X
pshx ; Save X to the stack
ldx #buffer ; Load address of buffer into X
@@ -168,6 +166,33 @@ CheckInput
jsr Zeros ; Fill buffer with Zeros
pulx ; Restore X from the stack
bra cDone ; branch always to cDone
+cMDCommand ldaa 1,x+ ; Load next character into A
+ cmpa #'D' ; Compare do 'D' character
+ bne cUnknownCMD ; If A != 'D', unknown command
+ ldaa 0,x ; Load next character but don't increment
+ cmpa #'$' ; Compare A to '$'
+ bne cUnknownCMD ; If A != '$', branch to unknown command
+ jsr ReadHex ; ReadHex to Read the memory Address
+ beq cBadAddr ; If Z == 1, branch to cBadAddr
+ exg Y,D ; Exchange Y and D
+ pshd ; Save D to the stack
+mSkipSpaces ldaa 1,x+ ; Load next character into A
+ beq cBadData ; If A == 0, branch to bad Data (no data given)
+ cmpa #' ' ; Compare A to space character
+ beq mSkipSpaces ; While A == ' ', loop to skip spaces
+ cmpa #'$' ; Compare A to '$'
+ bne cBadData ; If A != '$', branch to cBadData
+ dex ; Decrement X by 1
+ jsr ReadHex ; Jump to ReadHex to read hex data
+ beq cBadData ; If Z == 1, branch to cBadData
+ puld ; Restore D from the stack
+ exg D,X ; Exchange D and X
+ pshd ; Save D to the stack, cBadData usually has 2 D's on the stack
+ cpy #2 ; Compare Y to 2
+ blo cBadData ; No distances below 2 bytes
+ puld ; Restore D from the stack
+ jsr MDCommand ; Jump to MDCommand
+ bra cNoPrint ; Done with command
cWrite ldaa 0,x ; Load next character but don't increment
cmpa #'$' ; Compare A to '$'
bne cUnknownCMD ; If A != '$', branch to unknown command
@@ -192,7 +217,7 @@ cWriteData puld ; Restore D from the stack
exg D,X ; Exchange D and X
sty x ; Write data in Y to memory in X
cDone jsr PrintMem ; Jump to PrintMem to print the contents of the location
- puld ; Restore D from the stack
+cNoPrint puld ; Restore D from the stack
pulx ; Restore X from the stack
rts ; Return to caller
cBadAddr ldx #badAddr ; Load the address of badAddr into X
@@ -818,6 +843,9 @@ twMsg dc.b 'Welcome to Type Writer, you may type below.',CR,LF
; msg: this is the main option menu string
msg dc.b 'S: Show the contents of memory location in word',CR,LF
dc.b 'W: Write the data word (not byte) to memory location',CR,LF
+ dc.b 'MD: Display the contents of continuous memory locations',CR,LF
+ dc.b 'LD: Load a block of data to continuous memory locations',CR,LF
+ dc.b 'GO: Run the program at the specified memory location',CR,LF
dc.b 'QUIT: Quit the main program, run Type writer program.',CR,LF,NULL
end ; last line of the file