SmartyKit 1 ROM asm source & make file

SmartyKit 1 ROM assembler (asm) source and make file for cc65.

Easy-to-use development tool to write your own software for SmartyKLit 1 (you need just run make in your Terminal) and learn how ROM is organized.
This commit is contained in:
Sergei Panarin 2021-01-21 00:25:02 +03:00
parent 03dba1a58e
commit 4f19769784
17 changed files with 2293 additions and 0 deletions

View File

@ -0,0 +1,96 @@
;printing 8x8 picture in the center with '*'
PIC_WIDTH = 8
PIC_HEIGHT = 8
OFFSET_X = (40 - PIC_WIDTH)/2
PIC_ADDRESS = $1111
ROW_ADDRESS = PIC_ADDRESS + PIC_HEIGHT
; Y - row number
; X - column (pixel) number
JSR NEXT_ROW
LDA #$0
STA ROW_ADDRESS ;initialize row counter with 0
LDY #PIC_HEIGHT
ROWS_LOOP: JSR PRINT_OFFSET
LDA ROW_ADDRESS
TAX
LDA PIC_ADDRESS, X
LDX #PIC_WIDTH
NEXT_PIXEL: ASL
BCC NO_PIXEL
JSR PRINT_STAR
JMP AFTER_PIXEL
NO_PIXEL: JSR PRINT_BLANK
AFTER_PIXEL: DEX
BNE NEXT_PIXEL
JSR NEXT_ROW
INC ROW_ADDRESS
DEY
BNE ROWS_LOOP
JSR NEXT_ROW
JMP RESET
;printing offset subroutine (optional: save registers A and X)
PRINT_OFFSET: PHA ;save A
TXA ;X->A
PHA ;save X
LDX #OFFSET_X
OFFSET_LOOP: LDA #' '
JSR ECHO
DEX
BNE OFFSET_LOOP
PLA ;restore X
TAX ;A->X
PLA ;restore A
RTS
PRINT_STAR: PHA
LDA #'*'
JSR ECHO
PLA
RTS
PRINT_BLANK: PHA
LDA #' '
JSR ECHO
PLA
RTS
NEXT_ROW: PHA
LDA #$0d
JSR ECHO
PLA
RTS
;from HeartPicture
;to PIC_ADDRESS ($88)
COPY_HEART: PHA
TXA
PHA
LDX #PIC_HEIGHT
COPY_LOOP: LDA HeartPicture, X
STA PIC_ADDRESS, X
DEX
BPL COPY_LOOP
PLA
TAX
PLA
RTS
HeartPicture:
.byte %00000000
.byte %01100110
.byte %11111111
.byte %11111111
.byte %11111111
.byte %01111110
.byte %00111100
.byte %00011000
SmileyPicture: .byte $3c, $42, $a5, $81, $a5, $99, $42, $3c
WozPicture: .byte $88, $a8, $50, $07, $61, $92, $94, $67
SmartyLogo: .byte $ff, $81, $bd, $bd, $bd, $bd, $81, $ff
RocketPicture: .byte $18, $24, $24, $24, $7e, $a5, $FF, $a5
.byte "8*8 Pixel Art program end", $0d, $00

View File

