More bug fixes and optimizations. Added U as an explicit upload command
This commit is contained in:
@@ -49,8 +49,8 @@ uart_init
|
|||||||
sta uart_reg4 ; Enable RTS
|
sta uart_reg4 ; Enable RTS
|
||||||
LDA #$87 ; FIFO enable, reset RCVR/XMIT FIFO
|
LDA #$87 ; FIFO enable, reset RCVR/XMIT FIFO
|
||||||
sta uart_reg2
|
sta uart_reg2
|
||||||
lda #$01 ; Enable receiver interrupt
|
; lda #$01 ; Enable receiver interrupt
|
||||||
sta uart_reg1
|
; sta uart_reg1
|
||||||
jsr AFE_16C550 ; Enable auto flow control
|
jsr AFE_16C550 ; Enable auto flow control
|
||||||
rts ; done
|
rts ; done
|
||||||
|
|
||||||
|
|||||||
24
sbcmon.asm
24
sbcmon.asm
@@ -223,14 +223,12 @@ monitor_loop
|
|||||||
jsr input_char ; Get user input; blocking
|
jsr input_char ; Get user input; blocking
|
||||||
cmp #32 ; Control character?
|
cmp #32 ; Control character?
|
||||||
bcc ml_not_printable ; not printable
|
bcc ml_not_printable ; not printable
|
||||||
cmp #127 ; non-ascii characters?
|
|
||||||
bcs ml_not_printable
|
|
||||||
jsr output_char ; Echo
|
jsr output_char ; Echo
|
||||||
ml_not_printable
|
ml_not_printable
|
||||||
cmp #':' ; HEX upload?
|
; cmp #':' ; HEX upload?
|
||||||
bne nothex
|
; bne nothex
|
||||||
jmp HexUpLd
|
; jmp HexUpLd
|
||||||
nothex
|
;nothex
|
||||||
cmp #'?'
|
cmp #'?'
|
||||||
bne nothelp
|
bne nothelp
|
||||||
jmp go_help
|
jmp go_help
|
||||||
@@ -247,7 +245,11 @@ notmem
|
|||||||
bne notdump
|
bne notdump
|
||||||
jmp go_dump
|
jmp go_dump
|
||||||
notdump
|
notdump
|
||||||
jmp monitor_loop ; Reloop if invalid command
|
cmp #'U'
|
||||||
|
bne notupload
|
||||||
|
jmp hexupld
|
||||||
|
notupload
|
||||||
|
jmp monitor ;_loop ; Reloop if invalid command
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
;---------------------------------------------------------------------
|
||||||
; Go and run a program...
|
; Go and run a program...
|
||||||
@@ -368,12 +370,12 @@ ghc_abort
|
|||||||
;---------------------------------------------------------------------
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
helptxt
|
helptxt
|
||||||
.byte $0d,$0a,"6502 Monitor RC2014 v0.1.2"
|
.byte $0d,$0a,"6502 Monitor RC2014 v0.1.3"
|
||||||
.byte CR,LF,"? Print this help"
|
.byte CR,LF,"? Print this help"
|
||||||
.byte CR,LF,"D XXXX Dump memory from XXXX"
|
.byte CR,LF,"D XXXX Dump memory from XXXX"
|
||||||
.byte CR,LF,"E XXXX Edit memory from XXXX" ;; CR to skip"
|
.byte CR,LF,"E XXXX Edit memory from XXXX"
|
||||||
.byte CR,LF,"G XXXX Go execute from XXXX"
|
.byte CR,LF,"G XXXX Go execute from XXXX"
|
||||||
.byte CR,LF,":sHLtD...C Load Intel HEX file, ':' is part of file",0
|
.byte CR,LF,"U Upload Intel HEX file",0
|
||||||
helptxt2:
|
helptxt2:
|
||||||
.byte CR,LF," ESC to quit when upload is done"
|
.byte CR,LF," ESC to quit when upload is done"
|
||||||
.byte $0d, $0a
|
.byte $0d, $0a
|
||||||
@@ -587,7 +589,7 @@ Hexdigdata .byte "0123456789ABCDEF";hex char table
|
|||||||
;
|
;
|
||||||
buildtxt
|
buildtxt
|
||||||
.byte $0d, $0a
|
.byte $0d, $0a
|
||||||
.byte "6502 Board for RC2014"
|
.byte "6502 CPU for RC2014"
|
||||||
.byte $0d, $0a
|
.byte $0d, $0a
|
||||||
.byte $00
|
.byte $00
|
||||||
|
|
||||||
|
|||||||
72
upload.asm
72
upload.asm
@@ -16,11 +16,6 @@ rectype = $ee
|
|||||||
bytecount_l = $f0
|
bytecount_l = $f0
|
||||||
bytecount_h = $f1
|
bytecount_h = $f1
|
||||||
|
|
||||||
CR = 13
|
|
||||||
LF = 10
|
|
||||||
ESC = 27 ; ESC to exit
|
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
;****************************************************
|
;****************************************************
|
||||||
@@ -34,26 +29,40 @@ HexUpLd
|
|||||||
sta dlfail ;Start by assuming no D/L failure
|
sta dlfail ;Start by assuming no D/L failure
|
||||||
sta bytecount_l
|
sta bytecount_l
|
||||||
sta bytecount_h
|
sta bytecount_h
|
||||||
beq IHex ; Equivalent to a BRA
|
lda #>MsgStart
|
||||||
|
ldx #<MsgStart
|
||||||
|
jsr PrintStrAX
|
||||||
|
; beq IHex ; Equivalent to a BRA
|
||||||
; Record processing loop
|
; Record processing loop
|
||||||
HdwRecs jsr GetSer ; Wait for start of record mark ':'
|
HdwRecs
|
||||||
|
jsr input_char
|
||||||
|
cmp #ESC ; If we pressed ESC
|
||||||
|
bne hul0
|
||||||
|
hul1
|
||||||
|
jmp HdEr3
|
||||||
|
; jsr GetSer ; Wait for start of record mark ':'
|
||||||
|
hul0
|
||||||
cmp #':'
|
cmp #':'
|
||||||
bne HdwRecs ; not found yet
|
bne HdwRecs ; not found yet
|
||||||
; Start of record marker has been found
|
; Start of record marker has been found
|
||||||
IHex jsr GetHex ; Get the record length
|
IHex jsr GetHex ; Get the record length
|
||||||
|
bcs hul1 ; ESC = quit
|
||||||
sta reclen ; save it
|
sta reclen ; save it
|
||||||
sta chksum ; and save first byte of checksum
|
sta chksum ; and save first byte of checksum
|
||||||
jsr GetHex ; Get the high part of start address
|
jsr GetHex ; Get the high part of start address
|
||||||
|
bcs hul1 ; ESC = quit
|
||||||
sta start_hi
|
sta start_hi
|
||||||
clc
|
clc
|
||||||
adc chksum ; Add in the checksum
|
adc chksum ; Add in the checksum
|
||||||
sta chksum ;
|
sta chksum ;
|
||||||
jsr GetHex ; Get the low part of the start address
|
jsr GetHex ; Get the low part of the start address
|
||||||
|
bcs hul1 ; ESC = quit
|
||||||
sta start_lo
|
sta start_lo
|
||||||
clc
|
clc
|
||||||
adc chksum
|
adc chksum
|
||||||
sta chksum
|
sta chksum
|
||||||
jsr GetHex ; Get the record type
|
jsr GetHex ; Get the record type
|
||||||
|
bcs HdEr3
|
||||||
sta rectype ; & save it
|
sta rectype ; & save it
|
||||||
clc
|
clc
|
||||||
adc chksum
|
adc chksum
|
||||||
@@ -62,8 +71,10 @@ IHex jsr GetHex ; Get the record length
|
|||||||
bne HdEr1 ; end-of-record
|
bne HdEr1 ; end-of-record
|
||||||
ldx reclen ; number of data bytes to write to memory
|
ldx reclen ; number of data bytes to write to memory
|
||||||
ldy #0 ; start offset at 0
|
ldy #0 ; start offset at 0
|
||||||
|
|
||||||
; Data handler loop
|
; Data handler loop
|
||||||
HdLp1 jsr GetHex ; Get the first/next/last data byte
|
HdLp1 jsr GetHex ; Get the first/next/last data byte
|
||||||
|
bcs HdEr3
|
||||||
sta (start_lo),y ; Save it to RAM
|
sta (start_lo),y ; Save it to RAM
|
||||||
inc bytecount_l ; increment byte count
|
inc bytecount_l ; increment byte count
|
||||||
bne bc_1
|
bne bc_1
|
||||||
@@ -76,12 +87,14 @@ bc_1
|
|||||||
dex ; decrement count
|
dex ; decrement count
|
||||||
bne HdLp1
|
bne HdLp1
|
||||||
jsr GetHex ; get the checksum
|
jsr GetHex ; get the checksum
|
||||||
|
bcs HdEr3
|
||||||
clc
|
clc
|
||||||
adc chksum
|
adc chksum
|
||||||
bne HdDlF1 ; If failed, report it
|
bne HdDlF1 ; If failed, report it
|
||||||
; Another successful record has been processed
|
; Another successful record has been processed
|
||||||
lda #'#' ; Character indicating record OK = '#'
|
lda #'.' ; Character indicating record OK = '.'
|
||||||
sta uart_xmit ; write it out but don't wait for output
|
sta uart_xmit ; write it out but don't wait for output
|
||||||
|
; jsr output_char
|
||||||
jmp HdwRecs ; get next record
|
jmp HdwRecs ; get next record
|
||||||
; Bad checksum
|
; Bad checksum
|
||||||
HdDlF1 lda #'F' ; Character indicating record failure = 'F'
|
HdDlF1 lda #'F' ; Character indicating record failure = 'F'
|
||||||
@@ -105,7 +118,8 @@ HdEr1 cmp #1 ; Check for end-of-record type
|
|||||||
jmp HdwRecs
|
jmp HdwRecs
|
||||||
|
|
||||||
; We've reached the end-of-record record
|
; We've reached the end-of-record record
|
||||||
HdEr2 jsr GetHex ; get the checksum
|
HdEr2 jsr GetHex ; get the checksum
|
||||||
|
bcs HdEr3 ; ESC = quit
|
||||||
clc
|
clc
|
||||||
adc chksum ; Add previous checksum accumulator value
|
adc chksum ; Add previous checksum accumulator value
|
||||||
beq HdEr3 ; checksum = 0 means we're OK!
|
beq HdEr3 ; checksum = 0 means we're OK!
|
||||||
@@ -113,14 +127,17 @@ HdEr2 jsr GetHex ; get the checksum
|
|||||||
ldx #<MsgBadRecChksum
|
ldx #<MsgBadRecChksum
|
||||||
jsr PrintStrAX
|
jsr PrintStrAX
|
||||||
jmp HdErNX
|
jmp HdErNX
|
||||||
; Completion
|
|
||||||
|
; -------------------
|
||||||
|
; We're done here
|
||||||
HdEr3 lda dlfail
|
HdEr3 lda dlfail
|
||||||
beq HdErOK
|
beq HdErOK ; No errors
|
||||||
;A upload failure has occurred
|
;A upload failure has occurred
|
||||||
lda #>MsgUploadFail
|
lda #>MsgUploadFail
|
||||||
ldx #<MsgUploadFail
|
ldx #<MsgUploadFail
|
||||||
jsr PrintStrAX
|
jsr PrintStrAX
|
||||||
jmp HdErNX
|
jmp HdErNX ; Quit
|
||||||
|
; No errors
|
||||||
HdErOK lda #>MsgUploadOK
|
HdErOK lda #>MsgUploadOK
|
||||||
ldx #<MsgUploadOK
|
ldx #<MsgUploadOK
|
||||||
jsr PrintStrAX
|
jsr PrintStrAX
|
||||||
@@ -136,22 +153,29 @@ HdErNX
|
|||||||
; subroutines
|
; subroutines
|
||||||
;
|
;
|
||||||
|
|
||||||
GetSer jsr input_char ; get input from Serial Port
|
;GetSer jsr input_char ; get input from Serial Port
|
||||||
cmp #ESC ; check for abort
|
; cmp #ESC ; check for abort
|
||||||
bne GSerXit ; return character if not
|
; bne GSerXit ; return character if not
|
||||||
|
;
|
||||||
; Escape
|
; ; Escape
|
||||||
jmp HdEr3
|
; jmp HdEr3
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
; Exit: CY=1 if ESC
|
||||||
GetHex lda #$00
|
GetHex lda #$00
|
||||||
sta temp
|
sta temp
|
||||||
jsr GetNibl
|
jsr GetNibl
|
||||||
|
bcs gh_quit
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
asl a ; This is the upper nibble
|
asl a ; This is the upper nibble
|
||||||
sta temp
|
sta temp
|
||||||
GetNibl jsr GetSer
|
GetNibl
|
||||||
|
; jsr GetSer
|
||||||
|
jsr input_char
|
||||||
|
cmp #ESC
|
||||||
|
beq gh_quit
|
||||||
; Convert the ASCII nibble to numeric value from 0-F:
|
; Convert the ASCII nibble to numeric value from 0-F:
|
||||||
cmp #'9'+1 ; See if it's 0-9 or 'A'..'F' (no lowercase yet)
|
cmp #'9'+1 ; See if it's 0-9 or 'A'..'F' (no lowercase yet)
|
||||||
bcc MkNnh ; If we borrowed, we lost the carry so 0..9
|
bcc MkNnh ; If we borrowed, we lost the carry so 0..9
|
||||||
@@ -160,8 +184,12 @@ GetNibl jsr GetSer
|
|||||||
MkNnh sbc #'0'-1 ; subtract off '0' (if carry clear coming in)
|
MkNnh sbc #'0'-1 ; subtract off '0' (if carry clear coming in)
|
||||||
and #$0F ; no upper nibble no matter what
|
and #$0F ; no upper nibble no matter what
|
||||||
ora temp
|
ora temp
|
||||||
GSerXit
|
clc
|
||||||
|
;GSerXit
|
||||||
rts ; return with the nibble received
|
rts ; return with the nibble received
|
||||||
|
gh_quit
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -181,6 +209,10 @@ MsgUploadFail .byte CR,LF
|
|||||||
MsgUploadOK .byte CR,LF
|
MsgUploadOK .byte CR,LF
|
||||||
.byte "Upload byte count: "
|
.byte "Upload byte count: "
|
||||||
.byte 0
|
.byte 0
|
||||||
|
|
||||||
|
MsgStart .byte CR, LF
|
||||||
|
.byte "Upload now (ESC to quit):"
|
||||||
|
.byte 0
|
||||||
|
|
||||||
; Fin.
|
; Fin.
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user