Finally Works, fix the Bug.

It's due to not reset the Unidisk PC value to 00 05 from 3C 05, after
execution second time read operation.
This commit is contained in:
rigreco 2015-03-01 11:19:59 +01:00
parent 71231e1917
commit 239000d726
4 changed files with 112 additions and 58 deletions

37
AppleII/Chksum.asm Normal file
View File

@ -0,0 +1,37 @@
* @com.wudsn.ide.asm.hardware=APPLE2
COut equ $FDED
PTR equ $EB
STARTCHK lda #<STARTCHK
sta PTR
lda #>STARTCHK
sta PTR+1
ldy #$00
lda #$00
pha
LOOP pla
eor (PTR),y
pha
inc PTR
bne CHK
inc PTR+1
CHK lda PTR+1
cmp #>PROGEND
bcc LOOP
lda PTR
cmp #<PROGEND
bcc LOOP
beq LOOP
CHKCS pla
cmp CHKSUM
bne ERROR
REALSTART lda #0
inc A
sta $FA
PROGEND rts
CHKSUM chk
ERROR sta CHKCALC
lda #"E"
jsr COut
rts
CHKCALC dfb $00

View File

@ -22,7 +22,7 @@ FP2 equ $EC
** Applesoft FP Accumulator 5 Byte + 1 Byte Sign ** ** Applesoft FP Accumulator 5 Byte + 1 Byte Sign **
FAC equ $9D FAC equ $9D
** Variabile Memory location $0380 ** RSLT equ $7000
*************************** ***************************
@ -88,16 +88,16 @@ CONT lda FAC+2
* *
** FP1 to FAC conversion ** ** FP1 to FAC conversion **
* *
ENTRY2 lda FP1 ; X1 1 Byte --> 9D FAC ENTRY2 lda RSLT ; X1 1 Byte --> 9D FAC
inc A ; 2^(FP1+1) inc EXP inc A ; 2^(FP1+1) inc EXP
sta FAC sta FAC
lda FP1+1 lda RSLT+1
bmi NEG2 ; chk the Hi bit of 1 byte Mantissa bmi NEG2 ; chk the Hi bit of 1 byte Mantissa
POS2 clc POS2 clc
lda FP1+1 ; M1 Hi 2 Byte --> 9E FAC lda RSLT+1 ; M1 Hi 2 Byte --> 9E FAC
rol ; Multiply for 2^1 rol ; Multiply for 2^1
ora #$80 ; Set Hi Bit 1 byte Mantissa (change Sign only if is positive) ora #$80 ; Set Hi Bit 1 byte Mantissa (change Sign only if is positive)
@ -106,7 +106,7 @@ POS2 clc
;sta FAC+5 ; To 1^ Byte Mantissa of FAC UnPacked ;sta FAC+5 ; To 1^ Byte Mantissa of FAC UnPacked
jmp CONT2 jmp CONT2
NEG2 lda FP1+1 NEG2 lda RSLT+1
sec sec
sbc #01 ; One's complement inv -1 sbc #01 ; One's complement inv -1
@ -118,11 +118,11 @@ NEG2 lda FP1+1
sta FAC+5 ; To 6^ Byte of FAC Unpacked sta FAC+5 ; To 6^ Byte of FAC Unpacked
CONT2 lda FP1+2 ; M1 3 Byte --> 9F FAC CONT2 lda RSLT+2 ; M1 3 Byte --> 9F FAC
rol rol
sta FAC+2 sta FAC+2
lda FP1+3 ; M1 Lo 4 Byte --> A0 FAC lda RSLT+3 ; M1 Lo 4 Byte --> A0 FAC
rol rol
sta FAC+3 sta FAC+3
@ -132,9 +132,6 @@ CONT2 lda FP1+2 ; M1 3 Byte --> 9F FAC
;brk ;brk
*************************** ***************************
*
;ldy #$03 ;Hi Byte MEM
;lda #$80 ;Lo Byte MEM
* *
jsr CHKCOM jsr CHKCOM
jsr PTRGET ; Return the Y and A pointing to the specific variabile jsr PTRGET ; Return the Y and A pointing to the specific variabile
@ -142,4 +139,5 @@ CONT2 lda FP1+2 ; M1 3 Byte --> 9F FAC
jsr MOVMF ;FAC->VARIABLE Y (5 Bytes Packed) jsr MOVMF ;FAC->VARIABLE Y (5 Bytes Packed)
;brk ;brk
rts rts
chk

View File