@ -0,0 +1,525 @@
;SYMBOLS_TABLE = $031D
;INSTRUCTIONS_TABLE = $032D
VAR_X = $0006
VAR_Y = $0007
;addresses from Woz Monitor
;ECHO = $FFEF
;KBD = $D010
;KBDCR = $D011
SCREEN_WIDTH = $28
LDA #$FF
PHA
LDA #$00
PHA
A_0286: LDA #<INSTRUCTIONS
STA VAR_X ;zp
LDA #>INSTRUCTIONS
STA VAR_Y ;zp
A_028R: JSR ECHO_CR
A_0291: LDY #$00
LDA (VAR_X),Y
BEQ A_02B2
LSR A
LSR A
LSR A
LSR A
TAX
LDA (VAR_X),Y
AND #$0F
TAY
LDA SYMBOLS,Y
A_02A4: JSR ECHO
DEX
BNE A_02A4
INC VAR_X ;zp
BNE A_0291
INC VAR_Y ;zp
BNE A_0291
A_02B2: INY
SEC
LDA #SCREEN_WIDTH
SBC (VAR_X),Y
LSR A
TAX
LDA #$A0
A_02BC: JSR ECHO
DEX
BNE A_02BC
LDA (VAR_X),Y
TAX
A_02C5: INY
LDA (VAR_X),Y
JSR ECHO
DEX
BNE A_02C5
INY
TYA
CLC
ADC VAR_X ;zp
STA VAR_X ;zp
LDA #$00
ADC VAR_Y ;zp
STA VAR_Y ;zp
LDA #$10
JSR FUNC_WAIT
JSR ECHO_CR
LDY #$00
LDA (VAR_X),Y
BEQ A_0286
BNE A_028R
FUNC_WAIT: PHA
TXA
PHA
TYA
PHA
LDY #$FF
A_02F2: LDX #$FF
A_02F4: LDA KBDCR
BPL A_0302
PLA
TAY
PLA
TAX
PLA
LDA KBD
RTS
A_0302: DEX
BNE A_02F4
DEY
BNE A_02F2
PLA
TAY
PLA
TAX
PLA
SEC
SBC #$01
BNE FUNC_WAIT
LDA #$00
RTS
ECHO_CR: PHA
LDA #$8D
JSR ECHO
PLA
RTS
SYMBOLS:
.BYTE $A0
.BYTE $AE
.BYTE $BA
.BYTE $AC
.BYTE $BB
.BYTE $A1
.BYTE $AD
.BYTE $DE
.BYTE $AB
.BYTE $BD
.BYTE $BF
.BYTE $A6
.BYTE $AA
.BYTE $A5
.BYTE $A3
.BYTE $C0
INSTRUCTIONS:
.BYTE $FF
.BYTE $1F
.BYTE $1B
.BYTE $17
.BYTE $16
.BYTE $14
.BYTE $13
.BYTE $14
.BYTE $17
.BYTE $1B
.BYTE $1E
.BYTE $FF
.BYTE $CF
.BYTE $1E
.BYTE $2C
.BYTE $18
.BYTE $50
.BYTE $21
.BYTE $12
.BYTE $14
.BYTE $17
.BYTE $1C
.BYTE $FF
.BYTE $8F
.BYTE $1B
.BYTE $16
.BYTE $12
.BYTE $21
.BYTE $70
.BYTE $31
.BYTE $10
.BYTE $11
.BYTE $18
.BYTE $FF
.BYTE $5F
.BYTE $1D
.BYTE $15
.BYTE $50
.BYTE $21
.BYTE $70
.BYTE $41
.BYTE $18
.BYTE $1D
.BYTE $FF
.BYTE $2F
.BYTE $1E
.BYTE $14
.BYTE $F0
.BYTE $30
.BYTE $11
.BYTE $10
.BYTE $12
.BYTE $17
.BYTE $1E
.BYTE $FF
.BYTE $19
.BYTE $E0
.BYTE $11
.BYTE $12
.BYTE $24
.BYTE $12
.BYTE $40
.BYTE $19
.BYTE $FF
.BYTE $14
.BYTE $50
.BYTE $23
.BYTE $11
.BYTE $20
.BYTE $21
.BYTE $20
.BYTE $12
.BYTE $15
.BYTE $18
.BYTE $19
.BYTE $16
.BYTE $12
.BYTE $30
.BYTE $12
.BYTE $19
.BYTE $DF
.BYTE $1C
.BYTE $11
.BYTE $40
.BYTE $12
.BYTE $19
.BYTE $1A
.BYTE $17
.BYTE $25
.BYTE $26
.BYTE $34
.BYTE $17
.BYTE $2A
.BYTE $19
.BYTE $17
.BYTE $13
.BYTE $30
.BYTE $11
.BYTE $1B
.BYTE $CF
.BYTE $18
.BYTE $50
.BYTE $13
.BYTE $2A
.BYTE $19
.BYTE $38
.BYTE $19
.BYTE $18
.BYTE $27
.BYTE $28
.BYTE $27
.BYTE $18
.BYTE $17
.BYTE $12
.BYTE $30
.BYTE $18
.BYTE $CF
.BYTE $1A
.BYTE $50
.BYTE $15
.BYTE $19
.BYTE $17
.BYTE $14
.BYTE $13
.BYTE $22
.BYTE $13
.BYTE $16
.BYTE $17
.BYTE $16
.BYTE $13
.BYTE $21
.BYTE $12
.BYTE $14
.BYTE $17
.BYTE $15
.BYTE $20
.BYTE $13
.BYTE $1D
.BYTE $CF
.BYTE $1C
.BYTE $40
.BYTE $12
.BYTE $28
.BYTE $15
.BYTE $13
.BYTE $11
.BYTE $30
.BYTE $12
.BYTE $28
.BYTE $12
.BYTE $10
.BYTE $11
.BYTE $12
.BYTE $14
.BYTE $17
.BYTE $18
.BYTE $12
.BYTE $10
.BYTE $1A
.BYTE $DF
.BYTE $1D
.BYTE $12
.BYTE $30
.BYTE $14
.BYTE $1A
.BYTE $19
.BYTE $18
.BYTE $17
.BYTE $45
.BYTE $16
.BYTE $1B
.BYTE $1D
.BYTE $18
.BYTE $26
.BYTE $17
.BYTE $18
.BYTE $1A
.BYTE $1B
.BYTE $15
.BYTE $11
.BYTE $1C
.BYTE $EF
.BYTE $18
.BYTE $10
.BYTE $13
.BYTE $12
.BYTE $13
.BYTE $59
.BYTE $18
.BYTE $27
.BYTE $19
.BYTE $1B
.BYTE $2C
.BYTE $1A
.BYTE $27
.BYTE $19
.BYTE $2A
.BYTE $17
.BYTE $12
.BYTE $18
.BYTE $EF
.BYTE $1E
.BYTE $12
.BYTE $23
.BYTE $11
.BYTE $15
.BYTE $16
.BYTE $35
.BYTE $24
.BYTE $35
.BYTE $16
.BYTE $17
.BYTE $16
.BYTE $14
.BYTE $13
.BYTE $14
.BYTE $15
.BYTE $16
.BYTE $15
.BYTE $11
.BYTE $18
.BYTE $FF
.BYTE $17
.BYTE $30
.BYTE $12
.BYTE $24
.BYTE $13
.BYTE $21
.BYTE $23
.BYTE $11
.BYTE $10
.BYTE $21
.BYTE $22
.BYTE $21
.BYTE $13
.BYTE $14
.BYTE $12
.BYTE $13
.BYTE $1D
.BYTE $FF
.BYTE $1D
.BYTE $16
.BYTE $11
.BYTE $10
.BYTE $21
.BYTE $22
.BYTE $11
.BYTE $22
.BYTE $13
.BYTE $24
.BYTE $25
.BYTE $14
.BYTE $23
.BYTE $41
.BYTE $1A
.BYTE $FF
.BYTE $2F
.BYTE $1D
.BYTE $16
.BYTE $15
.BYTE $20
.BYTE $31
.BYTE $13
.BYTE $24
.BYTE $15
.BYTE $16
.BYTE $47
.BYTE $13
.BYTE $11
.BYTE $10
.BYTE $12
.BYTE $19
.BYTE $FF
.BYTE $2F
.BYTE $1D
.BYTE $1A
.BYTE $1C
.BYTE $19
.BYTE $13
.BYTE $11
.BYTE $20
.BYTE $21
.BYTE $13
.BYTE $24
.BYTE $33
.BYTE $24
.BYTE $21
.BYTE $13
.BYTE $1A
.BYTE $EF
.BYTE $2E
.BYTE $1D
.BYTE $1C
.BYTE $1B
.BYTE $1D
.BYTE $1E
.BYTE $1B
.BYTE $16
.BYTE $13
.BYTE $51
.BYTE $12
.BYTE $41
.BYTE $12
.BYTE $21
.BYTE $12
.BYTE $18
.BYTE $1A
.BYTE $1D
.BYTE $AF
.BYTE $1E
.BYTE $1D
.BYTE $3C
.BYTE $2D
.BYTE $4E
.BYTE $1A
.BYTE $14
.BYTE $22
.BYTE $11
.BYTE $20
.BYTE $71
.BYTE $13
.BYTE $15
.BYTE $17
.BYTE $2C
.BYTE $1D
.BYTE $1E
.BYTE $7F
.BYTE $4D
.BYTE $2E
.BYTE $2D
.BYTE $2E
.BYTE $1D
.BYTE $2E
.BYTE $19
.BYTE $23
.BYTE $32
.BYTE $31
.BYTE $22
.BYTE $13
.BYTE $15
.BYTE $16
.BYTE $14
.BYTE $17
.BYTE $2E
.BYTE $3D
.BYTE $2E
.BYTE $4F
.BYTE $2E
.BYTE $7D
.BYTE $2E
.BYTE $1D
.BYTE $2E
.BYTE $1A
.BYTE $14
.BYTE $43
.BYTE $14
.BYTE $13
.BYTE $14
.BYTE $15
.BYTE $16
.BYTE $17
.BYTE $15
.BYTE $14
.BYTE $18
.BYTE $1D
.BYTE $4E
.BYTE $2D
.BYTE $4E
.BYTE $9D
.BYTE $4E
.BYTE $1C
.BYTE $1A
.BYTE $18
.BYTE $15
.BYTE $14
.BYTE $43
.BYTE $15
.BYTE $26
.BYTE $15
.BYTE $13
.BYTE $16
.BYTE $1A
.BYTE $3E
.BYTE $8D
.BYTE $00
.BYTE $04
.BYTE $57
.BYTE $4F
.BYTE $5A
.BYTE $20
.BYTE $00
.byte "Woz face program end", $0d, $00

