A2osX/SYS/KERNEL.S.INIT2.txt

358 lines
6.9 KiB
Plaintext
Raw Normal View History

2016-08-28 20:48:01 +00:00
PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
2016-08-28 20:48:01 +00:00
INC 1
AUTO 6
*--------------------------------------
2016-09-29 15:30:15 +00:00
Kernel.Init2 sei
>LDAXI MSG.Init2
jsr PrintFAX
2016-08-28 20:48:01 +00:00
>LDYAI A2osX.GP
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
>LDYAI A2osX.SYSCALL
2017-01-12 17:43:45 +00:00
>STYA ZPPtr2
>LDYAI A2osX.GP.S^$FFFF
2017-01-12 17:43:45 +00:00
>STYA ZPPtr3
2016-08-28 20:48:01 +00:00
jsr Kernel.Move
2016-09-29 15:30:15 +00:00
sta CLRALTZP
>LDAXI MSG.D2
jsr PrintFAX
2016-09-29 15:30:15 +00:00
sta SETALTZP
2016-08-28 20:48:01 +00:00
lda RRAMWRAMBNK2
lda RRAMWRAMBNK2
>LDYAI A2osX.D2
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
2016-08-28 20:48:01 +00:00
>LDYAI $D000
2017-01-12 17:43:45 +00:00
>STYA ZPPtr2
>LDYAI A2osX.D2.S^$FFFF
2017-01-12 17:43:45 +00:00
>STYA ZPPtr3
2016-08-28 20:48:01 +00:00
jsr Kernel.Move
2016-09-29 15:30:15 +00:00
sta CLRALTZP
>LDAXI MSG.D1
jsr PrintFAX
2016-09-29 15:30:15 +00:00
sta SETALTZP
2016-08-28 20:48:01 +00:00
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
>LDYAI A2osX.D1
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
2016-08-28 20:48:01 +00:00
>LDYAI $D000
2017-01-12 17:43:45 +00:00
>STYA ZPPtr2
>LDYAI A2osX.D1.S^$FFFF
2017-01-12 17:43:45 +00:00
>STYA ZPPtr3
2016-08-28 20:48:01 +00:00
jsr Kernel.Move
2016-09-29 15:30:15 +00:00
sta CLRALTZP
>LDAXI MSG.E0
jsr PrintFAX
2016-09-29 15:30:15 +00:00
sta SETALTZP
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
>LDYAI A2osX.E0
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
2016-08-28 20:48:01 +00:00
>LDYAI $E000
2017-01-12 17:43:45 +00:00
>STYA ZPPtr2
>LDYAI A2osX.E0.S^$FFFF
2017-01-12 17:43:45 +00:00
>STYA ZPPtr3
2016-08-28 20:48:01 +00:00
jsr Kernel.Move
>LDYAI D.STACK.TOP
>STYA pStack init Soft Stack
sta CLRALTZP Make MAIN ZP is enabled for X.PRINT.F
cli
jsr KConfigLoad
lda A2osX.HZ
2016-08-28 20:48:01 +00:00
pha push HZ
>LDAXI MSG.HZ
jsr PrintFAX
2016-08-28 20:48:01 +00:00
jsr CPU.Init
>LDAXI MSG.Init2.OK
jsr PrintFAX
2016-09-29 15:30:15 +00:00
rts Do NOT replace this JSR/RTS with a JMP
2016-08-28 20:48:01 +00:00
*--------------------------------------
Kernel.Move ldy #0
.1 inc ZPPtr3
bne .2
inc ZPPtr3+1
beq .9
.2 lda (ZPPtr1),y
sta (ZPPtr2),y
iny
bne .1
inc ZPPtr1+1
inc ZPPtr2+1
bne .1
.9 rts
*--------------------------------------
2016-08-28 20:48:01 +00:00
CPU.Init >LDAXI MSG.CPU
jsr PrintFAX
2016-08-28 20:48:01 +00:00
jsr Detect6502 A = CPU type
sta A2osX.CPUTYPE
ldx MSG.CPUTYPEH,y
2016-08-28 20:48:01 +00:00
lda MSG.CPUTYPEL,y
jsr PrintFAX
2016-08-28 20:48:01 +00:00
lda MACHID
2016-08-28 20:48:01 +00:00
and #MACHID.TYPE
cmp #MACHID.TYPE.IIc
beq CPU.Init.Z80
>LDAXI MSG.CPU.SPEED
jsr PrintFAX
2016-08-28 20:48:01 +00:00
stz A2osX.RANDOM16
stz A2osX.RANDOM16+1
php
sei
.1 bit VBL
bpl .2
.2 bit VBL
bmi .2
ldx #0 Count LO
lda #0 Count HI
.3 ldy #3 (2)
.4 nop (2)
dey (2)
bne .4 (2*)
inc A2osX.RANDOM16 (6)
bne .5 (2*)
inc A2osX.RANDOM16+1 (6)
bit VBL (4)
bpl .3 (2*)
bmi .6
.5 nop (2)
nop (2)
nop (2)
bit VBL (4)
bpl .3 (2*)
.6 plp
stz A2osX.CPUSPEED
.7 sec
lda A2osX.RANDOM16
sbc #100
tax
lda A2osX.RANDOM16+1
sbc /100
bcc .8
stx A2osX.RANDOM16
sta A2osX.RANDOM16+1
inc A2osX.CPUSPEED
bra .7
.8 lda A2osX.RANDOM16
sta A2osX.CPUSPEED+1
pha push CPU speed LO
lda A2osX.CPUSPEED
pha push CPU speed HI
>LDAXI MSG.CPU.SPEEDOK
jsr PrintFAX
2016-08-28 20:48:01 +00:00
CPU.Init.Z80 >LDAXI MSG.Z80
jsr PrintFAX
2016-08-28 20:48:01 +00:00
jsr DetectZ80
bcs .9
sta A2osX.Z80SLOT
pha Push Z80Slot
tax
lda #A2osX.SLOTS.Z80
sta A2osX.SLOTS,x
2016-08-28 20:48:01 +00:00
>LDAXI MSG.Z80.OK
jsr PrintFAX
2016-08-28 20:48:01 +00:00
rts
.9 >LDAXI MSG.Z80.KO
jsr PrintFAX
2016-08-28 20:48:01 +00:00
rts
*--------------------------------------
* Out:
* A = $60, 6502
* A = $61, 65C02
* A = $62, 65R02
* A = $63, 65816
2016-08-28 20:48:01 +00:00
*--------------------------------------
Detect6502 ldy #0 Test 6502 BCD bug
sed
lda #$99
clc
adc #$01
cld
bmi .9 BUG!, we have 6502
ldy #3 test 65C816 TYX Instruction
ldx #0
.OP 65816
tyx TYX: if 65C816, x becomes non-zero
.OP 65C02
bne .9 worked! 65C816
dey y=2 -> R65C02
ldx $EA save zp $EA
stz $EA store 0 in $EA
* .OP 65R02
.HS F7EA For compatibility with A2osX.ASM
* smb 7,$EA if not Rockwell, assemble as nop nop
* .OP 65C02
asl $EA cs if Rockwell
stx $EA restore zp $EA
bcs .9
dey y=1 -> 65C02
.9 tya
ora #$60
rts
*--------------------------------------
* Out:
* A = Z80 Slot
*--------------------------------------
DetectZ80 ldx #Z80Code.Size
.1 lda Z80Code.Start-1,x
sta $1000-1,x 00000H for Z80
dex
bne .1
2017-01-12 17:43:45 +00:00
stz ZPPtr1
2016-08-28 20:48:01 +00:00
lda #$C1
2017-01-12 17:43:45 +00:00
sta ZPPtr1+1
2016-08-28 20:48:01 +00:00
2017-01-12 17:43:45 +00:00
.2 sta (ZPPtr1)
2016-08-28 20:48:01 +00:00
lda $100D
bmi .8
2017-01-12 17:43:45 +00:00
inc ZPPtr1+1
lda ZPPtr1+1
2016-08-28 20:48:01 +00:00
cmp #$C8
beq .9 CS
clc
adc #$20
sta $100A
bra .2
2017-01-12 17:43:45 +00:00
.8 lda ZPPtr1+1
2016-08-28 20:48:01 +00:00
and #$0F
clc
.9 rts
*--------------------------------------
KConfigLoad >LDAXI MSG.KCREAD
jsr PrintFAX
jsr MLI
.DA #MLIOPEN
.DA MLIOPEN00
bcs .9
lda MLIOPEN00+5
sta MLIREAD00+1
sta MLICLOSE00+1
jsr MLI
.DA #MLIREAD
.DA MLIREAD00
php
pha
jsr MLI
.DA #MLICLOSE
.DA MLICLOSE00
pla
plp
bcs .9
>LDAXI MSG.KCREAD.OK
jsr PrintFAX
rts
.9 >LDAXI MSG.KCREAD.KO
jsr PrintFAX
rts
*--------------------------------------
2016-08-28 20:48:01 +00:00
Z80Code.Start .HS 31FFFF START: LD SP,0FFFFH Init Stack
.HS 3EFF LD A,0FFH Set Flag
.HS 320D00 LD (FLAG),A
.HS 3200E1 LD (0E100H),A Back to 6502
.HS 18F3 JR START Loop
.HS 00 FLAG: .DB 0
Z80Code.Size .EQ *-Z80Code.Start
2016-08-28 20:48:01 +00:00
*--------------------------------------
MSG.Init2 >CSTR "A2osX[Stage2]:Init\nInstalling KERNEL...\n - $BE00 Global Page...\n"
MSG.D1 >CSTR " - $D000 Bank1...\n"
MSG.D2 >CSTR " - $D000 Bank2...\n"
MSG.E0 >CSTR " - $E000...\n"
MSG.HZ >CSTR "Kernel SYS Timer Set For %d0 hz Machine.\n"
MSG.Init2.OK >CSTR "A2osX[Stage2]:Complete.\n"
*--------------------------------------
MSG.CPU >CSTR "Checking CPU..."
MSG.CPU.SPEED >CSTR "Detecting CPU Speed..."
2016-08-28 20:48:01 +00:00
MSG.CPUTYPEL .DA #MSG.6502
.DA #MSG.65C02
.DA #MSG.65R02
.DA #MSG.65816
MSG.CPUTYPEH .DA /MSG.6502
.DA /MSG.65C02
.DA /MSG.65R02
.DA /MSG.65816
MSG.6502 >CSTR "6502.\n"
MSG.65C02 >CSTR "65C02.\n"
MSG.65R02 >CSTR "65R02.\n"
MSG.65816 >CSTR "65816.\n"
MSG.CPU.SPEEDOK >CSTR "%d.%02d Mhz.\n"
MSG.Z80 >CSTR "Detecting Z80 CPU..."
MSG.Z80.OK >CSTR "Detected In Slot %d.\n"
MSG.Z80.KO >CSTR "Not Detected.\n"
MSG.KCREAD >CSTR "Reading Kernel Config File..."
MSG.KCREAD.OK >CSTR "OK\n"
MSG.KCREAD.KO >CSTR "\nError While Reading Kernel Config File, Using Default.\n"
A2OSXCONF >PSTR "A2osX.KCONFIG"
*--------------------------------------
MLIOPEN00 .DA #3
.DA A2OSXCONF
.DA $1000
.BS 1
*--------------------------------------
MLIREAD00 .DA #4
.BS 1
.DA A2osX.HZ
.DA 16
.BS 2
*--------------------------------------
MLICLOSE00 .DA #1
.BS 1
*--------------------------------------
2016-08-28 20:48:01 +00:00
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.INIT2
LOAD /A2OSX.SRC/SYS/KERNEL.S
2016-08-28 20:48:01 +00:00
ASM