@ -28,7 +28,7 @@ ZPTempH equ $0007
** Zero page storage ** ** Zero page storage **
N1 equ $FA ;25 4 Byte FP FA--FD (FP1) N1 equ $FA ;25 4 Byte FP FA--FD (FP1)
N2 equ $EC ;27 4 Byte FP EC--EF (FP2) N2 equ $EC ;27 4 Byte FP EC--EF (FP2)
; RSLT equ $1D ;29 RSLT equ $7000 ;29
*** Monitor routines *** *** Monitor routines ***
COut equ $FDED ;Console output ASCII COut equ $FDED ;Console output ASCII
CROut equ $FD8E ;Carriage return CROut equ $FD8E ;Carriage return
@ -87,31 +87,32 @@ Message asc 'NO PC OR NO DEVICE'
** Set the Input Value first in Dynamic data ** ** Set the Input Value first in Dynamic data **
** 4 Byte N1 to FP1 ** ** 4 Byte N1 to FP1 **
EXEC lda N1 ;X1 EXEC lda N1 ;X1
sta $622F ; Absolute addressing sta $6238 ; Absolute addressing
lda N1+1 ;M1 (1) lda N1+1 ;M1 (1)
sta $6230 sta $6239
lda N1+2 ;M1 (2) lda N1+2 ;M1 (2)
sta $6231 sta $623A
lda N1+3 ;M1 (3) lda N1+3 ;M1 (3)
sta $6232 sta $623B
** 4 Byte N2 to FP2 ** ** 4 Byte N2 to FP2 **
lda N2 ;X2 lda N2 ;X2
sta $6233 sta $623C
lda N2+1 ;M2 (1) lda N2+1 ;M2 (1)
sta $6234 sta $623D
lda N2+2 ;M2 (2) lda N2+2 ;M2 (2)
sta $6235 sta $623E
lda N2+3 ;M2 (3) lda N2+3 ;M2 (3)
sta $6236 sta $623F
*** Download *** *** Download ***
jsr Dispatch jsr Dispatch
dfb ControlCmd dfb ControlCmd
dw DOWNLOAD dw DOWNLOAD
** Set Unidisk Registers ** ** Set Unidisk Registers **
* lda #01 ;First time * ;First time execution
* sta UNIAcc_reg lda #$00 ; Target the first time entry point
sta LowPC_reg ; First time set init value of PC, just for the next execution
* The program begin to PC preset to $0500 * * The program begin to PC preset to $0500 *
* *
** Execute ** ** Execute **
@ -128,11 +129,11 @@ READ jsr Dispatch
* First time execute * * First time execute *
lda UNIAcc_reg lda UNIAcc_reg
sta N1 sta RSLT
lda UNIX_reg lda UNIX_reg
sta N1+1 ; Store the result sta RSLT+1 ; Store the result
lda UNIY_reg lda UNIY_reg
sta N1+2 sta RSLT+2
** Second time execute ** ** Second time execute **
lda #$3C ; Target the secont time entry point lda #$3C ; Target the secont time entry point
@ -149,7 +150,7 @@ READ jsr Dispatch
* Second time execute only to read the latest Byte of FP1* * Second time execute only to read the latest Byte of FP1*
lda UNIAcc_reg lda UNIAcc_reg
sta N1+3 sta RSLT+3
* *
rts rts

View File