View File

@ -0,0 +1,14 @@
;printing 'Hello, World!'
;More about 'Hello, World!' program: https://en.wikipedia.org/wiki/%22Hello,_World!%22_program
LDX #00
PRINT_CHAR:
LDA HelloWorldText, X
BEQ END_PRINT ;end printing at the end of the string (\n=0)
JSR ECHO
INX
JMP PRINT_CHAR
END_PRINT:
JMP RESET ;return to Woz Monitor
HelloWorldText:
.byte $0d, "Hello, World!", $0d, "This is SmartyKit 1.", $0d, $0d, $00

View File

@ -0,0 +1,4 @@
FD00: A2 00 BD 11 FD F0 07 20
FD08: EF FF E8 4C 02 FD 4C 00
FD10: FF 48 65 6C 6C 6F 20 57
FD18: 6F 72 6C 64 21 0D 00

15
ROM development/Makefile Normal file
View File

@ -0,0 +1,15 @@
all: welcome compile
welcome:
@echo "SmartyKit 1: 6502 assembler & C-compiler to ROM (.bin)"
compile:
@echo "Assembling and linking..."
ca65 -l ROM_listing.asm SmartyKit1_ROM.asm
ld65 -m ROM.map -o SmartyKit1_ROM.bin SmartyKit1_ROM.o -C apple1.cfg
ld65 -o SmartyKit1_ROM_symon.bin SmartyKit1_ROM.o -C symon.cfg
clean:
@echo "Cleaning up..."
rm SmartyKit1_ROM.o

