Digital Research
This commit is contained in:
2020-11-06 18:50:37 +01:00
parent 621ed8ccaf
commit 31738079c4
8481 changed files with 1888323 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,327 @@
*****************************************************************
* *
* Usual filename: BDOS00.S *
* Originally Written by W. B. Tyler, 1982. *
* Adapted by: Timothy M. Benson *
* Control: 5 May 83 15:25 (TMB) *
* Modified 18 March 1984 for extended exception handling WBT. *
* This version works with the 68000, not the 68010. *
* *
* initiate program execution *
* *
*****************************************************************
*
.globl _GO
.globl _STEP
.globl _BDOS
.globl _GETSSP
.globl _EXINIT
.text
*
*
_GO: clr.l errflag
movem.l d0-d7/a0-a5,regsave save register variables
movem.l a6/a7,asave
move.w #22,d0 set up illegal trap vector
move.w #iltv,d1
move.w d1,thvnum
move.l #th,d2
trap #3
move.l d0,savev
*
move.l 4(a7),a0 addr of state save area
*
move.w #62,d0 get supervisor mode
trap #2
*
move.l (a0),pctr pc to start at
move.w 12(a0),status starting status
move.l 4(a0),a1 set up stack pointers
move a1,usp user stack pointer
move.l 8(a0),a7 supervisor stack pointer
movem.l 14(a0),d0-d7/a0-a6 set up other registers
move.l pctr,-(a7) set up for rte
and.w #$7FFF,status
move.w status,-(a7)
rte begin executing
*
* trap handling for _GO and _STEP
*
th1: move.w (a7)+,status grab info from sys stack
move.l (a7)+,pctr (this one for exceptions)
movem.l d0-d1,bsave
Move.W #62,D0 Back into supervisor mode
Trap #2 By using the BDOS call
movem.l bsave,d0-d1
jmp th2
th: move.w (a7)+,status grab info from sys stack
Movem.L D0-D1/A0,bsave Save some stuff
Move.L #OLDVEC,A0 Get address of exception storage
Move.W #9,D0 Load exception vector count (-1)
Move.L (A7),D1 Get return address from stack
th3: Cmp.L (A0)+,D1 Is this the one we have?
Beq th4 Yep.
Dbf D0,th3 Are we done yet?
Movem.L bsave,D0-D1/A0 User exception vector
move.l (a7)+,pctr
th2: move.l a7,savessp
move.l a0,savea0
move.l usp,a0
move.l a0,saveusp
move.l savea0,a0
andi $5fff,sr
movem.l a6/a7,bsave save regs
move.l asave+4,a7 get old regs
move.l 4(a7),a6
move.l pctr,(a6)
move.l saveusp,4(a6)
move.l savessp,8(a6)
move.w status,12(a6)
and.w #$7FFF,12(a6)
movem.l d0-d7/a0-a5,14(a6)
move.w #22,d0
move.w thvnum,d1
move.l savev,d2
trap #3
move.l bsave,70(a6)
move.l bsave+4,74(a6)
btst #5,status
beq wasusr
move.l savessp,74(a6)
wasusr: move.l asave,a6
movem.l regsave,d0-d7/a0-a5
move.l errflag,d0
rts back to SID proper
th4: Movem.L bsave,D0-D1/A0 Restore registers (again)
Move.W status,-(SP) Save status register again
THRTE: Rte Continue processing as in GO.
*
*
*****************************************************************
* *
* execute one user instruction (trace or notrace) *
* *
*****************************************************************
*
_STEP: clr.l errflag
movem.l d0-d7/a0-a5,regsave save registers
movem.l a6/a7,asave save registers
*
move.w #62,d0 get supervisor mode
trap #2
*
move.w #22,d0
move.w #trv,d1
move.w d1,thvnum
move.l #th,d2
trap #3
move.l d0,savev Save previous trace exception pointer.
*
move.l asave+4,a0 caller's stack ptr
move.l 4(a0),a0 address of cpu state save area
move.l (a0),pctr starting pc
move.w 12(a0),d0 status
ori.w #$8000,d0 set trace bit
move.w d0,status starting status
move.l 4(a0),a1 user stack pointer
move.l a1,usp
move.l 8(a0),a7 system stack pointer
movem.l 14(a0),d0-d7/a0-a6 registers
move.l pctr,-(a7) set up for rte
move.w status,-(a7)
rte
*
*
*****************************************************************
* *
* BDOS Call Subroutine -- C Callable *
* *
*****************************************************************
*
_BDOS: move.w 4(a7),d0
move.l d1,saved1
move.l 6(a7),d1
trap #2
move.l saved1,d1
rts
*
.bss
*
saved1: .ds.l 1
*
.text
*
*****************************************************************
* *
* GETSSP -- supplies system stack pointer to C *
* *
*****************************************************************
*
_GETSSP: move.w #62,d0
trap #2
move.l a7,d0
andi #$5fff,sr
rts
*
*
*****************************************************************
* *
* Exception Vector Setting *
* *
* This routine sets all the exception vectors handled by *
* DDT on behalf of the program being debugged. *
* *
*****************************************************************
*
*
_EXINIT:
Movem.L D0-D7/A0-A5,-(SP) * Save all them registers
Move.L #EPB,A0 * Initialize Exception Parameter
Move.W #2,(A0) * .. Block. 1st vector is #2,
Move.L #IBRVEC,2(A0) * Place to come to on interrupt
Move.L #OLDVEC,A1 * Make pointer to old vectors
EXINI1: Move.W #$3D,D0 * Func $3D == Set Exc. Vector
Move.L A0,D1 * Get address of block
Trap #2
Move.W #22,D0 * get BIOS exception vector call
Move.W (A0),D1 * Get the vector number
Move.L #THRTE,D2 * Temporary exception vector handler
Movem.L A0-A1,-(SP) * Save the address registers
Trap #3 * Call up the BIOS
Movem.L (SP)+,A0-A1 * Restore the address registers
Move.L D0,(A1)+ * Save the old BIOS vector
Move.L D0,D2 * restore the old vector in the BIOS
Move.W #22,D0 * The call (see above)
Move.W (A0),D1 * Das Vectornummer
Movem.L A0-A1,-(SP) * Take a guess
Trap #3
Movem.L (SP)+,A0-A1
Add.W #1,(A0) * Increase vector num. to change
Add.L #6,2(A0) * And set new exception handler
Cmp.W #12,(A0) * Done yet?
Bne EXINI1 * Nope, do it again
Movem.L (SP)+,D0-D7/A0-A5 * Restore all those registers
Rts
EXHANDL:
move.l #$FF,errflag * indicate error to caller
Move.L (SP)+,STKVAL * Save RA to IBRVEC
Move.L SP,ESTKSV * Save old user stack
Move.L #EXCSTK,SP * And get one of our own
Movem.L D0-D7/A0-A6,-(SP) * Plenty big enough to save regs
Move.L STKVAL,D1 * Get the IBRVEC RA again
Sub.L #IBRVEC+6,D1 * Make it an offset into IBRVEC
Divu.W #3,D1 * Get (EXV-2) * 2
And.L #$FFFF,D1 * Clear out the remainder
Lsl.L #1,D1 * Make it an offset into messages
Cmp.W #8,D1 * If Bus Error or Address Error
Bge EXHAN1
Add.L #8,ESTKSV * .. Then get rid of garbage
EXHAN1: Add.L #EXMSLT,D1 * Now a pointer to message pointer
Move.L D1,A0
Move.L (A0),D1 * Now a pointer to the message
Move.W #9,D0 * Good enough for printing
Trap #2
Move.L #ATMES,D1 * Print " at "
Move.W #9,D0
Trap #2
Move.L ESTKSV,A0 * Get exception RA
Move.L 2(A0),-(SP) * Throw it on the stack
Jsr _puthexl * And print it out
Move.L (SP)+,A0 * Clean up the stack
Move.L #ENDMES,D1 * Print out the <CR><LF>
Move.W #9,D0
Trap #2
Movem.L (SP)+,D0-D7/A0-A6 * Get old register values
Move.L ESTKSV,SP * And the old stack pointer
Jmp th1 * And return to DDT
*
*
.data
*
* Message Table contains all the exception handler messages
*
BUSERR: Dc.B "Bus Error$"
ADRERR: Dc.B "Address Error$"
ILLINS: Dc.B "Illegal Instruction$"
ZERDIV: Dc.B "Divide by Zero$"
CHKINS: Dc.B "'CHK' Exception$"
TPVINS: Dc.B "'TRAPV' Exception$"
PRVERR: Dc.B "Privilege Violation$"
XTRACE: Dc.B "Trace Exception$"
LN10EM: Dc.B "Line 1010 Emulator$"
LN15EM: Dc.B "Line 1111 Emulator$"
ATMES: Dc.B " at $"
ENDMES: Dc.B $0D,$0A,"$"
.even
OLDVEC: .Ds.L 10 * Old vector addresses
EXMSLT: .Dc.L BUSERR,ADRERR,ILLINS * Message addresses
.Dc.L ZERDIV,CHKINS,TPVINS
.Dc.L PRVERR,XTRACE,LN10EM
.Dc.L LN15EM
.data
IBRVEC: Jsr EXHANDL * This is where exceptions point
Jsr EXHANDL * Sole purpose: Put their return
Jsr EXHANDL * .. address on the stack so that
Jsr EXHANDL * .. the exception number can be
Jsr EXHANDL * .. calculated
Jsr EXHANDL
Jsr EXHANDL
Jsr EXHANDL
Jsr EXHANDL
Jsr EXHANDL
.bss
*
ESTKSV: .Ds.L 1 * One LONG for the old user stack
STKVAL: .Ds.L 1 * Value of pointer from IBRVEC
.Ds.B 256 * Plenty of room for Exception Stack
EXCSTK:
errflag: .ds.l 1
asave: .ds.l 2
bsave: .ds.l 3
regsave: .ds.l 14
savessp: .ds.l 1
saveusp: .ds.l 1
savea0: .ds.l 1
iltv = $4 illegal instruction vector number
trv = $9 trace exception vector number
*
savev: .ds.l 1
thvnum: .ds.w 1
*
setexp = 61
setsup = 62
*
pctr: .ds.l 1
status: .ds.w 1
*
*
EPB:
vnum: .ds.w 1
newv: .ds.l 1
oldv: .ds.l 1
*
setexv=61
linef=11
buserr=2
*
*
.end
 .end


View File

