[net.micro.apple] Apple II system and DOS constants for assembly programming

goldste@uthub.UUCP (Jack Goldstein) (02/15/86)

   There has been a lot of talk in this group lately about assembly
language programming and posting public domain apple sources.  I thought
I'd combine the two topics with this posting.

     The first file in this article contains a number of constant
definitions (equates) for assembly language programming on an Apple II+.
It includes some character constants, most of the zero page variables,
many of the useful ROM routines and all the page 3 vectors.  It is most
useful if your assembler has an include feature, especially if you have
a RAM disk.

     One noteable omission from this file is that none of the on-board
I/O locations are present.  Perhaps someone can add them and repost.

     The second file contains constant definitions for programming
with DOS 3.3.  It contains most of the constants related to the File
Manager and RWTS and many DOS variables.

    This is not a shell archive.  You have to extract the files
manually.

-------------- cut here for system.inc ------------------------------

*			  SYSTEM DEFINITIONS
*			  ******************

* Written by Jack Goldstein		February, 1986

* This file contains a number of constant definitions which may be
* useful when programming an Apple ][.  It was written for an
* Apple ][+ so a few things may have to be changed for the 2e.
 
 
*
* Character constants
*
cntrlC		.eq $83
bell		.eq $87
bksp		.eq $88
tab		.eq $89
LF		.eq $8a
FF		.eq $8c
CR		.eq $8d
cntrlQ		.eq $91
cntrlS		.eq $93
cntrlX		.eq $98
ESC		.eq $9B
space		.eq $A0
 
caseBit		.eq $20
 
 
*
* Zero Page Variables
* Most of the monitor variables, except for the screen control ones,
* are overwritten by DOS.
*
 
loc0		.eq $0
loc1		.eq $1
wndLft		.eq $20
wndWdth		.eq $21
wndTop		.eq $22
wndBtm		.eq $23
CH		.eq $24			horizontal cursor position
CV		.eq $25			vertical      "	      "
baseAddr	.eq $28			base addr of current output line
baseAddr2	.eq $2A			base addr of line for ESC-edit
invFlag		.eq $32			bits AND'd with every char out
prompt		.eq $33
 
CSW		.eq $36			char out switch
KSW		.eq $38			keyboard input switch
 
regPC		.eq $3A			Saved user register
A1		.eq $3C
A2		.eq $3E
A3		.eq $40
A4		.eq $42
A5		.eq $44
regA		.eq $45			Saved user registers
regX		.eq 46
regY		.eq $47
regStat		.eq $48
regSP		.eq $49
 
random		.eq $4A
 
apProgStart	.eq $67
apVarStart	.eq $69
apHimem		.eq $73
apHighLineNum	.eq $76			one byte
apProgEnd	.eq $AF
 
lineBuf		.eq $200		GetLn buffer
 
 
*
* Monitor subroutines
*
 
* Standard input and output 
Mon.COut	.eq $FDED		
Mon.CROut	.eq $FD8E		
Mon.Bell	.eq $FF3A
Mon.PrHex	.eq $FDE3
Mon.PrByte	.eq $FDDA		
Mon.PrntAX	.eq $F941		
Mon.PrntYX	.eq $F940
Mon.PrBlnk	.eq $F948		Print 3 blanks
Mon.PrBl2	.eq $F94A		Print X blanks
Mon.PrErr	.eq $FF2D		
 
Mon.RdKey	.eq $FD0C		Standard input
Mon.GetLn	.eq $FD6A		
Mon.GetLnZ	.eq $FD67		CR then GETLN
Mon.GetLn2	.eq $FD6F		GetLn without printing prompt
 
* Screen Control for 40 Column Text
Mon.COut1	.eq $FDF0		Char in A to screen
Mon.KeyIn	.eq $FD1B		Apple keyboard
 
Mon.SetInv	.eq $FE80		
Mon.SetNorm	.eq $FE84		
Mon.Init	.eq $FB2F		init 40 column text window
Mon.SetTxt	.eq $FB39		
Mon.SetGr	.eq $FB40		
Mon.SetWnd	.eq $FB4B
Mon.BasCalc	.eq $FBC1		
Mon.VTab	.eq $FC22		
Mon.ClrEOP	.eq $FC42		
Mon.Home	.eq $FC58		
Mon.Scroll	.eq $FC70		
Mon.ClrEOL	.eq $FC9C		
 
* Setting I/O Vectors
Mon.SetKbd	.eq $FE89		set normal keyboard input
Mon.SetVid	.eq $FE93		set normal 40 column output
Mon.InPort	.eq $FE8B		set input to slot A
Mon.OutPort	.eq $FE95		set output to slot A
 
* General Utilities
Mon.Entry	.eq $FF69		Monitor entry point
Mon.GetNum	.eq $FFA7		Decode hexnum from inBuf to A1,A2
Mon.Wait	.eq $FCA8		wait .5 * (26 + 27A +5A^2) mu-secs
Mon.Save	.eq $FF4A		Save user regs
Mon.Restore	.eq $FF3F		Restore user regs
Mon.OldBrk	.eq $FA59		old break
Mon.Move	.eq $FE2C		Move (A1 to A2) to A4
Mon.Vfy		.eq $FE36		Verify (A1 to A2) with A4
 
 
 
*
* Page 3 Routines and Vectors
*
WarmStart	.eq $3d0
ColdStart	.eq $3d3
Dos.FileMan	.eq $3d6
Dos.RWTS	.eq $3d9
Dos.LocFileParm .eq $3dc
Dos.LocIOB	.eq $3e3
Dos.ConnectIO	.eq $3ea		Connect DOS IO intercepts
Break		.eq $3ef
ResetAddr	.eq $3f2
PowerUpByte	.eq $3f4
ApSoftUsrRtn	.eq $3f5		&
MonitorUsrRtn	.eq $3f8		^Y
NMIUsrRtn	.eq $3fb
IntrptRtnAddr	.eq $3fe
 
 
*
* RAM Card I/O Locations
*
RAM2RdRamWrtRom .eq $C080		
RAM2RdRomWrtRam .eq $C081		
RAM2RdRomWrtRom .eq $C082		
RAM2RdRamWrtRam .eq $C083		
 
RAM1RdRamWrtRom .eq $C088
RAM1RdRomWrtRam .eq $C089
RAM1RdRomWrtRom .eq $C08A
RAM1RdRamWrtRam .eq $C08B

------------------------ cut here for dos.inc ---------------------------

*			DOS CONSTANTS AND VARIABLES
*			***************************
 
* Written by Jack Goldstein,		February, 1986

* This file contains a number of constants which may be useful when
* programming an Apple with DOS 3.3.
 
*
* CONSTANTS
*
 
* File Types
tText		.eq $00
tIntBasic	.eq $01
tApSoft		.eq $02
tBinary		.eq $04
tRelocatable	.eq $08
tSType		.eq $10
 
 
*
* R W T S
* '*' marks those fields to be changed; '+' marks those to be read
*
 
* IOB
iTabType	.eq $0			always 1
iSlot16		.eq $1
iDrive		.eq $2			*
iVolume		.eq $3			* 0 matches any vol
iTrack		.eq $4			*
iSector		.eq $5			*
iDevTab		.eq $6
iDataBufLoc	.eq $8			*
iByteCount	.eq $B
iCommand	.eq $C			*
iReturnCode	.eq $D			+  carry set on rtrn if non-zero
iPrevVolume	.eq $E
iPrevSlot16	.eq $F
iPrevDrive	.eq $10
 
* Command Codes
cSeek		.eq $0
cRead		.eq $1
cWrite		.eq $2
cFormat		.eq $4
 
* Return codes
rNoError	.eq $0
rInitErr	.eq $08
rWriteProt	.eq $10
rBadVol		.eq $20
rDriveErr	 .eq $40
 
 
*
* The File Manager
*
 
* Parameter List
pCallType	.eq $0
pSubCallType	.eq $1
pRecord		.eq $2
pFileType	.eq $7			for open
pFileNameAddr	.eq $8
pReturnCode	.eq $A
pScratchBuf	.eq $C			45 byte scratch buffer
pDataBuffer	.eq $10			256 bytes
 
* Call type codes
fOpen		.eq $1
fClose		.eq $2
fRead		.eq $3
fWrite		.eq $4
fDelete		.eq $5
fCatalog	.eq $6
fLock		.eq $7
fUnlock		.eq $8
fRename		.eq $9
fPosition	.eq $A
fInit		.eq $B
fVerify		.eq $C
 
* Sub-call Codes
sOneByte	.eq $1
sRange		.eq $2
sPosOneByte	.eq $3
sPosRange	.eq $4
 
* Return Codes	-  carry is set on return if non-zero return code
eNoError	.eq $0
eBadCall	.eq $2
eBadSubCall	.eq $3
eWriteProt	.eq $4
eEndOfData	.eq $5
eFileNotFound	.eq $6
eBadVol		.eq $7
eDiskErr	.eq $8
eDiskFull	.eq $9
eFileLocked	.eq $A
 
* Other errors
eSyntaxError	.eq $B
eNoBuffers	.eq $C
eWrongFileType	.eq $D
eTooLarge	.eq $E
 
 
* DOS buffer formt
bDataBuf	.eq $0
bTSList		.eq $100
bWorkArea	.eq $200
bFileName	.eq $22D
bLink		.eq $251
fileNameSize	.eq bLink-bFileName
 
 
*
* ZERO PAGE VARIABLES
*
IOBLoc		.eq $48
 
 
*
* DOS VARIABLES
*
 
Dos.firstBuf	.eq $9D00
Dos.kbdIntRtn	.eq $9D02		keyboard intercept routine
Dos.vidIntRtn	.eq $9D04		video	     "	      "
 
Dos.cmdEntryTab .eq $9D1E
 
Dos.actBasVect	.eq $9D56		active BASIC vector table
Dos.BasChain	.eq $9D56
Dos.BasRun	.eq $9D58
Dos.BasErrHand	.eq $9D5A
Dos.BasColdStrt .eq $9D5C
Dos.BasWarmStrt .eq $9D5E
Dos.BasReloc	.eq $9D60
 
Dos.IntBasVect	.eq $9D62
Dos.Ap1BasVect	.eq $9D6C		ROM Applesoft
Dos.Ap2BasVect	.eq $9D78		RAM Applesoft
 
Dos.MaxDrives	.eq $A95B
 
Dos.errorMsgs	.eq $A971
Dos.errorIndex	.eq $AA3F
 
Dos.curStatus	.eq $AA51
Dos.CSW		.eq $AA53
Dos.KSW		.eq $AA55
Dos.maxFiles	.eq $AA57
Dos.MONFlags	.eq $AA5E
Dos.ExecActFlag .eq $AAB3
Dos.ActiveBasic .eq $AAB6
 
* Status constants
sRead		.eq $01
sWarmstart	.eq $00
sColdstart	.eq $08
sApSoftRam	.eq $40
 
* MON constants
mC		.eq $40
mI		.eq $20
mO		.eq $10
 
* Active Basic Constants
bInteger	.eq $00
bApsoftRom	.eq $40
bApsoftRam	.eq $80