228
ROM development/POST.asm Normal file
View File

@ -0,0 +1,228 @@
;KBD = $D010
;KBDCR = $D011
;DSP = $D012
;DSPCR = $D013
START_TEST = $EA
END_TEST = $EB
LED_BLINKS = 5
TEST1_REPEATS = 4
TEST2_REPEATS = 16
TEST61_REPEATS = 8
TEST62_REPEATS = 8
TEST7_REPEATS = 16
POSTOK_REPEATS = 4
/*
LED_BLINKS = 1
TEST1_REPEATS = 1
TEST2_REPEATS = 1
TEST61_REPEATS = 1
TEST62_REPEATS = 1
TEST7_REPEATS = 1
POSTOK_REPEATS = 1
*/
POST_START: NOP
LDA #START_TEST
STA DSP
LDA #%00000001
JSR BLINK
;Test 1. Memory addresses decoder (blinking in cycle)
MEM_DECODER: LDX #TEST1_REPEATS
LOOPADDR: LDA $FF00
LDA $E000
LDA $D000
LDA $C000
DEX
BNE LOOPADDR
LDA #%00000010
JSR BLINK
;Test 2. Ports decoder (blinking in cycle)
LDA #TEST2_REPEATS
PORTS_DECODER: TAX
LDY KBD
LDY KBDCR
STX DSP
BIT DSP
DEX
TXA
BNE PORTS_DECODER
LDA #%00000100
JSR BLINK
;Test 3. Testing writing to Video port (1->2->4->8->16->32->64->128->256->0)
LDA #%00000001
VIDEO_PORT: STA DSP
ASL A ;shifting 1 to the left
BNE VIDEO_PORT
LDA #%00001000
JSR BLINK
;Test 4. Testing writing to Video port via function call (256->128->64->32->16->8->4->2->1->0)
JSR VIDEO_PORT2
LDA #%00010000
JSR BLINK
;Test 5. Testing RAM with write&read (writing TEST_SYMBOL and testing read for every 4Kb block in 32Kb RAM)
;Total blocks tested is 8 (4*8 = 32)
TEST_SYMBOL = $3E
/*
RAMTEST: CLD
LDX #$00
LDY #$00
LDA #$FF
STA $00
LDA #$0F
STA $01
RAMLOOP: LDA #TEST_SYMBOL
STA ($00),Y
LDA ($00),Y
CMP #TEST_SYMBOL
BNE ENDTEST
TXA
ASL A
ADC #$01
STA DSP
TAX
LDA $01
ADC #$10
STA $01
JMP RAMLOOP
*/
LDA #%00100000
JSR BLINK
;Test 6. Testing BIT7 ports - keyboard and video
BIT7MASK = %10000000
KBD7MASK = %00000111
DSP7MASK = %00111111
;Test 6.1. Testing keyboard BIT7 port read (turn on 3 LEDs on the left and show BIT7 in the last LED)
KBDBIT7: LDX #TEST61_REPEATS
LDA #KBD7MASK
STA DSP
KBD7LOOP:
LDA KBDCR
AND #BIT7MASK
ORA #KBD7MASK
STA DSP
DEX
BNE KBD7LOOP
;Test 6.2. Testing video BIT7 port read (turn on 6 LEDs on the left and show BIT7 in the last LED)
DSPBIT7: LDX #TEST62_REPEATS
LDA #DSP7MASK
STA DSP
DSP7LOOP:
LDA DSP
AND #BIT7MASK
ORA #DSP7MASK
STA DSP
DEX
BNE DSP7LOOP
LDA #%01000000
JSR BLINK
;Test 7. Testing keyboard port read and write to Video port
KBDTODSP: LDX #TEST7_REPEATS
LDA #$00
STA DSP
KBDDSPLOOP:
LDA KBD
STA DSP
DEX
BNE KBDDSPLOOP
;POST success and end
ENDPOST: LDX #POSTOK_REPEATS
ENDLOOP:
LDA #%01010101
STA DSP
NOP
NOP
LDA #%10101010
STA DSP
NOP
NOP
DEX
BNE ENDLOOP
NOP
NOP
;printing ASCII table
JSR ASCII_ECHO
ENDTEST: NOP
NOP
LDA #END_TEST
JSR ECHO ;writing END_TEST to let video driver know that tests are over
LDX #$00
PRINT_MSG:
LDA POSTCompletedText, X
BEQ TO_WOZ_MON ;end printing at the end of the string (\n=0)
JSR ECHO
INX
JMP PRINT_MSG
TO_WOZ_MON: JMP RESET ;start Woz Monitor (operating system)
;------------------------------------------------------
; POST subroutines
;------------------------------------------------------
;blinking LEDs in Video port
VIDEO_PORT2: LDA #%10000000
TEST2: STA DSP
LSR A
BNE TEST2
RTS
;blink with a LED in a position from A register
TURN_OFF = %00000000
BLINK: LDX #LED_BLINKS
TAY ;save A
NEXT_BLINK: TYA ;restore A
STA DSP
NOP
NOP
LDA #TURN_OFF
STA DSP
NOP
NOP
DEX
BNE NEXT_BLINK
RTS
;printing visible symbols of ACSII table via ECHO function from Woz Monitor
PRINT_ASCII:
LDY #32
LDX #95 ;80 in hex = 127 in decimal
ASCII_ECHO:
BIT DSP
BMI ASCII_ECHO
STY DSP
INY
DEX
BNE ASCII_ECHO
RTS
CHAR_ECHO: BIT DSP
BMI CHAR_ECHO
STA DSP
RTS
POSTCompletedText:
.byte $0d, $0d, "POST ok (v.1.0). SmartyKit 1 is ready.", $0d, $0d, $00