@@ -0,0 +1,387 @@
*****************************************************************
* *
* Usual filename: BDOS10.S *
* Originally Written by W. B. Tyler, 1982. *
* Adapted by: Timothy M. Benson *
* Control: 5 May 83 15:25 (TMB) *
* Modified 18 March 1984 for extended exception handling WBT. *
* This version works with the 68010, not the 68000. *
* *
* initiate program execution *
* *
*****************************************************************
*
.globl _GO
.globl _STEP
.globl _BDOS
.globl _GETSSP
.globl _EXINIT
.globl _GETVBR
.globl _GETSFC
.globl _GETDFC
.text
*
*
_GO: clr.l errflag
movem.l d0-d7/a0-a5,regsave save register variables
movem.l a6/a7,asave
move.w #22,d0 set up illegal trap vector
move.w #iltv,d1
move.w d1,thvnum
move.l #th,d2
trap #3
move.l d0,savev
*
move.l 4(a7),a0 addr of state save area
*
move.w #62,d0 get supervisor mode
trap #2
*
move.l (a0),pctr pc to start at
move.w 12(a0),status starting status
move.l 4(a0),a1 set up stack pointers
move a1,usp user stack pointer
move.l 8(a0),a7 supervisor stack pointer
move.l 78(a0),d0 set up control registers...
movec d0,vbr
move.l 82(a0),d0
movec d0,sfc
move.l 86(a0),d0
movec d0,dfc
movem.l 14(a0),d0-d7/a0-a6 set up other registers
clr.w -(a7) format word
move.l pctr,-(a7) set up for rte
and.w #$7FFF,status
move.w status,-(a7)
rte begin executing
*
* trap handling for _GO and _STEP
*
th1: move.w (a7)+,status grab info from sys stack
move.l (a7)+,pctr (this one for exceptions)
movem.l d0-d1,bsave save registers
Move.W #62,D0 Back into supervisor mode
Trap #2 By using the BDOS call
movem.l bsave,d0-d1 restore registers
jmp th2
th: move.w (a7)+,status grab info from sys stack
Movem.L D0-D1/A0,bsave Save some stuff
Move.L #OLDVEC,A0 Get address of exception storage
Move.W #9,D0 Load exception vector count (-1)
Move.L (A7),D1 Get return address from stack
th3: Cmp.L (A0)+,D1 Is this the one we have?
Beq th4 Yep.
Dbf D0,th3 Are we done yet?
Movem.L bsave,D0-D1/A0 User exception vector
move.l (a7)+,pctr unstack PC
add.l #2,a7 unstack format word
th2: move.l a7,savessp
movem.l d0-d2,-(a7)
movec vbr,d0 save control registers
movec sfc,d1
movec dfc,d2
move.l d0,savevbr
move.l d1,savesfc
move.l d2,savedfc
movem.l (a7)+,d0-d2
move.l a0,savea0
move.l usp,a0
move.l a0,saveusp
move.l savea0,a0
andi $5fff,sr
movem.l a6/a7,bsave save regs
move.l asave+4,a7 get old regs
move.l 4(a7),a6
move.l pctr,(a6)
move.l saveusp,4(a6)
move.l savessp,8(a6)
move.w status,12(a6)
and.w #$7FFF,12(a6)
movem.l d0-d7/a0-a5,14(a6)
move.l savevbr,78(a6)
move.l savesfc,82(a6)
move.l savedfc,86(a6)
move.w #22,d0
move.w thvnum,d1
move.l savev,d2
trap #3
move.l bsave,70(a6)
move.l bsave+4,74(a6)
btst #5,status
beq wasusr
move.l savessp,74(a6)
wasusr: move.l asave,a6
movem.l regsave,d0-d7/a0-a5
move.l errflag,d0 return error flag
rts back to SID proper
th4: Movem.L bsave,D0-D1/A0 Restore registers (again)
Move.W status,-(SP) Save status register again
THRTE: Rte Continue processing as in GO.
*
*
*****************************************************************
* *
* execute one user instruction (trace or notrace) *
* *
*****************************************************************
*
_STEP: clr.l errflag
movem.l d0-d7/a0-a5,regsave save registers
movem.l a6/a7,asave save registers
*
move.w #62,d0 get supervisor mode
trap #2
*
move.w #22,d0
move.w #trv,d1
move.w d1,thvnum
move.l #th,d2
trap #3
move.l d0,savev Save previous trace exception pointer.
*
move.l asave+4,a0 caller's stack ptr
move.l 4(a0),a0 address of cpu state save area
move.l (a0),pctr starting pc
move.w 12(a0),d0 status
ori.w #$8000,d0 set trace bit
move.w d0,status starting status
move.l 4(a0),a1 user stack pointer
move.l a1,usp
move.l 8(a0),a7 system stack pointer
move.l 78(a0),d0
movec d0,vbr
move.l 82(a0),d0
movec d0,sfc
move.l 86(a0),d0
movec d0,dfc
movem.l 14(a0),d0-d7/a0-a6 registers
clr.w -(a7) format word
move.l pctr,-(a7) set up for rte
move.w status,-(a7)
rte
*
*
*****************************************************************
* *
* BDOS Call Subroutine -- C Callable *
* *
*****************************************************************
*
_BDOS: move.w 4(a7),d0
move.l d1,saved1
move.l 6(a7),d1
trap #2
move.l saved1,d1
rts
*
.bss
*
saved1: .ds.l 1
*
.text
*
*****************************************************************
* *
* GETSSP -- supplies system stack pointer to C *
* *
*****************************************************************
*
_GETSSP: move.w #62,d0
trap #2
move.l a7,d0
andi #$5fff,sr
rts
*
*
*****************************************************************
* *
* Routines for getting control register values from C *
* *
*****************************************************************
*
*
_GETVBR: move.w #62,d0
trap #2
movec vbr,d0
andi #$5fff,sr
rts
_GETSFC: move.w #62,d0
trap #2
movec sfc,d0
andi #$5fff,sr
rts
_GETDFC: move.w #62,d0
trap #2
movec dfc,d0
andi #$5fff,sr
rts
*
*
*****************************************************************
* *
* Exception Vector Setting *
* *
* This routine sets all the exception vectors handled by *
* DDT on behalf of the program being debugged. *
* *
*****************************************************************
*
*
_EXINIT:
Movem.L D0-D7/A0-A5,-(SP) * Save all them registers
Move.L #EPB,A0 * Initialize Exception Parameter
Move.W #2,(A0) * .. Block. 1st vector is #2,
Move.L #IBRVEC,2(A0) * Place to come to on interrupt
Move.L #OLDVEC,A1 * Make pointer to old vectors
EXINI1: Move.W #$3D,D0 * Func $3D == Set Exc. Vector
Move.L A0,D1 * Get address of block
Trap #2
Move.W #22,D0 * get BIOS exception vector call
Move.W (A0),D1 * Get the vector number
Move.L #THRTE,D2 * Temporary exception vector handler
Movem.L A0-A1,-(SP) * Save the address registers
Trap #3 * Call up the BIOS
Movem.L (SP)+,A0-A1 * Restore the address registers
Move.L D0,(A1)+ * Save the old BIOS vector
Move.L D0,D2 * restore the old vector in the BIOS
Move.W #22,D0 * The call (see above)
Move.W (A0),D1 * Das Vectornummer
Movem.L A0-A1,-(SP) * Take a guess
Trap #3
Movem.L (SP)+,A0-A1
Add.W #1,(A0) * Increase vector num. to change
Add.L #6,2(A0) * And set new exception handler
Cmp.W #12,(A0) * Done yet?
Bne EXINI1 * Nope, do it again
Movem.L (SP)+,D0-D7/A0-A5 * Restore all those registers
Rts
EXHANDL:
move.l #$ff,errflag * indicate error to caller
Move.L (SP)+,STKVAL * Save RA to IBRVEC
Move.L SP,ESTKSV * Save old user stack
Move.L #EXCSTK,SP * And get one of our own
Movem.L D0-D7/A0-A6,-(SP) * Plenty big enough to save regs
Move.L STKVAL,D1 * Get the IBRVEC RA again
Sub.L #IBRVEC+6,D1 * Make it an offset into IBRVEC
Divu.W #3,D1 * Get (EXV-2) * 2
And.L #$FFFF,D1 * Clear out the remainder
Lsl.L #1,D1 * Make it an offset into messages
Cmp.W #8,D1 * If Bus Error or Address Error
Bge EXHAN1
Add.L #8,ESTKSV * .. Then get rid of garbage
EXHAN1: Add.L #EXMSLT,D1 * Now a pointer to message pointer
Move.L D1,A0
Move.L (A0),D1 * Now a pointer to the message
Move.W #9,D0 * Good enough for printing
Trap #2
Move.L #ATMES,D1 * Print " at "
Move.W #9,D0
Trap #2
Move.L ESTKSV,A0 * Get exception RA
Move.L 2(A0),-(SP) * Throw it on the stack
Jsr _puthexl * And print it out
Move.L (SP)+,A0 * Clean up the stack
Move.L #ENDMES,D1 * Print out the <CR><LF>
Move.W #9,D0
Trap #2
Movem.L (SP)+,D0-D7/A0-A6 * Get old register values
Move.L ESTKSV,SP * And the old stack pointer
Jmp th1 * And return to DDT
*
*
.data
*
* Message Table contains all the exception handler messages
*
BUSERR: Dc.B "Bus Error$"
ADRERR: Dc.B "Address Error$"
ILLINS: Dc.B "Illegal Instruction$"
ZERDIV: Dc.B "Divide by Zero$"
CHKINS: Dc.B "'CHK' Exception$"
TPVINS: Dc.B "'TRAPV' Exception$"
PRVERR: Dc.B "Privilege Violation$"
XTRACE: Dc.B "Trace Exception$"
LN10EM: Dc.B "Line 1010 Emulator$"
LN15EM: Dc.B "Line 1111 Emulator$"
ATMES: Dc.B " at $"
ENDMES: Dc.B $0D,$0A,"$"
.even
OLDVEC: .Ds.L 10 * Old vector addresses
EXMSLT: .Dc.L BUSERR,ADRERR,ILLINS * Message addresses
.Dc.L ZERDIV,CHKINS,TPVINS
.Dc.L PRVERR,XTRACE,LN10EM
.Dc.L LN15EM
.data
IBRVEC: Jsr EXHANDL * This is where exceptions point
Jsr EXHANDL * Sole purpose: Put their return
Jsr EXHANDL * .. address on the stack so that
Jsr EXHANDL * .. the exception number can be
Jsr EXHANDL * .. calculated
Jsr EXHANDL
Jsr EXHANDL
Jsr EXHANDL
Jsr EXHANDL
Jsr EXHANDL
.bss
*
ESTKSV: .Ds.L 1 * One LONG for the old user stack
STKVAL: .Ds.L 1 * Value of pointer from IBRVEC
.Ds.B 256 * Plenty of room for Exception Stack
EXCSTK:
errflag: .ds.l 1
asave: .ds.l 2
bsave: .ds.l 3
regsave: .ds.l 14
savessp: .ds.l 1
saveusp: .ds.l 1
savea0: .ds.l 1
savevbr: .ds.l 1
savesfc: .ds.l 1
savedfc: .ds.l 1
iltv = $4 illegal instruction vector number
trv = $9 trace exception vector number
*
savev: .ds.l 1
thvnum: .ds.w 1
*
setexp = 61
setsup = 62
*
pctr: .ds.l 1
status: .ds.w 1
*
*
EPB:
vnum: .ds.w 1
newv: .ds.l 1
oldv: .ds.l 1
*
setexv=61
linef=11
buserr=2
*
*
.end
1
linef=11
buserr=2
*
*
.end


View File

@@ -0,0 +1,48 @@
/****************************************************************/
/* */
/* Define BDOS Function Codes */
/* */
/****************************************************************/
#define SYSRESET 0
#define CONIN 1
#define CONOUT 2
#define READIN 3
#define PUNOUT 4
#define LISTOUT 5
#define DCONIO 6
#define GETIOB 7
#define SETIOB 8
#define PRNTSTR 9
#define READBUF 10
#define CONSTAT 11
#define GETVER 12
#define RESETDSK 13
#define SELDSK 14
#define OPEN 15
#define CLOSE 16
#define SRCHFST 17
#define SRCHNXT 18
#define DELETE 19
#define READSEQ 20
#define WRITSEQ 21
#define MAKEFILE 22
#define RENAME 23
#define GTLOGIN 24
#define CURDSK 25
#define SETDMA 26
#define WRTPROT 28
#define GETROV 29
#define SETATTR 30
#define GETDPB 31
#define USERCD 32
#define READRND 33
#define WRITRND 34
#define FILESIZ 35
#define SETRND 36
#define RESTDRV 37
#define WRANDZF 40
#define GETFREE 46
#define DBIOSCL 50
#define PGMLOAD 59

View File

@@ -0,0 +1,13 @@
/********************************************************/
/* */
/* Include file for SID-68K -- MC68000 Version */
/* */
/********************************************************/
#define MC68000 1
 */
/********************************************************/
#define MC68000 1

View File

@@ -0,0 +1,13 @@
/********************************************************/
/* */
/* Include file for SID-68K -- MC68010 Version */
/* */
/********************************************************/
#define MC68010 1
 */
/********************************************************/
#define MC68010 1

View File

@@ -0,0 +1,13 @@
/********************************************************/
/* */
/* Include file for SID-68K -- MC68010 Version */
/* */
/********************************************************/
#define MC68010 1
 */
/********************************************************/
#define MC68010 1

Binary file not shown.

View File

@@ -0,0 +1,159 @@
/********************************************************/
/* */
/* Stuff to INCLUDE in DDT-68K */
/* */
/********************************************************/
#define MAXBP 10 /* max breakpoints allowed */
#define ILLEGAL 0x4AFC /* ILLEGAL instruction */
#define BDOSCALL 0x4E42 /* TRAP #2 instruction */
#define BIOSCALL 0x4E43 /* TRAP #3 instruction */
#define BUFLEN 85 /* command buffer length */
#define GETSEP getsep(&cx)
struct bytestr { char memb; };
struct wordstr { int memw; };
struct longstr { long meml; };
/****************************************************************/
/* */
/* Define the CPU Status Structure and Related Tables */
/* */
/****************************************************************/
struct cpustate {
long pc;
long usp;
long ssp;
int status;
long dreg[8];
long areg[8];
#ifdef MC68010
long vbr;
long sfc;
long dfc;
#endif
};
#define TRACE 0x8000
#define SUPER 0x2000
#define INTMSK 0x0700
#define EXTEND 0x0010
#define NEG 0x0008
#define ZERO 0x0004
#define OFLOW 0x0002
#define CARRY 0x0001
/****************************************************************/
/* */
/* Define FCB Structure */
/* */
/****************************************************************/
struct fcb {
char dr; /* drive code */
char fn[8]; /* file name */
char t[3]; /* file type */
char ex; /* extent */
char s1; /* used by sys */
char s2; /* used by sys */
char rc; /* rec count */
char d[16]; /* used by sys */
char cr; /* curr rec no */
char r[3]; /* rand rec no */
};
/****************************************************************/
/* */
/* Base Page Structure */
/* */
/****************************************************************/
struct basepage {
long lowtpa; /* low address of tpa */
long hightpa; /* high address of tpa */
long csstart; /* start of code seg */
long cslen; /* length of code seg */
long dsstart; /* start of data seg */
long dslen; /* length of data seg */
long bsstart; /* start of bss seg */
long bslen; /* length of bss seg */
long freelen; /* free mem after bss */
long reserved[5];
struct fcb fcb2;
struct fcb fcb1;
char comtail[0x80];
};
/************************************************************************/
/* */
/* Define a structure for holding information about the most */
/* recently loaded program or file */
/* */
/************************************************************************/
struct value {
int kind; /* 0 => none, 1 => pgm, 2 => file */
long textbase; /* if kind==2 then use textseg for file */
long textlen;
long database;
long datalen;
long bssbase;
long bsslen;
long bpa;
long initstk;
};
/************************************************************************/
/* */
/* Define the Load Program Parameter Block */
/* */
/************************************************************************/
struct lpb {
struct fcb *fcbaddr;
long tpabase;
long tpatop;
long *bpaddr;
long stkinit;
int flags;
};
/****************************************************************/
/* */
/* Some Forward Function Definitions */
/* */
/****************************************************************/
char *readcom();
char hexchar();
short int getform();
long int GETSSP();
#ifdef MC68010
long int GETVBR();
long int GETSFC();
long int GETDFC();
#endif
/**/
VBR();
long int GETSFC();
long int GETDFC();
#endif
/**/

View File