@ -20,42 +20,61 @@
* *
* *
* @com.wudsn.ide.asm.hardware=APPLE2 * @com.wudsn.ide.asm.hardware=APPLE2
*
* Protocol Converter Call
XC XC
** CHKSUM Pointer *
PTR equ $08
** Protocol Converter Call
ZPTempL equ $0006 ;Temporary zero page storage ZPTempL equ $0006 ;Temporary zero page storage
ZPTempH equ $0007 ZPTempH equ $0007
** Zero page storage ** ** Zero page storage **
N1 equ $FA ;25 4 Byte FP FA--FD (FP1) N1 equ $FA ;25 4 Byte FP FA--FD (FP1)
N2 equ $EC ;27 4 Byte FP EC--EF (FP2) N2 equ $EC ;27 4 Byte FP EC--EF (FP2)
; RSLT equ $1D ;29 RSLT equ $7000 ;29
*** Monitor routines *** *** Monitor routines ***
COut equ $FDED ;Console output ASCII COut equ $FDED ;Console output ASCII
CROut equ $FD8E ;Carriage return CROut equ $FD8E ;Carriage return
** Command Code ** ** Command Code **
StatusCmd equ 0 StatusCmd equ 0
** Status Code ** ** Status Code **
* StatusDIB equ 3
StatusUNI equ 5 StatusUNI equ 5
* *
ControlCmd equ 4 ControlCmd equ 4
** Control Codes ** ** Control Codes **
Eject equ 4
Run equ 5 Run equ 5
SetDWLoad equ 6 SetDWLoad equ 6
DWLoad equ 7 DWLoad equ 7
* *
org $6000 org $6000
***************************************************** *****************************************************
************** CHKSUM MAIN Routine ******************
* *
STARTCHK lda #<STARTCHK
sta PTR
lda #>STARTCHK
sta PTR+1
ldy #$00
lda #$00
pha
LOOP pla
eor (PTR),y
pha
inc PTR
bne CHK
inc PTR+1
CHK lda PTR+1
cmp #>PROGEND
bcc LOOP
lda PTR
cmp #<PROGEND
bcc LOOP
beq LOOP
CHKCS pla
cmp CHKSUM
bne ERRCHK
***********************************************
* Find a Protocol Converter in one of the slots. * Find a Protocol Converter in one of the slots.
START jsr FindPC START jsr FindPC
bcs Error bcs Error
*** Eject ***
; jsr Dispatch
; dfb ControlCmd
; dw E_JECT
*** Set Address *** *** Set Address ***
jsr Dispatch jsr Dispatch
dfb ControlCmd dfb ControlCmd
@ -63,7 +82,14 @@ START jsr FindPC
* *
jsr EXEC ; Jump the Error routine jsr EXEC ; Jump the Error routine
rts rts
********************************************* **************** CHKSUM ERROR Routine ***************
*
ERRCHK sta CHKCALC
lda #"E"
jsr COut
rts
CHKCALC dfb $00
**************** PROTOCOL CONVERTER ERROR Routine ***
Error equ * Error equ *
* *
* There is either no PC around, or there was no give message * There is either no PC around, or there was no give message
@ -81,7 +107,7 @@ errout equ *
* *
Message asc 'NO PC OR NO DEVICE' Message asc 'NO PC OR NO DEVICE'
dfb $8D,0 dfb $8D,0
********************************************* *******************************************************
* *
** Set the Input Value first in Dynamic data ** ** Set the Input Value first in Dynamic data **
@ -111,8 +137,9 @@ EXEC lda N1 ;X1
dfb ControlCmd dfb ControlCmd
dw DOWNLOAD dw DOWNLOAD
** Set Unidisk Registers ** ** Set Unidisk Registers **
* lda #01 ;First time ;First time execution
* sta UNIAcc_reg lda #$00 ; Target the first time entry point
sta LowPC_reg ; First time set init value of PC, just for the next execution
* The program begin to PC preset to $0500 * * The program begin to PC preset to $0500 *
* *
** Execute ** ** Execute **
@ -129,14 +156,14 @@ READ jsr Dispatch
* First time execute * * First time execute *
lda UNIAcc_reg lda UNIAcc_reg
sta N1 sta RSLT
lda UNIX_reg lda UNIX_reg
sta N1+1 ; Store the result sta RSLT+1 ; Store the result
lda UNIY_reg lda UNIY_reg
sta N1+2 sta RSLT+2
** Second time execute ** ** Second time execute **
lda #$3C ; Target the secont time entry point lda #$3C ; Target the second time entry point
sta LowPC_reg ; Second time set new value of PC sta LowPC_reg ; Second time set new value of PC
** Execute ** ** Execute **
jsr Dispatch jsr Dispatch
@ -150,10 +177,10 @@ READ jsr Dispatch
* Second time execute only to read the latest Byte of FP1* * Second time execute only to read the latest Byte of FP1*
lda UNIAcc_reg lda UNIAcc_reg
sta N1+3 sta RSLT+3
* *
rts PROGEND rts
CHKSUM chk
****************************************************** ******************************************************
FindPC equ * FindPC equ *
* *
@ -257,20 +284,10 @@ EXE equ *
dfb 1 dfb 1
dw CNTL_LIST2 dw CNTL_LIST2
dfb Run dfb Run
*** Eject ***
;E_JECT equ *
; dfb 3
; dfb 1
; dw CNTL_LIST1
; dfb Eject
* *
******** CONTROL LISTS ******** ******** CONTROL LISTS ********
* *
* *
*** Eject ***
CNTL_LIST1 equ *
dw $0000
*
*** Execute *** *** Execute ***
CNTL_LIST2 equ * CNTL_LIST2 equ *
Clow_byte dfb $06 Clow_byte dfb $06
@ -306,4 +323,5 @@ FP1 dfb $00
FP2 dfb $00 FP2 dfb $00
dfb $00 dfb $00
dfb $00 dfb $00
dfb $00 dfb $00
**************** End UNIDISK Program ****************