46
ROM development/ROM.map Normal file
View File

@ -0,0 +1,46 @@
Modules list:
-------------
SmartyKit1_ROM.o:
CODE Offs=000000 Size=000005 Align=00001 Fill=0000
PICTURE Offs=000000 Size=00001A Align=00001 Fill=0000
C000 Offs=000000 Size=000001 Align=00001 Fill=0000
E000 Offs=000000 Size=000007 Align=00001 Fill=0000
F000 Offs=000000 Size=00024A Align=00001 Fill=0000
F800 Offs=000000 Size=00000B Align=00001 Fill=0000
FA00 Offs=000000 Size=000122 Align=00001 Fill=0000
FC00 Offs=000000 Size=0000B2 Align=00001 Fill=0000
FD00 Offs=000000 Size=000037 Align=00001 Fill=0000
FF00 Offs=000000 Size=0000FA Align=00001 Fill=0000
VECTORS Offs=000000 Size=000006 Align=00001 Fill=0000
Segment list:
-------------
Name Start End Size Align
----------------------------------------------------
PICTURE 000088 0000A1 00001A 00001
CODE 008000 008004 000005 00001
C000 00C000 00C000 000001 00001
E000 00E000 00E006 000007 00001
F000 00F000 00F249 00024A 00001
F800 00F800 00F80A 00000B 00001
FA00 00FA00 00FB21 000122 00001
FC00 00FC00 00FCB1 0000B2 00001
FD00 00FD00 00FD36 000037 00001
FF00 00FF00 00FFF9 0000FA 00001
VECTORS 00FFFA 00FFFF 000006 00001
Exports list by name:
---------------------
Exports list by value:
----------------------
Imports list:
-------------

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
.setcpu "6502"
.feature c_comments
.segment "PICTURE"
.byte %00000000
.byte %01100110
.byte %11111111
.byte %11111111
.byte %11111111
.byte %01111110
.byte %00111100
.byte %00011000
.byte 00
.byte 00
Smiley: .byte $3c, $42, $a5, $81, $a5, $99, $42, $3c
Woz: .byte $88, $a8, $50, $07, $61, $92, $94, $67
; .byte "8*8 Pixel Art picture end", $0d, $00
.code
loop: lda #$12
jmp loop
.segment "C000"
nop
.segment "E000"
JSR COPY_HEART
JMP $FC00
nop
.segment "F000"
;Woz face
.include "Apple30th_Woz.asm"
.segment "F800"
;Test from Apple-1 Operation Manual printing all ASCII symbols in a loop
.include "TestFromManual.asm"
.segment "FA00"
;Power-On Self Test (POST)
.include "POST.asm"
.segment "FC00"
;printing 8x8 picture in the center with '*'
.include "8x8art.asm"
.segment "FD00"
;Printing 'Hello, World!'
.include "HelloWorld.asm"
.segment "FF00"
.include "Woz_Monitor.asm"
.segment "VECTORS"
; Interrupt Vectors
.WORD NMI ; NMI
.WORD POST_START ; RESET (starting point in Woz Monitor) or POST (test)
.WORD IRQ ; BRK/IRQ

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,7 @@
;Test from Apple-1 Operation Manual printing all ASCII symbols in a loop
LDA #$00
TEST_LOOP: TAX
JSR ECHO
INX
TXA
JMP TEST_LOOP