@@ -0,0 +1,202 @@
*****************************************************************
* *
* Usual filename: SIDLOAD.S *
* Adapted by: Timothy M. Benson *
* Control: 4 MAY 83 15:21 (TMB) *
* *
* SID Loader -- This program loads DDT68000 at the top of *
* the TPA, hands it its command tail, and passes control *
* to it. *
* *
*****************************************************************
*
.text
*
start: move.l (a7)+,ccprtn * save stacked info
move.l (a7)+,bpaddr
*
lea mystack+$80,a7 * switch to local stack
*
move.l bpaddr,a0 * copy base page to local area
lea localbp,a1
move.l #$100,d0 * count of bytes to move
bsr copy * branch to subroutine
*
move.w #32,d0 * get the current user # and save it
move.l #$ff,d1 * d1 = 255
trap #2 * call the bdos
move.l d0,d3 * d3 holds current user #
*
move.l bpaddr,a0 * get drive for DDT68000.68K
move.b $24(a0),sidfcb * and stuff into FCB
move.w #openf,d0 * open file DDT68000.68K
move.l #sidfcb,d1 * get address of fcb
trap #2 * call the bdos
cmpi.b #$ff,d0 * check for failure
bne openok * if not then go ahead
*
tst d3 * check if we are on user 0
beq loadfail * if so then we have failed
*
move.w #32,d0 * if not then switch to user 0
clr.l d1 * d1 = 0
trap #2 * call the bdos
*
move.w #openf,d0 * try the open again
move.l #sidfcb,d1 * address of fcb
trap #2 * call the bdos
cmpi.b #$ff,d0 * check for errors
beq loadfail * error, load failed
*
openok: move.w #setdma,d0 * set up to read pgm header
move.l #dskbuf,d1 * dma address
trap #2 * call the bdos
*
move.w #readseq,d0 * read the header
move.l #sidfcb,d1 * address of fcb
trap #2 * call the bdos
cmpi.w #0,d0 * check for errors
bne loadfail * error, load failed
*
lea dskbuf,a0
move.l tsize(a0),d0 * compute size of DDT68000.68K
add.l dsize(a0),d0 * by adding component sizes
add.l bsize(a0),d0
add.l #$1000,d0 * fake stack size since Belton doesnt
add.l #bplen+fudge,d0
*
cmpi.w #goodmgc,magic(a0) * must be $601A
bne loadfail
*
tst.w rlbflg(a0) * must be 0
bne loadfail
*
lea localbp,a0
lea lpb,a1
lea sidfcb,a2
move.l a2,lpbfcb(a1)
move.l bphitpa(a0),d1 * set up lpb and load pgm
move.l d1,lpbhitpa(a1)
sub.l d0,d1
bclr.l #0,d1
move.l d1,lpblotpa(a1)
clr.w lpbcf(a1)
clr.b sidfcb+fcbcr
move.w #pgmldf,d0 * now do load
move.l a1,d1
trap #2
tst.w d0
bne loadfail * load has failed
*
move.l d3,d1 * restore the old user 0
move.w #32,d0 * get bdos function #
trap #2 * call the bdos
*
* set up for SID execution
*
move.l lpbbpa(a1),a2 * addr of new bp
move.l bplotpa(a0),bplotpa(a2) * copy tpa lower bound
move.l lpbdusp(a1),a7 * default user stack ptr
move.l a2,-(a7) * stack new bp address
move.l ccprtn,-(a7) * stack ccp rtn address
move.l bpcsstrt(a2),-(a7) * stack entry to DDT68000.68K
lea bpfcb2(a0),a0 * copy parsed fcb's &
lea bpfcb2(a2),a1 * command tail to new bp
move.l #bplen-bpfcb2,d0
bsr copy
rts * exit to DDT68000.68K
*
* BDOS Function Code Equates
*
prstrng = 9
openf = 15
closef = 16
readseq = 20
setdma = 26
bioscall= 50
pgmldf = 59
*
*
* Local Variables etc.
*
mystack: .ds.l $20 * local stack
*
fudge = $10
*
bplen = $100
localbp: .ds.l bplen * local copy of base page
bplotpa = 0
bphitpa = 4
bpcsstrt= 8
bpcslen = $C
bpdsstrt= $10
bpdslen = $14
bpbsstrt= $18
bpbslen = $1C
bpfcb2 = $38
bpfcb1 = $5C
*
ccprtn: .ds.l 1 * return addr in CCP
bpaddr: .ds.l 1 * base page address
*
sidfcb: .dc.b 0 * FCB for DDT68000.68K
.dc.b 'DDT6800068K' * File name and type.
.dc.b 0 * extent
.dc.b 0,0 * s1, s2
.dc.b 0 * rc
.ds.b 16 * d0 ... dn
.dc.b 0 * cr
.ds.b 0,0,0 * random record number
*
.even
*
fcbcr = 32
*
dskbuf: .ds.w 64 * used to hold pgm header
magic = 0 * offsets in pgm header
tsize = 2
dsize = 6
bsize = 10
stksize = 18
rlbflg = 26
*
goodmgc = $601A * legal value for magic number
*
*
*
lpb: .ds.w 11 * loader parameter block
lpbfcb = 0
lpblotpa= 4
lpbhitpa= 8
lpbbpa = 12
lpbdusp = 16
lpbcf = 20
*
*
* Copy Bytes from (a0)+ to (a1)+ for d0
*
copy: subi.l #1,d0
bmi copyxit
copylp: move.b (a0)+,(a1)+
dbf d0,copylp
copyxit: rts
*
*
* Can't Load DDT68000.68K, Print Error Message
*
loadfail: move.w #prstrng,d0
move.l #loaderr,d1
trap #2
move.l ccprtn,-(a7)
rts
loaderr: .dc.b 13,10,'Cannot load DDT68000.68K.',13,10,'$'
*
*
.end

move.l ccprtn,-(a7)
rts
loaderr: .dc.b 13,10,'Cannot load DDT68000.68K.',13,10,'$'
*
*
.end

View File

@@ -0,0 +1,80 @@
/*
Copyright 1981
Alcyon Corporation
8474 Commerce Av.
San Diego, Ca. 92121
*/
#define NUMSS 1 /*number of special symbols*/
#define SSRG 0 /*max symbol offset to display symbolically*/
#define LSTENT 12
struct symtab {
char syname[8];
char *syval;
};
struct {
int hiword;
int loword;
};
char *symbuf; /*start of symbol table*/
char *esymbuf; /*end of symbol table*/
int *symptr;
int errflg;
/* the following definitions must not be changed -- esp. the order */
int symlen;
int symct;
char ssymbol[8];
int ssymflg;
char *ssymval;
/* end of order dependant declarations */
char *dot;
char *tdot;
int dotinc;
char *sdot; /* symbolic operand temporary dot */
int textsym;
#define TEXTS 01000
#define DATAS 02000
#define BSSS 0400
#define ABSS 03400
char tsym[10];
char fsymbol[10];
int seffadr, sefaflg; /* effective address search variables */
int ssval[NUMSS]; /* special symbol values */
int instr; /* holds instruction first word */
#define BYTESZ 0
#define WORDSZ 1
#define LONGSZ 2
/* flags for symbols */
# define SYDF 0100000 /* defined */
# define SYEQ 0040000 /* equated */
# define SYGL 0020000 /* global - entry or external */
# define SYER 0010000 /* equated register */
# define SYXR 0004000 /* external reference */
# define SYDA 0002000 /* DATA based relocatable */
# define SYTX 0001000 /* TEXT based relocatable */
# define SYBS 0000400 /* BSS based relocatable */
struct { /* NOT PORTABLE !!!!!! */
char hibyte;
char lobyte;
};
#define AREG0 8
#define PC 16
char lbuf[40];

#define AREG0 8
#define PC 16
char lbuf[40];

View File

@@ -0,0 +1,75 @@
/********************************************************/
/* */
/* Usual filename: LGCDEF.H */
/* Put ' #include "lgcdef.h" ' at head of each */
/* separately compiled module containing */
/* code added to DDT68K to give SID68K. */
/* Remarks: General purpose symbol definitions */
/* for use by C-programmers in Languages. */
/* Author: Timothy M. Benson */
/* Last modified: 27 January 1983 */
/* */
/********************************************************/
/* Lower-case and mixed-case */
#define begin {
#define end }
#define otherwise else
#define and &&
#define or ||
#define If if( /* Note mixed case */
#define then )
/* Upper-case */
#define ADDR &
#define AND &
#define ANDEQ &=
#define ANDWITH &=
#define AT ->
#define BEGIN {
#define BLOCK {
#define CASE case
#define COMP ~
#define DCR -=
#define DECBY -=
#define DEFAULT default
#define DO do
#define DOFALSE :
#define DOTRUE ?
#define ELSE else
#define END }
#define EQ ==
#define FALSE 0
#define GE >=
#define GT >
#define IF if
#define IGNORE continue
#define INC +=
#define INCBY +=
#define LE <=
#define LT <
#define NE !=
#define NOT !
#define OR |
#define OREQ |=
#define ORWITH |=
#define SHL <<
#define SHLBY <<=
#define SHLR <<=
#define SHR >>
#define SHRBY >>=
#define SHRR >>=
#define TRUE 1
#define UNBLOCK }
#define VAL *
#define WHILE while
#define XOR ^
#define XORWITH ^=
TRUE 1
#define UNBLOCK }
#define VAL *
#define WHILE while
#define XOR ^
#define XORWITH ^=

Binary file not shown.

View File

@@ -0,0 +1,289 @@
/* struct for optab */
struct optbl {
WORD inmsk;
WORD invalu;
WORD infmt;
BYTE *innam;
};
#define MAXFMT 28
#define OPENT 4 /* # words per line in optab */
struct optbl optab[] = {
0xffff, 0x023c, 3, "andi.b",
0xffff, 0x027c, 3, "andi.w",
0xffff, 0x0a3c, 3, "eori.b",
0xffff, 0x0a7c, 3, "eori.w",
0xffff, 0x4afa, 0, "illegal",
0xffff, 0x4afb, 0, "illegal",
0xffff, 0x4afc, 0, "illegal",
0xffff, 0x4e71, 0, "nop",
0xffff, 0x003c, 3, "ori.b",
0xffff, 0x007c, 3, "ori.w",
0xffff, 0x4e70, 0, "reset",
0xffff, 0x4e74, 21, "rtd",
0xffff, 0x4e73, 0, "rte",
0xffff, 0x4e77, 0, "rtr",
0xffff, 0x4e75, 0, "rts",
0xffff, 0x4e72, 21, "stop",
0xffff, 0x4e76, 0, "trapv",
0xfffe, 0x4e7a, 24, "movec",
0xfff8, 0x50c8, 12, "dbt",
0xfff8, 0x51c8, 12, "dbf",
0xfff8, 0x52c8, 12, "dbhi",
0xfff8, 0x53c8, 12, "dbls",
0xfff8, 0x54c8, 12, "dbcc",
0xfff8, 0x55c8, 12, "dbcs",
0xfff8, 0x56c8, 12, "dbne",
0xfff8, 0x57c8, 12, "dbeq",
0xfff8, 0x58c8, 12, "dbvc",
0xfff8, 0x59c8, 12, "dbvs",
0xfff8, 0x5ac8, 12, "dbpl",
0xfff8, 0x5bc8, 12, "dbmi",
0xfff8, 0x5cc8, 12, "dbge",
0xfff8, 0x5dc8, 12, "dblt",
0xfff8, 0x5ec8, 12, "dbgt",
0xfff8, 0x5fc8, 12, "dble",
0xfff8, 0x4880, 14, "ext.w",
0xfff8, 0x48c0, 14, "ext.l",
0xfff8, 0x4e50, 15, "link",
0xfff8, 0x4e60, 17, "move.l", /* move usp */
0xfff8, 0x4e68, 17, "move.l",
0xfff8, 0x4840, 22, "swap",
0xfff8, 0x4e58, 22, "unlk",
0xfff0, 0x4e40, 23, "trap",
0xffc0, 0x0600, 3, "addi.b",
0xffc0, 0x0640, 3, "addi.w",
0xffc0, 0x0680, 3, "addi.l",
0xffc0, 0x0200, 3, "andi.b",
0xffc0, 0x0240, 3, "andi.w",
0xffc0, 0x0280, 3, "andi.l",
0xffc0, 0xe1c0, 7, "asl",
0xffc0, 0xe0c0, 7, "asr",
0xffc0, 0x0840, 10, "bchg",
0xffc0, 0x0880, 10, "bclr",
0xffc0, 0x08c0, 10, "bset",
0xffc0, 0x0800, 10, "btst",
0xffc0, 0x4200, 7, "clr.b",
0xffc0, 0x4240, 7, "clr.w",
0xffc0, 0x4280, 7, "clr.l",
0xffc0, 0x0c00, 3, "cmpi.b",
0xffc0, 0x0c40, 3, "cmpi.w",
0xffc0, 0x0c80, 3, "cmpi.l",
0xffc0, 0x0a00, 3, "eori.b",
0xffc0, 0x0a40, 3, "eori.w",
0xffc0, 0x0a80, 3, "eori.l",
0xffc0, 0x4ec0, 7, "jmp",
0xffc0, 0x4e80, 7, "jsr",
0xffc0, 0xe3c0, 7, "lsl",
0xffc0, 0xe2c0, 7, "lsr",
0xffc0, 0x42c0, 5, "move.w",
0xffc0, 0x44c0, 5, "move.w",
0xffc0, 0x46c0, 5, "move.w",
0xffc0, 0x40c0, 5, "move.w",
0xffc0, 0x4c80, 18, "movem.w",
0xffc0, 0x4cc0, 18, "movem.l",
0xffc0, 0x4880, 18, "movem.w",
0xffc0, 0x48c0, 18, "movem.l",
0xffc0, 0x0e00, 25, "moves.b",
0xffc0, 0x0e40, 25, "moves.w",
0xffc0, 0x0e80, 25, "moves.l",
0xffc0, 0x4800, 7, "nbcd",
0xffc0, 0x4400, 7, "neg.b",
0xffc0, 0x4440, 7, "neg.w",
0xffc0, 0x4480, 7, "neg.l",
0xffc0, 0x4000, 7, "negx.b",
0xffc0, 0x4040, 7, "negx.w",
0xffc0, 0x4080, 7, "negx.l",
0xffc0, 0x4600, 7, "not.b",
0xffc0, 0x4640, 7, "not.w",
0xffc0, 0x4680, 7, "not.l",
0xffc0, 0x0000, 3, "ori.b",
0xffc0, 0x0040, 3, "ori.w",
0xffc0, 0x0080, 3, "ori.l",
0xffc0, 0x4840, 7, "pea",
0xffc0, 0xe7c0, 7, "rol",
0xffc0, 0xe6c0, 7, "ror", /* rotate memory */
0xffc0, 0xe5c0, 7, "roxl",
0xffc0, 0xe4c0, 7, "roxr",
0xffc0, 0x50c0, 7, "st",
0xffc0, 0x51c0, 7, "sf",
0xffc0, 0x52c0, 7, "shi",
0xffc0, 0x53c0, 7, "sls",
0xffc0, 0x54c0, 7, "scc",
0xffc0, 0x55c0, 7, "scs",
0xffc0, 0x56c0, 7, "sne",
0xffc0, 0x57c0, 7, "seq",
0xffc0, 0x58c0, 7, "svc",
0xffc0, 0x59c0, 7, "svs",
0xffc0, 0x5ac0, 7, "spl",
0xffc0, 0x5bc0, 7, "smi",
0xffc0, 0x5cc0, 7, "sge",
0xffc0, 0x5dc0, 7, "slt",
0xffc0, 0x5ec0, 7, "sgt",
0xffc0, 0x5fc0, 7, "sle",
0xffc0, 0x0400, 3, "subi.b",
0xffc0, 0x0440, 3, "subi.w",
0xffc0, 0x0480, 3, "subi.l",
0xffc0, 0x4ac0, 7, "tas.b",
0xffc0, 0x4a00, 7, "tst.b",
0xffc0, 0x4a40, 7, "tst.w",
0xffc0, 0x4a80, 7, "tst.l",
0xff00, 0x6200, 8, "bhi",
0xff00, 0x6300, 8, "bls",
0xff00, 0x6400, 8, "bcc",
0xff00, 0x6500, 8, "bcs",
0xff00, 0x6600, 8, "bne",
0xff00, 0x6700, 8, "beq",
0xff00, 0x6800, 8, "bvc",
0xff00, 0x6900, 8, "bvs",
0xff00, 0x6a00, 8, "bpl",
0xff00, 0x6b00, 8, "bmi",
0xff00, 0x6c00, 8, "bge",
0xff00, 0x6d00, 8, "blt",
0xff00, 0x6e00, 8, "bgt",
0xff00, 0x6f00, 8, "ble",
0xff00, 0x6000, 8, "bra",
0xff00, 0x6100, 8, "bsr",
0xf1f8, 0xc100, 1, "abcd",
0xf1f8, 0xc108, 1, "abcd",
0xf1f8, 0xd100, 1, "addx.b",
0xf1f8, 0xd140, 1, "addx.w",
0xf1f8, 0xd180, 1, "addx.l",
0xf1f8, 0xd108, 1, "addx.b",
0xf1f8, 0xd148, 1, "addx.w",
0xf1f8, 0xd188, 1, "addx.l",
0xf1f8, 0xc140, 13, "exg",
0xf1f8, 0xc148, 13, "exg",
0xf1f8, 0xc188, 13, "exg",
0xf1f8, 0xe100, 6, "asl.b",
0xf1f8, 0xe140, 6, "asl.w",
0xf1f8, 0xe180, 6, "asl.l",
0xf1f8, 0xe120, 6, "asl.b",
0xf1f8, 0xe160, 6, "asl.w",
0xf1f8, 0xe1a0, 6, "asl.l",
0xf1f8, 0xe000, 6, "asr.b",
0xf1f8, 0xe040, 6, "asr.w",
0xf1f8, 0xe080, 6, "asr.l",
0xf1f8, 0xe020, 6, "asr.b",
0xf1f8, 0xe060, 6, "asr.w",
0xf1f8, 0xe0a0, 6, "asr.l",
0xf1f8, 0xb108, 11, "cmpm.b",
0xf1f8, 0xb148, 11, "cmpm.w",
0xf1f8, 0xb188, 11, "cmpm.l",
0xf1f8, 0xe108, 6, "lsl.b",
0xf1f8, 0xe148, 6, "lsl.w",
0xf1f8, 0xe188, 6, "lsl.l",
0xf1f8, 0xe128, 6, "lsl.b",
0xf1f8, 0xe168, 6, "lsl.w",
0xf1f8, 0xe1a8, 6, "lsl.l",
0xf1f8, 0xe008, 6, "lsr.b",
0xf1f8, 0xe048, 6, "lsr.w",
0xf1f8, 0xe088, 6, "lsr.l",
0xf1f8, 0xe028, 6, "lsr.b",
0xf1f8, 0xe068, 6, "lsr.w",
0xf1f8, 0xe0a8, 6, "lsr.l",
0xf1f8, 0x0108, 19, "movep.w",
0xf1f8, 0x0148, 19, "movep.l",
0xf1f8, 0x0188, 19, "movep.w",
0xf1f8, 0x01c8, 19, "movep.l",
0xf1f8, 0xe118, 6, "rol.b", /* rotate register */
0xf1f8, 0xe158, 6, "rol.w",
0xf1f8, 0xe198, 6, "rol.l",
0xf1f8, 0xe138, 6, "rol.b",
0xf1f8, 0xe178, 6, "rol.w",
0xf1f8, 0xe1b8, 6, "rol.l",
0xf1f8, 0xe018, 6, "ror.b",
0xf1f8, 0xe058, 6, "ror.w",
0xf1f8, 0xe098, 6, "ror.l",
0xf1f8, 0xe038, 6, "ror.b",
0xf1f8, 0xe078, 6, "ror.w",
0xf1f8, 0xe0b8, 6, "ror.l",
0xf1f8, 0xe110, 6, "roxl.b",
0xf1f8, 0xe150, 6, "roxl.w",
0xf1f8, 0xe190, 6, "roxl.l",
0xf1f8, 0xe130, 6, "roxl.b",
0xf1f8, 0xe170, 6, "roxl.w",
0xf1f8, 0xe1b0, 6, "roxl.l",
0xf1f8, 0xe010, 6, "roxr.b",
0xf1f8, 0xe050, 6, "roxr.w",
0xf1f8, 0xe090, 6, "roxr.l",
0xf1f8, 0xe030, 6, "roxr.b",
0xf1f8, 0xe070, 6, "roxr.w",
0xf1f8, 0xe0b0, 6, "roxr.l",
0xf1f8, 0x8100, 1, "sbcd",
0xf1f8, 0x8108, 1, "sbcd",
0xf1f8, 0x9100, 1, "subx.b",
0xf1f8, 0x9140, 1, "subx.w",
0xf1f8, 0x9180, 1, "subx.l",
0xf1f8, 0x9108, 1, "subx.b",
0xf1f8, 0x9148, 1, "subx.w",
0xf1f8, 0x9188, 1, "subx.l",
0xf1c0, 0xd000, 2, "add.b",
0xf1c0, 0xd040, 2, "add.w",
0xf1c0, 0xd080, 2, "add.l",
0xf1c0, 0xd100, 2, "add.b",
0xf1c0, 0xd140, 2, "add.w",
0xf1c0, 0xd180, 2, "add.l",
0xf1c0, 0xd0c0, 2, "adda.w",
0xf1c0, 0xd1c0, 2, "adda.l",
0xf1c0, 0x5000, 4, "addq.b",
0xf1c0, 0x5040, 4, "addq.w",
0xf1c0, 0x5080, 4, "addq.l",
0xf1c0, 0xc000, 2, "and.b",
0xf1c0, 0xc040, 2, "and.w",
0xf1c0, 0xc080, 2, "and.l",
0xf1c0, 0xc100, 2, "and.b",
0xf1c0, 0xc140, 2, "and.w",
0xf1c0, 0xc180, 2, "and.l",
0xf1c0, 0x0140, 10, "bchg",
0xf1c0, 0x0180, 10, "bclr",
0xf1c0, 0x01c0, 10, "bset",
0xf1c0, 0x0100, 10, "btst", /* fix to Belton's code */
0xf1c0, 0x4180, 9, "chk",
0xf1c0, 0xb000, 2, "cmp.b",
0xf1c0, 0xb040, 2, "cmp.w",
0xf1c0, 0xb080, 2, "cmp.l",
0xf1c0, 0xb0c0, 2, "cmpa.w",
0xf1c0, 0xb1c0, 2, "cmpa.l",
0xf1c0, 0x81c0, 9, "divs",
0xf1c0, 0x80c0, 9, "divu",
0xf1c0, 0xb100, 2, "eor.b",
0xf1c0, 0xb140, 2, "eor.w",
0xf1c0, 0xb180, 2, "eor.l",
0xf1c0, 0x41c0, 2, "lea",
0xf1c0, 0x3040, 16, "movea.w",
0xf1c0, 0x2040, 16, "movea.l",
0xf1c0, 0xc1c0, 9, "muls",
0xf1c0, 0xc0c0, 9, "mulu",
0xf1c0, 0x8000, 2, "or.b",
0xf1c0, 0x8040, 2, "or.w",
0xf1c0, 0x8080, 2, "or.l",
0xf1c0, 0x8100, 2, "or.b",
0xf1c0, 0x8140, 2, "or.w",
0xf1c0, 0x8180, 2, "or.l",
0xf1c0, 0x9000, 2, "sub.b",
0xf1c0, 0x9040, 2, "sub.w",
0xf1c0, 0x9080, 2, "sub.l",
0xf1c0, 0x9100, 2, "sub.b",
0xf1c0, 0x9140, 2, "sub.w",
0xf1c0, 0x9180, 2, "sub.l",
0xf1c0, 0x90c0, 2, "suba.w",
0xf1c0, 0x91c0, 2, "suba.l",
0xf1c0, 0x5100, 4, "subq.b",
0xf1c0, 0x5140, 4, "subq.w",
0xf1c0, 0x5180, 4, "subq.l",
0xf100, 0x7000, 20, "moveq.l",
0xf000, 0x1000, 16, "move.b",
0xf000, 0x3000, 16, "move.w",
0xf000, 0x2000, 16, "move.l",
0x0000, 0x0000, 0, "*unknown instruction*"
};
, 0x3000, 16, "move.w",
 0xf000, 0x2000, 16, "move.l",
0x0000, 0x0000, 0, "*unknown instruction*"
};
, 0x3000, 16, "move.w",

View File

@@ -0,0 +1,56 @@
/*****************************************************************************
*
* C P / M C R U N T I M E L I B H E A D E R F I L E
* -------------------------------------------------------------
* Copyright 1982 by Digital Research Inc. All rights reserved.
*
* This is an include file for assisting the user to write portable
* programs for C.
*
*****************************************************************************/
#define ALCYON 1 /* using Alcyon compiler */
/*
* Standard type definitions
*/
/***************************/
#define BYTE char /* Signed byte */
#define BOOLEAN char /* 2 valued (true/false) */
#define WORD short /* Signed word (16 bits) */
#define UWORD unsigned int /* unsigned word */
#define LONG long /* signed long (32 bits) */
#define ULONG unsigned long /* Unsigned long */
#define REG register /* register variable */
#define LOCAL auto /* Local var on 68000 */
#define EXTERN extern /* External variable */
#define MLOCAL static /* Local to module */
#define GLOBAL /**/ /* Global variable */
#define VOID /**/ /* Void function return */
#define DEFAULT int /* Default size */
/***************************/
#ifdef ALCYON
#define UBYTE char
#else
#define UBYTE unsigned char /* Unsigned byte */
#endif
/****************************************************************************/
/* Miscellaneous Definitions: */
/****************************************************************************/
#define FAILURE (-1) /* Function failure return val */
#define SUCCESS (0) /* Function success return val */
#define YES 1 /* "TRUE" */
#define NO 0 /* "FALSE" */
#define FOREVER for(;;) /* Infinite loop declaration */
#define NULL 0 /* Null pointer value */
#define ZERO 0 /* Zero value */
#define EOF (-1) /* EOF Value */
#define TRUE (1) /* Function TRUE value */
#define FALSE (0) /* Function FALSE value */
/*************************** end of portab.h ********************************/
 FALSE (0) / Function FALSE value */
/*************************** end of portab.h ********************************/
 FALSE (0) /

Binary file not shown.

View File