View File

@ -0,0 +1,154 @@
; The WOZ Monitor for the Apple 1
; Written by Steve Wozniak in 1976
; Page 0 Variables
XAML = $24 ; Last "opened" location Low
XAMH = $25 ; Last "opened" location High
STL = $26 ; Store address Low
STH = $27 ; Store address High
L = $28 ; Hex value parsing Low
H = $29 ; Hex value parsing High
YSAV = $2A ; Used to see if hex value is given
MODE = $2B ; $00=XAM, $7F=STOR, $AE=BLOCK XAM
; Other Variables
IN = $0200 ; Input buffer to $027F
KBD = $D010 ; PIA.A keyboard input
KBDCR = $D011 ; PIA.A keyboard control register
DSP = $D012 ; PIA.B display output register
DSPCR = $D013 ; PIA.B display control register
.org $FF00
.export RESET
RESET: CLD ; Clear decimal arithmetic mode.
CLI
LDY #$7F ; Mask for DSP data direction register.
STY DSP ; Set it up.
LDA #$A7 ; KBD and DSP control register mask.
STA KBDCR ; Enable interrupts, set CA1, CB1, for
STA DSPCR ; positive edge sense/output mode.
NOTCR: CMP #'_'+$80 ; "_"?
BEQ BACKSPACE ; Yes.
CMP #$9B ; ESC?
BEQ ESCAPE ; Yes.
INY ; Advance text index.
BPL NEXTCHAR ; Auto ESC if > 127.
ESCAPE: LDA #'\'+$80 ; "\".
JSR ECHO ; Output it.
GETLINE: LDA #$8D ; CR.
JSR ECHO ; Output it.
LDY #$01 ; Initialize text index.
BACKSPACE: DEY ; Back up text index.
BMI GETLINE ; Beyond start of line, reinitialize.
NEXTCHAR: LDA KBDCR ; Key ready?
BPL NEXTCHAR ; Loop until ready.
LDA KBD ; Load character. B7 should be 1.
STA IN,Y ; Add to text buffer.
JSR ECHO ; Display character.
CMP #$8D ; CR?
BNE NOTCR ; No.
LDY #$FF ; Reset text index.
LDA #$00 ; For XAM mode.
TAX ; 0->X.
SETSTOR: ASL ; Leaves $7B if setting STOR mode.
SETMODE: STA MODE ; $00=XAM $7B=STOR $AE=BLOK XAM
BLSKIP: INY ; Advance text index.
NEXTITEM: LDA IN,Y ; Get character.
CMP #$8D ; CR?
BEQ GETLINE ; Yes, done this line.
CMP #'.'+$80 ; "."?
BCC BLSKIP ; Skip delimiter.
BEQ SETMODE ; Yes. Set STOR mode.
CMP #':'+$80 ; ":"?
BEQ SETSTOR ; Yes. Set STOR mode.
CMP #'R'+$80 ; "R"?
BEQ RUN ; Yes. Run user program.
STX L ; $00-> L.
STX H ; and H.
STY YSAV ; Save Y for comparison.
NEXTHEX: LDA IN,Y ; Get character for hex test.
EOR #$B0 ; Map digits to $0-9.
CMP #$0A ; Digit?
BCC DIG ; Yes.
ADC #$88 ; Map letter "A"-"F" to $FA-FF.
CMP #$FA ; Hex letter?
BCC NOTHEX ; No, character not hex.
DIG: ASL
ASL ; Hex digit to MSD of A.
ASL
ASL
LDX #$04 ; Shift count.
HEXSHIFT: ASL ; Hex digit left, MSB to carry.
ROL L ; Rotate into LSD.
ROL H ; Rotate into MSDs.
DEX ; Done 4 shifts?
BNE HEXSHIFT ; No, loop.
INY ; Advance text index.
BNE NEXTHEX ; Always taken. Check next char for hex.
NOTHEX: CPY YSAV ; Check if L, H empty (no hex digits).
BEQ ESCAPE ; Yes, generate ESC sequence.
BIT MODE ; Test MODE byte.
BVC NOTSTOR ; B6=0 STOR 1 for XAM & BLOCK XAM
LDA L ; LSDs of hex data.
STA (STL,X) ; Store at current store index.
INC STL ; Increment store index.
BNE NEXTITEM ; Get next item. (no carry).
INC STH ; Add carry to store index high order.
TONEXTITEM: JMP NEXTITEM ; Get next command item.
RUN: JMP (XAML) ; Run at current XAM index.
NOTSTOR: BMI XAMNEXT ; B7=0 for XAM, 1 for BLOCK XAM.
LDX #$02 ; Byte count.
SETADR: LDA L-1,X ; Copy hex data to
STA STL-1,X ; store index.
STA XAML-1,X ; And to XAM index.
DEX ; Next of 2 bytes.
BNE SETADR ; Loop unless X=0.
NXTPRNT: BNE PRDATA ; NE means no address to print.
LDA #$8D ; CR.
JSR ECHO ; Output it.
LDA XAMH ; Examine index high-order byte.
JSR PRBYTE ; Output it in hex format.
LDA XAML ; Low-order examine index byte.
JSR PRBYTE ; Output it in hex format.
LDA #':'+$80 ; ":".
JSR ECHO ; Output it.
PRDATA: LDA #$A0 ; Blank.
JSR ECHO ; Output it.
LDA (XAML,X) ; Get data byte at examine index.
JSR PRBYTE ; Output it in hex format.
XAMNEXT: STX MODE ; 0->MODE (XAM mode).
LDA XAML
CMP L ; Compare examine index to hex data.
LDA XAMH
SBC H
BCS TONEXTITEM ; Not less, so no more data to output.
INC XAML
BNE MOD8CHK ; Increment examine index.
INC XAMH
MOD8CHK: LDA XAML ; Check low-order examine index byte
AND #$07 ; For MOD 8=0
BPL NXTPRNT ; Always taken.
PRBYTE: PHA ; Save A for LSD.
LSR
LSR
LSR ; MSD to LSD position.
LSR
JSR PRHEX ; Output hex digit.
PLA ; Restore A.
PRHEX: AND #$0F ; Mask LSD for hex print.
ORA #'0'+$80 ; Add "0".
CMP #$BA ; Digit?
BCC ECHO ; Yes, output it.
ADC #$06 ; Add offset for letter.
ECHO: BIT DSP ; bit (B7) cleared yet?
BMI ECHO ; No, wait for display.
STA DSP ; Output character. Sets DA.
RTS ; Return.
NMI: RTI ; simple Interrupt Service Routine(ISR)
IRQ: RTI ; simple Interrupt Service Routine(ISR)