@@ -0,0 +1,620 @@
/************************************************/
/* */
/* Usual filename: SID03.C */
/* Remarks: Second C module for SID68K */
/* Author: Timothy M. Benson */
/* Control: 19 MAY 83 16:52 (TMB) */
/* */
/************************************************/
#include "lgcdef.h"
#include "cputype.h"
#include "siddef.h"
#include "ddtinc.h"
#include "stdio.h"
#include "bdosfunc.h"
#include "disas.h"
gocmd(cx,statep,nulist) /* begin executing (optional breakpoints) */
char *cx;
struct cpustate *statep;
int **nulist;
{
extern U16 pkawnt[HMPPTS];
extern U16 *plocus[HMPPTS];
extern U16 ancien[HMPPTS];
extern int minus; /* 1 => no intermediate display */
int nbp;
long brkpt[MAXBP];
short brkwd[MAXBP];
long newpc;
long x;
int i;
short itsapp; /* 1 => ILLEGAL identified as pass point */
short mor; /* 1 => nonzero pass count, so GO again */
union asis BEGIN
long i32;
char *p8;
int *p16;
END strand; /* General purpose pointer */
int jetsam; /* Place to save word after system call */
deblank(&cx);
newpc = statep->pc;
if (gethex(&cx, &x)) newpc = x;
nbp = 0;
while ( GETSEP ) {
if (nbp >= MAXBP) {bad(); return;}
else { if (gethex(&cx,&x)) brkpt[nbp++]=x;
else {bad(); return;}
}
}
if ( ! nomore(cx) ) {bad(); return(0);}
statep->pc = newpc;
/* Execute one instruction */
if (STEP(statep)) return; /* exit if error */
/* Repeatedly set up pass points, break points, GO, restore */
/* after break, restore after pass, process pass point if */
/* applicable, continuing until pass point with count of one */
/* is encountered or until break point is encountered. */
for (mor = 1; mor and NOT keyhit();) BEGIN
stick(); /* Set up pass points */
for (i=0; i<nbp; i++) {
/* Set break points, saving previous contents. */
brkwd[i]=(brkpt[i])->memw;
brkpt[i]->memw = ILLEGAL;
}
GO(statep);
/* Restore previous contents at break points. */
for (i=0; i<nbp; i++) brkpt[i]->memw = brkwd[i];
yank(); /* Restore original contents at pass points. */
newpc = statep AT pc;
/* Determine if pass point */
for(i=0,itsapp=0; i LT HMPPTS and NOT itsapp; i++) BLOCK
strand.p16 = plocus[i];
If pkawnt[i] and strand.i32 EQ newpc then begin
itsapp = 1;
i--;
end
UNBLOCK
strand.i32 = newpc;
If *strand.p16 EQ ILLEGAL then BLOCK
showstate(statep);
stout("\nEncountered the ILLEGAL instruction\n");
goto trotz;
UNBLOCK
If itsapp then BLOCK
If pkawnt[i] EQ (U16) 1 or NOT minus then begin
shopas(i);
showstate(statep);
end
If ancien[i] NE BDOSCALL and ancien[i] NE BIOSCALL
then STEP(statep);
else begin /* Execute system call normally */
strand.i32 = newpc + 2;
jetsam = *strand.p16;
*strand.p16 = ILLEGAL;
GO(statep);
*strand.p16 = jetsam;
end
newpc = statep AT pc;
If pkawnt[i] GT (U16) 1 then --pkawnt[i];
otherwise begin
mor = 0;
showstate(statep);
end
UNBLOCK
otherwise BLOCK
mor = 0;
showstate(statep);
UNBLOCK
END
trotz:
*nulist = statep AT pc;
} /* end of go command */
/************************************************/
/* H alone: Spill symbol table */
/* Ha format: Print hex, ASCII, symbols */
/* Ha,b format: Do arithmetic */
/************************************************/
hexmath(cx)
char *cx;
{
extern struct lmhedr *caput;
extern int omega;
extern int scope;
long a, b;
deblank(&cx);
If nomore(cx) then BEGIN
If omega GE 0 then deluge(caput AT sump,omega);
else stout("\nNo symbols\n");
END
otherwise BEGIN
If gethex(&cx,&a) and nomore(cx) then BLOCK
putchar('\n');
puthexl(a);
putchar(' ');
If qotbyt(a) then putchar(' ');
spell(a,caput AT sump,scope,'b','h');
putchar('\n');
UNBLOCK
else If GETSEP && gethex(&cx,&b) && nomore(cx) then BLOCK
putchar('\n');
puthexl(a+b);
putchar(' ');
puthexl(a-b);
putchar('\n');
UNBLOCK
else bad();
END
}
incomtl(cx, valuep)
char *cx;
struct value *valuep;
{ /* process command tail */
register char *p;
register char *q;
register char nc;
register struct basepage *bpp;
if ( (valuep->kind) != 1 ) {bad(); return;} /* no pgm loaded */
bpp = valuep->bpa;
p = cx + 1;
q = &(bpp->comtail[1]);
nc = 0;
while (*p) { *q++ = *p++; nc += 1;}
*q = *p;
bpp->comtail[0] = nc;
if ( parse(&cx, &(bpp->fcb1), " ") && GETSEP )
parse(&cx, &(bpp->fcb2), " ");
}
disasm(cx,dap)
char *cx;
char **dap;
{ /* display memory in assembly format */
extern struct lmhedr *caput;
extern int scope;
char *s; /* start address */
char *f; /* end address */
register short int deflt;
register short int nl;
/* parse command and extract parameters */
deblank(&cx);
if ( ! gethex(&cx, &s) ) { /* get start address */
if (nomore(cx)) s = *dap; /* or use default */
else {bad(); return(0);} /* junk on the line */
}
if ( s & 1) { bad(); return(0);} /* must use even address */
if ( GETSEP ) { /* get end address */
if ( gethex(&cx, &f) ) deflt=0; /* got it */
else { bad(); return(0); }
}
else { f = s; deflt = 1; } /* not there, use def */
if((!nomore(cx)) || (s>f)) {bad(); return(0);} /* junk or nonsense */
/* now do the display */
nl = 0;
while ( (s<=f) || (deflt && (nl<12)) ) {
if ( keyhit() ) return;
If caput then nl INCBY
spell((U32) s,caput AT sump,scope,'m','v');
putchar(' ');
putchar(' ');
puthexl(s); putchar('\t');
dot = s;
pinstr();
putchar('\n');
s += dotinc;
nl++;
*dap = s;
} /* end of loop through instructions */
} /* end disassembly */
movemem(cx)
char *cx;
{ /* move memory block */
char *s; /* start address */
char *f; /* end address */
char *d; /* destination address */
/* parse command and extract parameters */
deblank(&cx);
if ( gethex(&cx, &s) ); /* get start address */
else {bad(); return(0);} /* not there, error */
if ( GETSEP && gethex(&cx, &f) ); /* get end address */
else { bad(); return(0); } /* not there, error */
if ( GETSEP && gethex(&cx, &d) ); /* get dest address */
else { bad(); return(0); }
if ((!nomore(cx)) || (s>f) ) /* test for junk or nonsense */
{ bad(); return(0); }
/* now do the moving */
for ( ; s <= f; s++, d++ ) d->memb = s->memb;
} /* end of movemem */
readfl(cx, basep, valuep, dap)
char *cx;
struct basepage *basep;
struct value *valuep;
char **dap;
{ /* read a file into memory */
struct fcb fcb1;
long lotpa;
long hitpa;
long curdma;
int endofile;
deblank(&cx);
if ( parse(&cx, &fcb1, " ") && nomore(cx))
{
if ( (BDOS(OPEN, &fcb1) & 0xffL) == 0xffL) /* open failed */
{
stout("Cannot open file\n");
return;
}
fcb1.cr = 0;
lotpa = basep->lowtpa;
hitpa = basep;
curdma = lotpa;
endofile = 0;
while ( (! endofile) && (curdma+128 <= hitpa) )
{
/* read a sector */
BDOS(SETDMA, curdma);
endofile = (BDOS(READSEQ, &fcb1) & 0xffL);
curdma += 128;
}
if ( ! endofile ) stout("\nFile too big -- read truncated.\n");
valuep->kind = 2;
valuep->textbase = lotpa;
valuep->textlen = curdma - lotpa - 128;
showvals(valuep);
*dap = lotpa;
}
else bad(); /* parsing error */
}
setmem(cx)
char *cx;
{
/* set memory */
register short int format; /* 1=byte, 2=word, 4=long word */
char *s; /* start address */
long v; /* value to stuff into memory */
char buf[BUFLEN]; /* input buffer */
char *bx; /* points into buf */
short int nc; /* num of hex digits input */
/* parse command and extract parameters */
format = getform(&cx);
if ( gethex(&cx, &s) ); /* get start address */
else {bad(); return(0);} /* not there, error */
if ( (format != 1) && (s & 1) ) /* must be even address, error */
{bad(); return(0);}
if (!nomore(cx)) { bad(); return(0); } /* test for junk */
/* now do the stuffing */
for ( ; ; s += format ) {
puthexl(s); putchar(' ');
switch ( format ) {
case 1: puthexb(s->memb);
break;
case 2: puthexw(s->memw);
break;
case 4: puthexl(s->meml);
break;
} /* end of switch */
putchar(' ');
*buf = BUFLEN - 2;
BDOS ( READBUF, buf );
putchar('\n');
buf[2+(nc=buf[1])] = 0;
if ( nc > 0 ) {
if ( buf[2] == '.' ) {return(0);}
for ( bx = &buf[1] ; *++bx ; ) *bx = toupper(*bx) ;
bx = &buf[1];
if ( gethex( &bx, &v ) );
else { bad(); return(0); }
while ( (*++bx) == 0x20 ) ; /* skip blanks */
if ( (*bx != 0) || /* test for bad input */
( (format == 1) && ((v>255L) || (v<0)) ) ||
( (format == 2) && ((v>65535L) || (v<0)) ) )
{ bad(); return(0); }
/* stuff the value */
switch ( format ) {
case 1 : s->memb = (char)v ;
if ( (s->memb ^ v) & 0x0ffL ) badram(s);
break;
case 2 : s->memw = (short int)v ;
if ( (s->memw ^ v) & 0x0ffffL ) badram(s);
break;
case 4 : s->meml = (long)v ;
if ( s->meml ^ v ) badram(s);
break;
} /* end of switch */
} /* end of nc > 0 */
} /* end of for */
} /* end of setmem */
trace(cx, statep, dap, tr)
char *cx;
struct cpustate *statep;
char **dap;
int tr;
{ /* trace program execution for n steps */
extern U16 pkawnt[HMPPTS];
extern U16 *plocus[HMPPTS];
extern U16 ancien[HMPPTS];
extern int minus; /* 1 => no intermediate display */
extern int omega; /* If negative, SID thinks no symbols */
int iota; /* Place to keep true value of "omega" */
/* while kidding oneself */
short itsapp; /* 1 => ILLEGAL identified as pass point */
union asis32 BEGIN
long i32;
char *p8;
U16 *p16;
END strand; /* General purpose pointer */
/**temp** Watch this: "strand" declared "*strand" elsewhere and */
/**temp** seems to work. Not sure why it works there, so it may */
/**temp** not work here. */
int jetsam; /* Place to save word after system call */
long nsteps;
register int underw; /* 1 => trace without call */
int oxbow; /* 0 => trace; otherwise it = length */
register int inst;
register long addr;
int jt; /* General purpose loop index */
short mor; /* 1 => not finished with GO */
int kt; /* Loop index for GO */
int steperr; /* set if an error exception occurs during step */
iota = omega; /* Save true value of "omega" */
deblank(&cx);
underw = vecina(&cx,'W');
if ( ! gethex(&cx, &nsteps)) nsteps = 1;
if ( ! nomore(cx) ) {bad(); return;}
/* Warning: Let there be no explicit returns here to end */
/* of function, lest symbols be accidentally zapped. */
If tr and minus then omega = -1;
while(nsteps--) {
inst = (addr = (statep->pc))->memw;
If inst EQ ILLEGAL then BEGIN
showstate(statep);
stout("\nEncountered the ILLEGAL instruction\n");
goto reject;
END
/* GO thru traps, ignoring pass points */
If (inst & 0xFFF0) EQ 0x4E40 then BEGIN
inst = (addr INCBY 2) AT memw;
addr AT memw = ILLEGAL;
GO(statep);
addr AT memw = inst;
goto refuse;
END
If underw and ((inst & 0xFF00) EQ 0x6100
or (inst & 0xFFC0) EQ 0x4E80) then BEGIN
If NOT (inst & 0x00FF) then oxbow = 4; /* Long BSR */
else If (inst & 0xFF00) EQ 0x6100 then oxbow = 2;
/* Short BSR */
else BLOCK /* JSR */
inst ANDWITH 0x003F;
If inst GE 0x0038 then begin
If inst EQ 0x0039 then oxbow = 6;
otherwise oxbow = 4;
end
else begin
inst ANDWITH 0x0038;
If inst EQ 0x0010 then oxbow = 2;
otherwise oxbow = 4;
end
UNBLOCK
END
otherwise oxbow = 0;
strand.i32 = addr;
for(jt=0,itsapp=0;jt LT HMPPTS and NOT itsapp;jt++)
If pkawnt[jt] and strand.p16 EQ plocus[jt] then BEGIN
itsapp = 1;
jt--;
END
If itsapp then BEGIN
If pkawnt[jt] GT (U16) 1 then --pkawnt[jt];
otherwise nsteps = 0;
If NOT nsteps or NOT tr and NOT minus then BLOCK
shopas(jt);
showstate(statep);
UNBLOCK
END
If oxbow then BEGIN
inst = (addr INCBY oxbow) AT memw;
addr AT memw = ILLEGAL;
steperr = STEP(statep);
for (mor=1;mor;) BLOCK
stick();
GO(statep);
yank();
If (strand.i32 = statep AT pc) EQ addr then mor = 0;
otherwise begin
for(kt=0,itsapp=0;kt LT HMPPTS and NOT itsapp;kt++)
If pkawnt[kt] and strand.p16 EQ plocus[kt] then {
itsapp = 1;
kt--;
}
If itsapp and pkawnt[kt] GT (U16) 1 then --pkawnt[kt];
else {mor = 0; nsteps = 0;}
If *strand.p16 EQ ILLEGAL then {
showstate(statep);
stout("\nEncountered the ILLEGAL instruction\n");
addr AT memw = inst;
goto reject;
}
If NOT nsteps or NOT tr and NOT minus then {
shopas(kt);
showstate(statep);
}
steperr = STEP(statep);
If keyhit() then {mor = 0; nsteps = 0; tr = 0;}
end
UNBLOCK
addr AT memw = inst;
END
otherwise steperr = STEP(statep);
refuse:
if (tr) showstate(statep);
if ( keyhit() || steperr ) nsteps = 0;
}
if ( ! tr ) showstate(statep);
reject:
*dap = statep->pc;
omega = iota; /* Reenable symbols. */
}
vcmd(cx, valuep)
char *cx;
struct value *valuep;
{/* display start and end of stuff loaded with R or E commands */
if (nomore(cx)) showvals(valuep);
otherwise bad();
}
wrtfile(cx, valuep)
char *cx;
struct value *valuep;
{ /* write memory contents to disk */
struct fcb fcb1;
long s;
long f;
deblank(&cx);
if ( ! parse(&cx, &fcb1, " ") ) {bad(); return;}
if ( nomore(cx) ) /* use default start and end */
{
if ( (valuep->kind) != 2 ) {bad(); return;}
s = valuep->textbase;
f = s + valuep->textlen - 1;
}
else /* try to parse s & f values */
{
if ( ( ! GETSEP ) || ( ! gethex(&cx, &s) ) ||
( ! GETSEP ) || ( ! gethex(&cx, &f) ) ||
( ! nomore(cx) ) ) {bad(); return;}
}
BDOS(DELETE, &fcb1);
if ( (BDOS(MAKEFILE, &fcb1) & 0xffL) == 0xffL )
{
stout("Cannot create file.\n");
return;
}
fcb1.cr = 0;
while ( s <= f )
{
BDOS(SETDMA, s);
if ( BDOS(WRITSEQ, &fcb1) & 0xffL )
{
stout("File write error.\n");
s = f + 1;
}
s += 128;
}
BDOS(CLOSE, &fcb1);
}
int dummy(s)
char *s;
{
stout("\n\nUnimplemented Function: ");
stout(s);
stout("\n\n");
}
shopas(jsh) /* Display pass-point data */
int jsh;
{
extern U16 pkawnt[HMPPTS];
extern U16 *plocus[HMPPTS];
putchar('\n');
puthexw(pkawnt[jsh]);
stout(" PASS ");
puthexl(plocus[jsh]);
putchar('\n');
}
stick() /* Set pass points, saving original contents. */
{
extern U16 pkawnt[HMPPTS];
extern U16 *plocus[HMPPTS];
extern U16 ancien[HMPPTS];
int kst;
for (kst=0; kst LT HMPPTS; kst++)
If pkawnt[kst] then BLOCK
ancien[kst] = *plocus[kst];
*plocus[kst] = ILLEGAL;
UNBLOCK
}
yank() /* Restore original contents at pass points. */
{
extern U16 pkawnt[HMPPTS];
extern U16 *plocus[HMPPTS];
extern U16 ancien[HMPPTS];
int kya;
for (kya=0; kya LT HMPPTS; kya++)
If pkawnt[kya] then *plocus[kya] = ancien[kya];
}(kya=0; kya LT HMPPTS; kya++)
If pkawnt[kya] then *plocus[kya] = ancien[kya];
}

View File

@@ -0,0 +1,614 @@
/************************************************/
/* */
/* Usual filename: SID04.C */
/* Remarks: Third C module for SID68k */
/* Author: Timothy M. Benson */
/* Control: 9 MAY 83 13:59 (TMB) */
/* */
/************************************************/
#include "lgcdef.h"
#include "cputype.h"
#include "siddef.h"
#include "ddtinc.h"
#include "stdio.h"
#include "bdosfunc.h"
#include "disas.h"
/********************************************************************
* ISSPACE character
*
* Return TRUE if the character is a whitespace character
********************************************************************/
isspace(ch)
int ch;
{
return(ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
}
putchar(x)
register char x;
{
BDOS(CONOUT, (long)x);
if (x == '\n') BDOS(CONOUT, (long)'\r');
}
int stout(s) /* write a string */
register char *s;
{
register int nc;
nc = 0;
while ( *s ) { putchar( *s++ ); nc++; }
return(nc);
}
/************************************************/
/* Starting at byte after **cpp get longest */
/* possible hex number from string or evaluate */
/* longest possible symbol. */
/* Fill in *np with value found. Return # of */
/* digits if hex, 8 if symbol, or 0 if invalid. */
/* Leave **cpp pointing to next position after */
/* chars processed. */
/************************************************/
gethex(cpp,np)
char **cpp;
long *np;
{
/**temp** This function extensively modified for SID */
extern struct lmhedr *caput;
extern int omega;
extern int nomo;
union ambig BLOCK /* Machine dependent */
long all32;
int last16[2];
char last8[4];
UNBLOCK triad;
register char *cp;
U16 *d16; /* For '@' values */
U32 *d32; /* For '!' values */
char *deixis; /* For '=' values */
long n;
register int nd;
char px; /* . = @ ! */
register char qu;
px = *(*cpp + 1);
If px EQ '.' or px EQ '=' or px EQ '@' or px EQ '!' then BEGIN
cp = ++*cpp; /* Locate prefix */
++*cpp; /* Skip prefix */
while((qu = *++cp) and qu NE ' ' and qu NE ',' and qu NE '+'
and qu NE '-' and qu NE '/' and qu NE '*')
; /* Find char after supposed name */
If nd = 8 * (omega GE 0
and (1 EQ indica((int)(cp - *cpp),*cpp
,caput AT sump,'B',&n,&nomo))) then
If px NE '=' and px NE '.' and n AND 1L then nd = 0;
otherwise BLOCK
triad.all32 = 0;
switch (px) begin
case '.':
triad.all32 = n;
break;
case '=':
deixis = n;
triad.last8[3] = *deixis;
break;
case '@':
d16 = n;
triad.last16[1] = *d16;
break;
case '!':
d32 = n;
triad.all32 = *d32;
break;
end
n = triad.all32;
UNBLOCK
END
otherwise for (n=0, nd=0, cp = *cpp;
ishex(*++cp);
nd++, n=(n<<4)+hexval(*cp));
*cpp = --cp;
*np = n;
return(nd);
}
int ishex ( c )
register char c;
{
return ( ( ('0'<=c) && (c<='9') ) || ( ('A'<=c) && (c<='F') ) );
}
int hexval ( c )
register char c;
{
if ( ('0'<=c) && (c<='9') ) return ( c-'0');
else return ( 10 + c - 'A' );
}
char hexchar(n)
register char n;
{
return ( n<10 ? '0'+n : 'A'+n-10 );
}
int puthex(n, i, zs)
register long n;
register int i;
register int zs;
{
register char d;
while ( i >= 4 )
{
i -= 4;
d = hexchar( (char)((n>>i) & 0xf) );
if ( d != '0' ) zs = 0;
if ( (! zs) || (! i) ) putchar(d);
}
}
int puthexl(n) /* write a long integer in hex */
long n;
{
puthex(n, 32, 0);
}
int puthexw(n) /* write an integer in hex */
short int n;
{
puthex((long)n, 16, 0);
}
puthexb(n) /* write a byte in hex */
char n;
{
puthex((long)n, 8, 0);
}
int putbyte(c) /* write an ascii byte. if not printable, write '.' */
register char c;
{
char d[2];
d[1] = 0;
d[0] = ( ( (c < 0x20) || (c > 0x7E) ) ? '.' : c );
stout(d);
}
bad()
{
stout("?\n");
}
badram(a)
long a;
{
stout("Bad or non-existent RAM at ");
puthexl(a);
putchar('\n');
}
nomore(cx)
char *cx;
{
++cx;
while (*cx)
{
if (!isspace(*cx)) return(0);
else ++cx;
}
return(1);
}
getsep(cxp)
register char **cxp;
{
register char *cx;
cx = (*cxp) + 1;
if ((*cx != ' ') && (*cx != ',')) return(0);
while ( *cx == ' ' ) ++cx;
if ( ! *cx ) return(0);
if ( *cx != ',' ) {*cxp = --cx; return(1);}
++cx;
while ( *cx == ' ' ) ++cx;
*cxp = --cx;
return(1);
}
deblank(cxp)
register char **cxp;
{
++*cxp;
while ( isspace(**cxp) ) ++*cxp;
--*cxp;
}
short int getform(cxp)
register char **cxp;
{
register char *cx;
register short int format;
cx = *cxp;
if ( *++cx == 'W' ) format = 2;
else if ( *cx == 'L' ) format = 4;
else { format = 1; cx--; }
*cxp = cx;
deblank(cxp);
return(format);
}
parse(cxp, fcbp, dtp)
register char **cxp;
struct fcb *fcbp;
char *dtp;
{
/* parse a filename into an fcb */
register char *cx;
register char c;
register int n;
fcbp->ex = 0;
fcbp->cr = 0;
cx = *cxp;
c = *++cx;
if ( ! (isalpha(c) || isdigit(c) || iswild(c))) return(0);
if ( *(cx+1) == ':' ) {fcbp->dr = c - 'A' + 1; cx += 2; }
else fcbp->dr = 0;
n = 0;
c = *cx;
while (isalpha(c) || isdigit(c) || iswild(c)) {
if ( n >= 8 ) return(0);
if(c == '*')
{
while(n < 8)
fcbp->fn[n++] = '?';
c = *++cx;
break;
}
fcbp->fn[n++] = c;
c = *++cx;
}
while ( n < 8 ) fcbp->fn[n++] = ' ';
for (n = 0; n < 3; ++n) {
if (*dtp) fcbp->t[n] = *dtp++;
else fcbp->t[n] = ' ';
}
if (*cx != '.') {*cxp = --cx; return(1);}
n = 0;
c = *++cx;
while ( isalpha(c) || isdigit(c) || iswild(c)) {
if ( n >= 3 ) return(0);
if(c == '*')
{
while(n < 3)
fcbp->t[n++] = '?';
c = *++cx;
break;
}
fcbp->t[n] = c;
++n;
c = *++cx;
}
while ( n < 3 ) fcbp->t[n++] = ' ';
*cxp = --cx;
return(1);
} /* end of parse fcb */
int keyhit()
{
if ( BDOS(CONSTAT, 0L) & 0xFFFFL ) {
BDOS(CONIN, 0L);
return(1);
}
else return(0);
}
showvals(vp)
register struct value *vp;
{
register int i, j;
register long * lp;
switch ( vp->kind )
{
case 0: stout("\nERROR, no program or file loaded.\n");
break;
case 1: /* do program vals */
for ( i = 0; i < 2; ++i )
{
lp = &(vp->textbase);
lp += i;
for (j = 0; j < 3; ++j)
{
switch ( j )
{
case 0: stout("text "); break;
case 1: stout("data "); break;
case 2: stout("bss "); break;
}
switch ( i )
{
case 0: stout(" base "); break;
case 1: stout(" length"); break;
}
stout(" = ");
puthexl(*lp);
lp += 2;
stout(" ");
}
putchar('\n');
}
stout("base page address = ");
puthexl(vp->bpa);
stout(" initial stack pointer = ");
puthexl(vp->initstk);
break; /* end of program values */
case 2: /* do file values */
stout("Start = ");
puthexl(vp->textbase);
stout(" End = ");
puthexl((vp->textbase)+(vp->textlen)-1L);
break;
}
putchar('\n');
} /* end of showvals */
/**/
/****************************************************************/
/* */
/* Examine/Alter CPU Registers */
/* */
/****************************************************************/
examine(cx, statep)
char *cx;
struct cpustate *statep;
{
if (nomore(cx)) showstate(statep);
else if (cmp("PC",cx)) pregl("PC", &(statep->pc));
else if (cmp("USP",cx)) { if (pregl("USP",&(statep->usp)) &&
((statep->status & SUPER) == 0 ))
statep->areg[7] = statep->usp;
}
else if (cmp("SSP",cx)) { if (pregl("SSP",&(statep->ssp)) &&
(statep->status & SUPER) )
statep->areg[7] = statep->ssp;
}
else if (cmp("ST", cx)) { pregw("ST",&(statep->status) );
if ( statep->status & SUPER) statep->areg[7] = statep->ssp;
else statep->areg[7] = statep->usp;
}
#ifdef MC68010
else if (cmp("VBR",cx)) pregl("VBR", &(statep->vbr));
else if (cmp("SFC",cx)) pregn("SFC", &(statep->sfc));
else if (cmp("DFC",cx)) pregn("DFC", &(statep->dfc));
#endif
else if (*++cx == 'D') pdareg('D', cx, statep->dreg);
else if (*cx == 'A') pdareg('A', cx, statep->areg);
else bad();
if ( statep->status & SUPER) statep->ssp = statep->areg[7];
else statep->usp = statep->areg[7];
}
showstate(statep)
register struct cpustate *statep;
{
/**temp** Next several lines added recently */
extern int scope;
extern struct lmhedr *caput;
/**temp** End of added stuff */
register short int status;
stout("PC="); puthexl(statep->pc); putchar(' ');
stout("USP="); puthexl(statep->usp); putchar(' ');
stout("SSP="); puthexl(statep->ssp); putchar(' ');
stout("ST="); puthexw(status = statep->status);
stout("=>");
if (status & TRACE) stout("TR ");
if (status & SUPER) stout("SUP ");
stout("IM="); putchar(((status & INTMSK)>>8)+'0');
if (status & EXTEND) stout(" EXT");
if (status & NEG) stout(" NEG");
if (status & ZERO) stout(" ZER");
if (status & OFLOW) stout(" OFL");
if (status & CARRY) stout(" CRY");
putchar('\n');
#ifdef MC68010
stout("VBR="); puthexl(statep->vbr); putchar(' ');
stout("SFC="); puthex(statep->sfc, 4, 0); putchar(' ');
stout("DFC="); puthex(statep->dfc, 4, 0); putchar('\n');
#endif
preglrow('D', statep->dreg); /* D registers */
preglrow('A', statep->areg); /* A registers */
dot = statep -> pc;
spell(statep AT pc,caput AT sump,scope,'m','h');
/* Label, if any */
pinstr(); /* disassembled instruction */
putchar('\n');
}
pdareg(da, cx, rp) /* print data or address register contents */
char da;
register char *cx;
long *rp;
{
char str[3];
if ( ('0' <= *++cx) && (*cx <= '7') && nomore(cx) ) {
str[0] = da;
str[1] = *cx;
str[2] = 0;
pregl(str, rp + *cx - '0');
}
else bad();
}
pregl(rname, regp) /* print register contents as long */
char *rname;
long *regp;
{
return(preg(rname, regp, 4));
}
pregn(rname, regp)
char *rname;
long *regp;
{
return(preg(rname, regp, 0));
}
pregw(rname, regp) /* print register contents as word */
char *rname;
long *regp;
{
return( preg(rname, regp, 2) );
}
preg(rname, regp, size) /* print register contents */
register char *rname;
register long *regp;
register int size;
{
char buf[BUFLEN];
register short int nc;
long int newval;
char *bp;
register int modify;
modify = 0;
stout(rname);
putchar('=');
switch(size)
{
case 0 : puthex(regp->meml, 4, 0);
break;
case 1 : puthexb(regp->memb);
break;
case 2 : puthexw(regp->memw);
break;
case 4 : puthexl(regp->meml);
break;
}
putchar(' ');
*buf = BUFLEN-2;
BDOS(READBUF, buf);
putchar('\n');
if ((nc=buf[1])>0) {
buf[nc+2]=0;
bp = buf + 1;
while (*++bp) *bp = toupper(*bp);
bp = buf + 1;
if (gethex(&bp, &newval) && nomore(bp)) {
switch(size)
{
case 0 : regp->meml = newval & 0xffL;
break;
case 1 : regp->memb = (char)(newval & 0xffL);
break;
case 2 : regp->memw = (int)(newval & 0xffffL);
break;
case 4 : regp->meml = newval;
break;
}
modify = 1;
}
else if ( ! nomore(buf+1) ) bad();
}
return(modify);
}
preglrow(ch, rowp)
char ch;
long *rowp;
{
register int n;
putchar(ch);
putchar(' ');
for (n=0; n<8; n++) {
putchar(' ');
puthexl(*rowp++);
if (n==3) putchar(' ');
}
putchar('\n');
}
tryflags(cx, statep)
register char *cx;
register struct cpustate *statep;
{
bad();
}
cmp(str, ctl)
register char *str;
register char *ctl;
{
while (*str && (*str++ == *++ctl)) ;
if ( ( ! *str) && nomore(ctl) ) return(1);
else return(0);
}
( ( ! *str) && nomore(ctl) ) return(1);
else return(0);
}