View File

@ -0,0 +1,20 @@
MEMORY
{
RAM: start=$0000, size=$8000, type=rw, define=yes, fill=yes;
ROM: start=$8000, size=$8000, type=ro, define=yes, fill=yes, file=%O;
}
SEGMENTS
{
PICTURE: load=RAM, type=rw, offset=$0088;
CODE: load=ROM, type=ro;
C000: load=ROM, type=ro, offset=$4000;
E000: load=ROM, type=ro, offset=$6000;
F000: load=ROM, type=ro, offset=$7000;
F800: load=ROM, type=ro, offset=$7800;
FA00: load=ROM, type=ro, offset=$7a00;
FC00: load=ROM, type=ro, offset=$7c00;
FD00: load=ROM, type=ro, offset=$7d00;
FF00: load=ROM, type=ro, offset=$7f00;
VECTORS: load=ROM, type=ro, offset=$7ffa;
}

19
ROM development/symon.cfg Normal file
View File

@ -0,0 +1,19 @@
MEMORY
{
ROM: start=$E000, size=$2000, type=ro, define=yes, fill=yes, file=%O;
}
SEGMENTS
{
CODE: load=ROM, type=ro;
PICTURE: load=ROM, type=ro;
C000: load=ROM, type=ro;
E000: load=ROM, type=ro;
F000: load=ROM, type=ro, offset=$1000;
F800: load=ROM, type=ro, offset=$1800;
FA00: load=ROM, type=ro, offset=$1a00;
FC00: load=ROM, type=ro, offset=$1c00;
FD00: load=ROM, type=ro, offset=$1d00;
FF00: load=ROM, type=ro, offset=$1f00;
VECTORS: load=ROM, type=ro, offset=$1ffa;
}

Binary file not shown.