File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,582 @@
/********************************************************/
/* */
/* Usual filename: SID68K.C */
/* Remarks: Main C module for SID68K */
/* Author: Timothy M. Benson */
/* Control: 19 MAY 83 18:01 (TMB) */
/* */
/********************************************************/
#include "lgcdef.h"
#include "cputype.h"
#include "siddef.h"
#include "ddtinc.h"
#include "stdio.h"
#include "bdosfunc.h"
#include "disas.h"
typedef long (*PFL)();
struct lmhedr *caput = NULL; /* Symbol table--known globally */
long HMSYMS;
long inhalt; /* Possible symbol value discovered during dissasembly */
int nomo = -1; /* Index to last symbol found by name */
int omega = -1; /* Index to last symbol in symbol table:*/
/* Negative value => no symbols */
char ref; /* Symbols for disassembly: */
/* '\0' => none */
/* 'm' => text, data, or bss */
/**temp** Setting of 'a' not currently in use */
/* 'a' => other */
int scope = 0; /* If zero, find all; otherwise find first */
int minus; /* 1 => "-" in effect; 0 => "-" not in effect */
U16 pkawnt[HMPPTS]; /* Pass counts (0 => not in use) */
U16 *plocus[HMPPTS]; /* Values of pass points */
U16 ancien[HMPPTS]; /* Previous contents at pass point */
struct cpustate state; /* state of user program regs */
main(bpptr)
struct basepage *bpptr;
{
char combuf[BUFLEN];
char *cx;
char *dispaddr; /* current display address */
char *listaddr; /* current disassembly addr*/
struct value curvals; /* values relating to current file or pgm */
register int i; /* workhorse integer */
/* phony machine state initialization */
for (i=0; i<8; i++) {state.dreg[i]=0L; state.areg[i]=0L;}
state.pc = 0x0;
state.usp = 0x00001000L;
state.areg[7]=state.usp;
state.ssp = GETSSP();
state.status = 0x0000;
#ifdef MC68010
state.vbr = GETVBR();
state.sfc = GETSFC();
state.dfc = GETDFC();
#endif
dispaddr = 0;
listaddr = 0;
curvals.kind = 0; /* no current file or program */
zappas(); /* Purge pass points */
init(bpptr, &state, &curvals, &dispaddr, &listaddr, &bpptr);
while ( 1 ) {
while ( ! (cx = readcom(combuf)) );
If *cx EQ '-' then BEGIN
minus = 1;
++cx;
END
otherwise minus = 0;
switch ( *cx ) {
/* one case for each possible command */
case 'C':
callrt(cx);
break;
case 'D' : display(cx, &dispaddr);
break;
case 'E' : ecmd(cx, bpptr, &state, &curvals,
&dispaddr, &listaddr, &bpptr);
break;
case 'F' : fillmem(cx);
break;
case 'G' : gocmd(cx,&state,&listaddr);
break;
case 'H' : hexmath(cx);
break;
case 'I' : incomtl(cx, &curvals);
break;
case 'K' : koax(cx);
break;
case 'L' : disasm(cx, &listaddr);
break;
case 'M' : movemem(cx);
break;
case 'P' : passpt(cx);
break;
case 'R' : readfl(cx, bpptr, &curvals, &dispaddr);
break;
case 'S' : setmem(cx);
break;
case 'T' : trace(cx, &state, &listaddr, (int)1);
break;
case 'U' : trace(cx, &state, &listaddr, (int)0);
break;
case 'V' : vcmd(cx, &curvals);
break;
case 'W' : wrtfile(cx, &curvals);
break;
case 'X' : examine(cx, &state);
break;
default : stout("Unknown Command\n\n");
break;
}; /* end of switch on comx */
}; /* end of while loop */
} /* end of function main */
init(basep, statep, valuep, dap, lap, bppa)
struct basepage *basep;
struct cpustate *statep;
struct value *valuep;
char **dap;
char **lap;
long *bppa;
{
/* if program file argument, then load it */
/* set up trap vectors */
/* initialize tables */
EXINIT(); /* Initialize Exception handlers */
stout("\n**************************************************\n");
stout("DDT-68K 3/19/84 Version 1.2\n");
stout("Serial #XXXX-0000-654321 All Rights Reserved\n");
stout("Copyright 1982,1983,1984 Digital Research Inc.\n");
stout("**************************************************\n\n");
caput = (long)basep - (long)(XTRASYM*sizeof(struct lmhedr));
if ((long)caput < basep->lowtpa) caput = NULL;
HMSYMS = 0;
if (basep->fcb1.fn[0] != ' ')
loadpgm(&(basep->fcb1),basep,statep,valuep,dap,lap,bppa);
}
char *readcom(buf) /* read one command line, return command type */
register char *buf;
{
register char *cx;
register short int i,nc;
do {
stout("\r\r-"); /* prompt */
*buf = BUFLEN-3;
BDOS(READBUF, buf); /* get command line */
putchar('\n');
} while ( ( nc=buf[1]) == 0 );
buf[2+nc] = 0;
for ( cx = &buf[2]; *cx; *cx=toupper(*cx), cx++);
for ( cx = &buf[2], i=0 ; iswhite(*cx) && (i<nc) ; cx++ , i++ );
return( (i==nc) ? NULL : cx );
}
clean()
{
/* restore trap vectors */
}
callrt(s)
char *s;
{
struct cpustate tstate;
int i;
long ret;
long n;
long p[10];
PFL rout;
char c;
if ( ! gethex(&s,&n) ) {
bad();
return(0);
}
for (i = 0; i < 10; i ++)
p[i] = i;
i = 0;
while ( (i < 10) && ( (getsep(&s)) && (gethex(&s,&p[i])) ) ) {
i++;
}
for (i = 0; i < 8; i++) {
tstate.areg[i] = state.areg[i];
tstate.dreg[i] = state.dreg[i];
}
tstate.pc = state.pc;
tstate.usp = state.usp;
tstate.ssp = state.ssp;
tstate.status = state.status;
rout = (PFL)n;
ret = (*rout)(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9]);
stout("Return value --> ");
hexlzs(ret);
stout("h\n");
for (i = 0; i < 8; i++) {
state.areg[i] = tstate.areg[i];
state.dreg[i] = tstate.dreg[i];
}
state.pc = tstate.pc;
state.usp = tstate.usp;
state.ssp = tstate.ssp;
state.status = tstate.status;
}
display(cx, dap)
char *cx;
char **dap;
{
/* display memory in hex and ascii */
short int format; /* 1=byte, 2=word, 4=long word */
char *s; /* start address */
char *f; /* end address */
char *i; /* working variable */
char *j; /* ditto */
short int c; /* column number */
/* parse command and extract parameters */
format = getform(&cx);
if (*++cx == '@') {
if ((*++cx >= '0') && (*cx <= '7')) {
s = state.areg[*cx - '0'];
f = s + ((11*16) - 1);
}
else {
bad();
return(0);
}
}
else {
cx--;
if ( ! gethex(&cx, &s) ) { /* get start address */
if ( nomore(cx) ) s = *dap; /* or use default */
else { bad(); return(0); } /* junk on the line */
}
if ( (format != 1) && (s & 1) ) s += 1; /* force even */
if ( GETSEP ) {if ( ! gethex(&cx, &f) ) {bad(); return;} }
else f = s + (11*16-1); /* not there, use def */
if ( ! nomore(cx) ) {bad(); return;} /* rest of line must be empty */
}
/* now do the display */
f = f - format + 1; /* first byte of last chunk to print */
for ( ; s <= f ; s += 16 ) { /* one line per pass */
if ( keyhit() ) return;
puthexl(s); putchar(' '); putchar(' '); c = 10;
for ( i=s, j=min(s+15,f);
i <= j;
i += format ) {
switch ( format ) {
case 1 : puthexb(i->memb);
break;
case 2 : puthexw(i->memw);
break;
case 4 : puthexl(i->meml);
break;
} /* end of switch */
putchar(' ');
c += (2*format+1);
} /* end of loop across line */
while ( c++ < 60 ) putchar(' ');
for ( i=s, j=min(s+15,f); i<=j ; i++ ) putbyte(*i);
putchar('\n');
} /* end of loop through lines */
*dap = f + format;
} /* end display */
ecmd(cx, basep, statep, valuep, dap, lap, bppa)
char *cx;
struct basepage *basep;
struct cpustate *statep;
struct value *valuep;
char **dap;
char **lap;
long *bppa;
{
/* Load the program named in the command */
struct fcb pgmfcb;
deblank(&cx);
if (parse(&cx, &pgmfcb, "68K") && nomore(cx))
loadpgm ( &pgmfcb, basep, statep, valuep, dap, lap, bppa);
else bad();
}
loadpgm(fcbp, basep, statep, valuep, dap, lap, bppa)
struct fcb *fcbp;
struct basepage *basep;
struct cpustate *statep;
struct value *valuep;
char **dap;
char **lap;
long *bppa;
{ /* load a program for execution */
extern int omega;
struct lpb pgmlpb;
int loaderr;
struct basepage *newbp;
long *stkptr;
int i;
char sector[128];
long stlen;
/* open program file */
while(1)
{
if ( (BDOS(OPEN, fcbp) & 0xffL) == 0x0FFL )
{
if(fcbp->t[0] != ' ')
{ /* open failed */
stout("Cannot open program file\n");
return;
}
else
{
fcbp->t[0] = '6';
fcbp->t[1] = '8';
fcbp->t[2] = 'K';
}
}
else
break;
}
/* Set up space for symbol table in top of TPA */
fcbp->cr = 0;
BDOS(SETDMA, sector);
if ( BDOS(READSEQ, fcbp) & 0xffL )
{
stout("Can not read program file.\n");
return;
}
fcbp->cr = 0;
stlen = (&sector[14])->meml;
HMSYMS = stlen / sizasym + (long)XTRASYM + 1L;
if(stlen) caput = (long)caput - (long)(stlen-128L-sizlmhdr);
if((long)caput < basep->lowtpa) {caput = NULL; HMSYMS = 0;}
/* set up lpb */
pgmlpb.fcbaddr = fcbp;
pgmlpb.tpabase = basep->lowtpa;
/* if ( stlen ) pgmlpb.tpatop = caput;
else pgmlpb.tpatop = basep; */
pgmlpb.tpatop = caput;
pgmlpb.flags = 0;
/* now do program load */
loaderr = (int)(BDOS(PGMLOAD, &pgmlpb) & 0x0FFFFL);
switch ( loaderr ) {
case 0: { /* successful */
newbp = pgmlpb.bpaddr;
valuep->kind = 1;
valuep->textbase = newbp->csstart;
valuep->textlen = newbp->cslen;
valuep->database = newbp->dsstart;
valuep->datalen = newbp->dslen;
valuep->bssbase = newbp->bsstart;
valuep->bsslen = newbp->bslen;
valuep->bpa = newbp;
valuep->initstk = pgmlpb.stkinit;
statep->pc = newbp->csstart;
stkptr = pgmlpb.stkinit;
(*--stkptr) = newbp;
(*--stkptr) = *--bppa;
statep->usp = stkptr;
statep->areg[7]= stkptr;
statep->status = 0;
*dap = newbp->csstart;
*lap = newbp->csstart;
newbp->fcb1.dr = 0;
newbp->fcb2.dr = 0;
for ( i = 0; i < 11; ++i) {
newbp->fcb1.fn[i] = ' ';
newbp->fcb2.fn[i] = ' ';
}
newbp->fcb1.cr = 0;
newbp->fcb2.cr = 0;
newbp->fcb1.ex = 0;
newbp->fcb2.ex = 0;
}
break; /* end case 0 -- success */
case 1: { stout("Insufficient memory or bad file header\n");
return;
}
break;
case 2: { stout("Read error\n");
return;
}
break;
case 3: { stout("Bad relocation bits\n");
return;
}
break;
default: { stout("Unknown program load error\n");
return;
}
break;
} /* end switch */
zappas(); /* Delete all pass points */
if(stlen) omega = simz(fcbp,valuep AT textbase); /*load symbol table*/
else {omega = -1; stout("No Symbols\n");}
showvals(valuep);
} /* end loadpgm */
fillmem(cx)
char *cx;
{
/* fill memory with constant */
register short int format; /* 1=byte, 2=word, 4=long word */
char *s; /* start address */
char *f; /* end address */
long v; /* value to stuff into memory */
/* parse command and extract parameters */
format = getform(&cx);
if ( gethex(&cx, &s) ); /* get start address */
else {bad(); return(0);} /* not there, error */
if ( (format != 1) && (s & 1) ) /* must be even address, error */
{bad(); return(0);}
if ( GETSEP && gethex(&cx, &f) ); /* get end address */
else { bad(); return(0); } /* not there, error */
if ( GETSEP && gethex(&cx, &v) ); /* get value to stuff */
else { bad(); return(0); }
if ( ! nomore(cx) ) {bad(); return;} /* rest of line must be empty */
if ((s>f) || /* test for junk or nonsense */
( (format == 1) && ((v > 255L) || (v < 0)) ) ||
( (format == 2) && ((v > 65535L) || (v < 0)) ) )
{ bad(); return(0); }
/* now do the stuffing */
for ( ; (s+format) <= (f+1); s += format )
{
switch ( format ) {
case 1 : s->memb = (char)v;
if ((s->memb ^ (char)v) & 0xFF) badram(s);
break;
case 2 : s->memw = (short int)v ;
if ((s->memw ^ (short int)v) & 0xFFFF) badram(s);
break;
case 4 : s->meml = (long)v ;
if ( s->meml != v ) badram(s);
break;
} /* end of switch */
} /* end of for */
} /* end of fillmem */
s);
break;
} /* end of switch */
} /* end of for */
} /* end of fillmem */


Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,573 @@
/********************************************************/
/* */
/* Usual filename: SIDFUN.C */
/* Remarks: Functions specific to DDT68K */
/* Author: Timothy M. Benson */
/* Control: 19 MAY 83 17:36 (TMB) */
/* */
/********************************************************/
#include "lgcdef.h"
#include "cputype.h"
#include "siddef.h"
#include "ddtinc.h"
#include "stdio.h"
#include "bdosfunc.h"
#include "disas.h"
/************************************************/
/* Load and initialize symbol table, returning */
/* int sized index to last valid symbol aut */
/* negative error code. */
/************************************************/
simz(fcbp,hwer)
struct fcb *fcbp;
long hwer;
{
extern struct lmhedr *caput;
extern int nomo;
U32 rano(); /* Returns second argument incremented by one */
struct asymbl *icon;
int goods; /* # symbol bytes in first symbol record */
int i;
int irate; /* Zero iff no input errors */
int junk; /* # bytes preceding symbols in first symbol record */
register long kount; /* Scratch loop counter */
char *oint; /* Scratch byte pointer */
U32 randy; /* Current random record number */
int zulu; /* Index to last symbol in current table */
int relocate; /* Logical -- whether or not file is relocatable */
randy = 0;
BDOS(SETDMA,caput);
rano(fcbp,&randy);
irate = BDOS(OPEN,fcbp) AND 0xFFFFFFFCL;
irate ORWITH (int) BDOS(READRND,fcbp);
caput AT tceps = hwer;
If caput AT lmkind EQ CONTIG then BEGIN
caput AT dceps = caput AT tceps;
caput AT dceps INCBY caput AT lmtlen;
caput AT bceps = caput AT dceps;
caput AT bceps INCBY caput AT lmdlen;
randy = 28; /* # bytes in contiguous header */
END
otherwise randy = 36; /* # bytes in noncontiguous header */
if(relocate = !*((unsigned *)((long)caput+0x1A)))
stout("File is relocatable\n");
If NOT(caput AT symlen) then BEGIN
stout("No symbols\n");
/**temp** Need to allot space for added symbols */
/**temp** Need to deallocate extra space */
nomo = -1;
return(-1);
END
randy INCBY caput AT lmtlen + caput AT lmdlen;
/* I.e., compute # bytes preceding symbols */
junk = randy % 128;
goods = 128 - junk;
randy /= 128;
oint = caput AT sump;
icon = oint; /* Save addr of symbol table. */
BDOS(SETDMA,icon);
randy = rano(fcbp,&randy);
irate ORWITH (int) BDOS(READRND,fcbp);
/* Move wanted info to head of array. */
for (i = 0; i LT goods; i++) *oint++ = *(oint + junk);
/* Now oint points to icon + goods. */
zulu = HMSYMS * sizeof(struct asymbl);
If caput AT symlen GT zulu then BEGIN
kount = (zulu - goods) / 128;
If (zulu - goods) % 128 then ++kount;
zulu = HMSYMS - 1;
END
otherwise BEGIN
kount = (caput AT symlen - goods) / 128;
If (caput AT symlen - goods) % 128 then ++kount;
zulu = caput AT symlen / sizeof(struct asymbl) - 1;
END
/**temp** May want to compute end of symbol table here */
/**temp** and/or deallocate unused storage */
while (kount-- GT 0) BEGIN
BDOS(SETDMA,oint);
randy = rano(fcbp,&randy);
If (i = BDOS(READRND,fcbp)) then
If i EQ 1 or i EQ 4 then kount = 0;
else irate ORWITH i;
oint INCBY 128;
END
If irate then BEGIN
stout("Symbol table disaster\n");
return(-1);
END
/**temp** When symbol table allocated dynamically, make */
/**temp** sure zulu still reflects subscript of */
/**temp** last symbol at this point in program */
If caput AT lmkind EQ CONTIG then
for(i = 0; i LE zulu; i++)
If (icon+i) AT symtyp IS SEGREF and relocate then
(icon+i) AT symval INCBY caput AT tceps;
/**temp** May later need different test for full symbol table */
If zulu GE HMSYMS - 1 then stout("Symbol table full\n");
return(zulu);
}
/************************************************/
/* Install random record number in fcb and */
/* return next higher random record number */
/************************************************/
U32 rano(fcbp,rand)
struct fcb *fcbp;
union slimy BLOCK
U32 recno;
char tail[4];
UNBLOCK *rand;
{
int i;
for (i = 0; i LE 2; i++)
fcbp AT r[i] = rand AT tail[i+1];
return(rand AT recno + 1);
}
deluge(tabula,zulu)
struct asymbl tabula[];
register int zulu;
{
register int i;
register int j;
register char litt;
register int reply;
U16 simbl;
for(i = 0, reply = 2; i LE zulu and reply; i++) BEGIN
putchar('\n');
puthexw(i);
putchar('(');
If (simbl = tabula[i].symtyp) IS TREL then putchar('T');
else If simbl IS DREL then putchar('D');
else If simbl IS BREL then putchar('B');
else putchar('A');
stout(")(");
If simbl IS GONE then putchar('H');
otherwise putchar('V');
stout("): ");
puthexl(tabula[i].symval);
stout(" = ");
/**temp** Call to kobold in next line may need parameters */
If simbl IS TLONG then kobold();
otherwise for(j = 0; j LT 8; j++)
If litt = tabula[i].namae[j] then putchar(litt);
else putchar(' ');
If reply EQ 2 then reply = 1;
otherwise If NOT (i % 10) then reply = pause();
END
putchar('\n');
}
kobold()
{
/* Will handle printing long symbols here; for now print message */
stout("** Long COBOL-style symbol **");
}
pause()
{
register char mor;
stout("\n Continue listing? (y/n)");
mor = getchar();
mor = toupper(mor);
putchar('\n');
return(mor NE 'N');
}
/****************************************************************/
/* For a given numerical value, find and print corresponding */
/* symbols in indicated table, with certain options. Return */
/* int number of symbols found. */
/****************************************************************/
spell(value,table,scope,class,orient)
U32 value;
struct asymbl table[];
int scope; /* If zero, then find all; otherwise find first. */
char class; /* 'm' implies only want segment references. */
char orient; /* 'h' or 'H' horizontal, anything else vertical: */
/* If 'H' then prefix '.'; if 'h' then append ':'.*/
{
extern int omega;
int hmany; /* Counter for # of symbols with given value */
register int i;
char it; /* Hold char while deciding what to do. */
register int j;
register U16 simbol; /* Hold symtyp here for inspection. */
hmany = 0; /* Alcyon compiler does not allow this */
/* to be initialized in declaration: */
/* I protest! */
for(i = 0; i LE omega; i++) BEGIN
If table[i].symval NE value then IGNORE;
simbol = table[i].symtyp;
If class EQ 'm' and NOT (simbol IS SEGREF)
then IGNORE;
/* I.e. ignore e.g. stack references */
If simbol IS GONE then IGNORE;
/* I.e. ignore hidden symbol */
/* Next line is dummy call to routine to handle long symbols */
If simbol IS TLONG then roam();
If orient EQ 'H' then putchar('.');
for(j = 0; j LT 8 and (it = table[i].namae[j]); j++)
putchar(it);
If orient NE 'H' then putchar(':');
If orient EQ 'H' or orient EQ 'h' then putchar(' ');
otherwise putchar('\n');
hmany++;
If scope then break;
END
If hmany and orient EQ 'h' then putchar('\n');
return(hmany);
}
roam()
{
/* dummy routine: will later handle symbols longer than 8 chars */
}
/************************************************/
/* For given string of given length find first */
/* corresponding symbol table entry, updating */
/* value and putting subscript at *whence. */
/* Return int 1 if found, 0 if not found, */
/* -1 if the bizarre happens, and -2 if an */
/* attempt is made to utilize a feature not */
/* yet implemented. */
/************************************************/
indica(leqth,logos,tesoro,phylum,value,whence)
int leqth;
char logos[]; /* String containing name */
struct asymbl tesoro[]; /* Short symbol table */
char phylum; /* Type of symbol wanted */
U32 *value; /* Place to stick value if and when found */
int *whence; /* Place to stick subscript to symbol table */
{
extern int omega;
register int i; /* To sweep symbol table */
register int j; /* To sweep string */
register short match; /* 1 iff strings equivalent */
register char nxch; /* Next char in logos */
U16 symbol; /* Type of last symbol considered */
for(i = 0; i LE omega; i++) BEGIN
symbol = tesoro[i].symtyp;
switch(phylum) BLOCK
case 'M': /* Address value wanted */
If NOT (symbol IS SEGREF) then IGNORE;
break;
case 'A': /* Nonaddress numerical value wanted */
If symbol IS SEGREF then IGNORE;
break;
case 'B':
break; /* Accept any kind of symbol */
default:
return(-1); /* This shouldn't happen */
UNBLOCK
If symbol IS GONE then IGNORE;
/**temp** Call in next statement will require parameters. */
/**temp** For now just returns (int) -2. */
If symbol IS TLONG then return(trek());
for(j = 0, match = 1; j LT 8 and match; j++) BLOCK
If j LT leqth then nxch = logos[j];
otherwise nxch = '\0';
If nxch NE toupper(tesoro[i].namae[j]) then match = 0;
UNBLOCK
If match then BLOCK
*whence = i;
*value = tesoro[i].symval;
return(1);
UNBLOCK
END
return(0);
}
trek()
{
/* dummy routine: will later handle symbols longer than 8 chars */
return(-2);
}
/****************************************/
/* K command: Play with symbol table */
/****************************************/
koax(cx)
char *cx;
{
extern struct lmhedr *caput;
extern int omega;
extern int main();
struct asymbl *galaxy;
int seqno; /* Subscript to symbol table */
long spot; /* Symbol value input */
char task;
char uppr; /* For entering new name */
galaxy = caput AT sump;
If nomore(cx) then BEGIN
stout("DDT begins at: ");
puthexl(main);
putchar('\n');
stout("Symbol table at: ");
puthexl(galaxy);
putchar('\n');
If omega LT 0 then BLOCK
stout("No symbols");
If caput then begin
stout("; file header at: ");
puthexl(caput);
end
putchar('\n');
UNBLOCK
return;
END
deblank(&cx);
task = *++cx;
switch(task) BEGIN
case 'A':
/* Add a symbol; e.g. KAname,value,type */
/* where name is converted to upper case and */
/* comma after it is obligatory, as is value. */
If nomore(cx) then BLOCK bad(); return; UNBLOCK
otherwise BLOCK
If omega GE HMSYMS then begin
stout("\nSymbol table full\n");
return;
end
deblank(&cx);
uppr = *++cx;
If uppr EQ ',' then begin bad(); return; end
++omega;
for(seqno = 0; seqno LT 8; seqno++) begin
(galaxy+omega) AT namae[seqno] = uppr;
If *++cx NE ',' and uppr then uppr = *cx;
else uppr = '\0';
end
cx--;
If NOT (getsep(&cx) and gethex(&cx,&spot)) then begin
omega--;
bad();
return;
end
(galaxy+omega) AT symval = spot;
If getsep(&cx) and gethex(&cx,&spot) then
seqno = (int)spot;
else seqno = 0xA700; /* Default symbol type */
If NOT nomore(cx) then begin
omega--;
bad();
return;
end
(galaxy+omega) AT symtyp = seqno;
UNBLOCK
break;
case 'H': /* Hide symbols */
/* KH hide symbol most recently sought by name*/
/* KHvalue hide first symbol with given value */
/* KH*value hide symbol with sequence number equal */
/* to given value, if in range */
seqno = findsn(cx,omega,galaxy);
If seqno LT 0 then begin bad(); return; end
otherwise (galaxy+seqno) AT symtyp ORWITH GONE;
break;
case 'R': /* Recover hidden symbols */
/* KR recover all hidden symbols */
/* KRvalue recover first symbol with given value */
/* KR*value recover symbol with sequence number */
/* equal to given value, if in range */
If nomore(cx) then
for(seqno = 0; seqno LE omega; seqno++)
(galaxy+seqno) AT symtyp ANDWITH ~GONE;
otherwise BLOCK
seqno = findsn(cx,omega,galaxy);
If seqno LT 0 then begin bad(); return; end
else (galaxy+seqno) AT symtyp ANDWITH ~GONE;
UNBLOCK
break;
default:
bad();
return;
break;
END
putchar('\n');
}
/************************************************/
/* Find serial number of symbol entry, parsing */
/* rest of command line */
/************************************************/
findsn(spear,zedd,arcade)
char *spear; /* Scanner for command line */
int zedd; /* Highest symbol table subscript */
struct asymbl *arcade; /* Addr of symbol table */
{
extern int nomo; /* Last entry sought by name */
int ix; /* To sweep symbol table */
int script; /* Int subscript to be returned */
long werth; /* Numerical value of symbol */
script = -1; /* Preset to illegal value */
If nomore(spear) then script = nomo;
otherwise BLOCK
deblank(&spear);
If *(spear+1) EQ '*' then begin
++spear;
If gethex(&spear,&werth) and nomore(spear) then
script = (int) werth;
end
else If gethex(&spear,&werth) and nomore(spear)
then for(ix = 0; ix LE zedd and script LT 0; ix++)
If (arcade+ix) AT symval EQ werth then script = ix;
UNBLOCK
If script GT zedd then script = -1;
return(script);
}
passpt(pcx)
char *pcx;
{
extern U16 pkawnt[HMPPTS];
extern U16 *plocus[HMPPTS];
extern U16 ancien[HMPPTS];
extern int minus;
extern int omega;
extern int scope;
extern struct lmhedr *caput;
int jp;
int reply; /* Operator's response */
int plain; /* plain iff no tail */
char *nupt; /* Value of new pass point */
/* N.b.: "char" required so bitwise "&" */
/* will work properly. */
long cntdn; /* New pass count (initially long) */
cntdn = 1; /* Set to default pass count */
If NOT (plain = nomore(pcx)) then BEGIN
If NOT gethex(&pcx,&nupt) then goto chide;
/* Warning: The following bitwise "&" statement */
/* requires nupt to be declared "char" pointer.*/
If nupt & 1 then BLOCK
stout("\nNo change--Address must be even!\n");
return;
UNBLOCK
If getsep(&pcx) then If NOT gethex(&pcx,&cntdn)
or minus then goto chide;
If NOT nomore(pcx) then goto chide;
END
If NOT cntdn then goto chide;
If minus then BEGIN
If plain then zappas();
else BLOCK
for (jp = 0; jp LT HMPPTS; jp++)
If pkawnt[jp] and plocus[jp] EQ nupt then begin
pkawnt[jp] = 0;
minus = 0;
end
If minus then goto chide;
UNBLOCK
END
otherwise BEGIN
If plain then BLOCK
for(jp=0,reply=1;jp LT HMPPTS and reply;jp++) begin
If pkawnt[jp] then {
If ++minus GT 16 and jp LT HMPPTS then BEGIN
reply = pause();
minus = 0;
END
If reply then BEGIN
putchar('\n');
puthexw(pkawnt[jp]);
stout(" ");
puthexl(plocus[jp]);
stout(" ");
If omega GE 0 then
spell((U32) plocus[jp],caput AT sump
,scope,'m','H');
END
}
end
putchar('\n');
UNBLOCK
else BLOCK
for (jp = 0; jp LT HMPPTS; jp++)
If pkawnt[jp] and plocus[jp] EQ nupt then begin
If pkawnt[jp] EQ cntdn then stout("\nAlready set\n");
otherwise pkawnt[jp] = cntdn;
return;
end
minus = 1;
for (jp = 0; jp LT HMPPTS; jp++)
If NOT pkawnt[jp] then begin
pkawnt[jp] = (U16) cntdn;
plocus[jp] = nupt;
jp = HMPPTS;
minus = 0;
end
If minus then begin
stout("\nToo many pass points--limit is: ");
SAYMAX
end
UNBLOCK
END
return;
chide:
bad();
}
qotbyt(nnnn)
long nnnn;
{
If nnnn LT 0x20 or nnnn GT 0x7E then return(0);
putchar('\'');
BDOS(CONOUT,nnnn);
putchar('\'');
return(1);
}
vecina(cxp,sought)
char **cxp;
char sought;
{
/* Check if next char in command is a specified char, advancing */
/* pointer if it is. */
++*cxp;
If **cxp EQ sought then return(1);
--*cxp;
return(0);
}
zappas()
{
extern U16 pkawnt[HMPPTS];
int jz;
for (jz = 0; jz LT HMPPTS; jz++) pkawnt[jz] = 0;
}
ern U16 pkawnt[HMPPTS];
int jz;
for (jz = 0; jz LT HMPPTS; jz++) pkawnt[jz] = 0;
}


Binary file not shown.

View File

@@ -0,0 +1,80 @@
/************************************************************************/
/* */
/* File I/O Definitions */
/* */
/* The definitions in this section are used by the run-time */
/* package to provide an interface between CP/M-68K I/O and */
/* standard C I/O. */
/* */
/************************************************************************/
/****************************************************************************/
/* Miscellaneous Definitions: */
/****************************************************************************/
#define FAILURE (-1) /* Function failure return val */
#define SUCCESS (0) /* Function success return val */
#define YES 1 /* "TRUE" */
#define NO 0 /* "FALSE" */
#define FOREVER for(;;) /* Infinite loop declaration */
#define NULL 0 /* Null pointer value */
#define EOF (-1) /* EOF Value */
#define TRUE (1) /* Function TRUE value */
#define FALSE (0) /* Function FALSE value */
#define BUFSIZE 128 /* # bytes in a buffer */
/**/
/****************************************************************************/
/* */
/* M A C R O S */
/* ----------- */
/* */
/* Define some stuff as macros .... */
/* */
/****************************************************************************/
#define getchar() ((char) BDOS(CONIN, 0)) /* Get character from console */
/**/
#define isalpha(c) (islower(c)||isupper(c)) /* true if "c" a letter */
#define isdigit(c) ('0' <= (c) && (c) <= '9') /* Ascii only!! */
#define iswhite(c) ((c) <= 040 || 0177<= (c)) /* Is control / funny char */
#define iswild(c) ((c) == '*' || (c) == '?') /* true if a wildcard char */
/**/
#define islower(c) ('a' <= (c) && (c) <= 'z') /* Ascii only!! */
#define isupper(c) ('A' <= (c) && (c) <= 'Z') /* Ascii only!! */
/**/
#define tolower(c) (isupper(c) ? ((c)+040):(c)) /* translate to lower case */
#define toupper(c) (islower(c) ? ((c)-040):(c)) /* translate to upper case */
/**/
#define abs(x) ((x) < 0 ? -(x) : (x)) /* Absolute value function */
#define max(x,y) (((x) > (y)) ? (x) : (y)) /* Max function */
#define min(x,y) (((x) < (y)) ? (x) : (y)) /* Min function */
/**/
/************************************************************************/
/* */
/* BDOS Procedure Declaration */
/* */
/************************************************************************/
long BDOS();
/***/
 */
/***********************************************************************/
long BDOS();
/***/
 */
/****