diff --git a/.gitattributes b/.gitattributes index dadf492..ebb5cd6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,9 +3,16 @@ # 86-DOS and CP/M text files must use CRLF and have 0x1A EOF markers, we simply mark them as binary *.a86 binary +*.A86 binary *.asm binary +*.ASM binary *.com binary +*.COM binary *.doc binary +*.DOC binary *.hex binary +*.HEX binary *.prn binary +*.PRN binary *.z80 binary +*.Z80 binary diff --git a/86DOS.A86 b/86DOS.A86 index e7a90d9..de592cd 100644 --- a/86DOS.A86 +++ b/86DOS.A86 @@ -13,35 +13,38 @@ ; INTBASE+18H: BIOS DISK WRITE ; INTBASE+40H: Long jump to CALL entry point -ESCCH EQU 1BH -CANCEL EQU "X"-"@" ;Cancel with Ctrl-X -MAXCALL EQU 36 -MAXCOM EQU 40 -INTBASE EQU 80H -INTTAB EQU 20H -ENTRYPOINTSEG EQU 0CH -ENTRYPOINT EQU INTBASE+40H -CONTC EQU INTTAB+3 -EXIT EQU INTBASE+8 -LONGJUMP EQU 0EAH -LONGCALL EQU 9AH -SAVEXIT EQU 10 +MAXCALL:EQU 36 +MAXCOM: EQU 40 +ESCCH: EQU 1BH +INTBASE:EQU 80H +INTTAB: EQU 20H +ENTRYPOINTSEG: EQU 0CH +ENTRYPOINT: EQU INTBASE+40H +CONTC: EQU INTTAB+3 +EXIT: EQU INTBASE+8 +LONGJUMP:EQU 0EAH +LONGCALL:EQU 9AH +MAXDIF: EQU 0FFFH +SAVEXIT:EQU 10 ; Field definition for FCBs -FNAME EQU 0 ;Drive code and name -EXTENT EQU 12 -ENTPOS EQU 16 ;Position of entry in directory -DRVBP EQU 18 ;BP for SEARCH FIRST and SEARCH NEXT -FIRCLUS EQU 20 ;First cluster of file -LSTCLUS EQU 22 ;Last cluster accessed -FILSIZ EQU 24 ;Size of file in records -CLUSPOS EQU 26 ;Position of last cluster accessed -FLSFLG EQU 28 ;Flush flag -SIZCHG EQU 29 ;Size change flag -NR EQU 32 ;Next record -RR EQU 33 ;Random record + ORG 0 + DS 12 ;Drive code and name +EXTENT: DS 4 +ENTPOS: DS 2 ;Position of entry in directory +DRVBP: DS 2 ;BP for SEARCH FIRST and SEARCH NEXT +FIRCLUS:DS 2 ;First cluster of file +LSTCLUS:DS 2 ;Last cluster accessed +FILSIZ: DS 2 ;Size of file in records +CLUSPOS:DS 2 ;Position of last cluster accessed +DIRTYFIL:DS 1 ;File has been written to if <>0 +SIZCHG: DS 1 ;Directory needs update if <>0 + ORG 32 +NR: DS 1 ;Next record +RR: DS 3 ;Random record + ; Description of 16-byte directory entry (same as returned by SEARCH FIRST ; and SEARCH NEXT, functions 17 and 18). @@ -51,53 +54,43 @@ RR EQU 33 ;Random record ; 0 11 File name and extension ( 0E5H if empty) ; 11 2 First allocation unit ( < 4080 ) ; 13 3 File size, in bytes (LSB first, 24 bits max.) -; -; The File Allocation Table uses a 12-bit entry for each allocation unit on -; the disk. These entries are packed, two for every three bytes. The contents -; of entry number N is found by 1) multiplying N by 1.5; 2) adding the result -; to the base address of the Allocation Table; 3) fetching the 16-bit word at -; this address; 4) If N was odd (so that N*1.5 was not an integer), shift the -; word right four bits; 5) mask to 12 bits (AND with 0FFF hex). Entry number -; zero is used as an end-of-file trap in the OS. Entry 1 is reserved for -; future use. The first available allocation unit is assigned entry number -; two, and even though it is the first, is called cluster 2. Entries of 0FFFH -; are end of file marks; entries of zero are unallocated. Otherwise, the -; contents of a FAT entry is the number of the next cluster in the file. ; Field definition for Drive Parameter Block -DEVNUM EQU 0 ;I/O driver number -SECSIZ EQU 1 ;Size of physical sector in records -CLUSMSK EQU 2 ;Records/cluster - 1 -CLUSSHFT EQU 3 ;Log2 of records/cluster -FIRFAT EQU 4 ;Starting record of FATs -FATSIZ EQU 6 ;Number of records occupied by FAT -FATCNT EQU 7 ;Number of FATs for this drive -FIRDIR EQU 8 ;Starting record of directory -DIRSIZ EQU 10 ;Number of records occupied by directory -FIRREC EQU 11 ;First record of first cluster -MAXCLUS EQU 13 ;Number of clusters on drive + 1 -DIRTY EQU 15 ;Whether FAT is dirty -FAT EQU 16 ;Pointer to start of FAT + ORG 0 +DRVNUM: DS 1 ;Drive number +SECSIZ: DS 1 ;Size of physical sector in records +CLUSMSK:DS 1 ;Records/cluster - 1 +CLUSSHFT:DS 1 ;Log2 of records/cluster +FIRFAT: DS 2 ;Starting record of FATs +FATSIZ: DS 1 ;Number of records occupied by FAT +FATCNT: DS 1 ;Number of FATs for this drive +FIRDIR: DS 2 ;Starting record of directory +DIRSIZ: DS 1 ;Number of records occupied by directory +FIRREC: DS 2 ;First record of first cluster +MAXCLUS:DS 2 ;Number of clusters on drive + 1 +DIRTYFAT:DS 1 ;-1=FAT has been changed +FAT: DS 2 ;Start of FAT -DPBSIZ EQU 18 ;Size of the structure in bytes +DPBSIZ: EQU $ -; BOIS entry point definitions +; BIOS entry point defintions -BIOSSEG EQU 40H +BIOSSEG: EQU 40H + ORG 0 + DS 3 +BIOSSTAT: DS 3 +BIOSIN: DS 3 +BIOSOUT: DS 3 +BIOSPRINT: DS 3 +BIOSAUXIN: DS 3 +BIOSAUXOUT: DS 3 +BIOSREAD: DS 3 +BIOSWRITE: DS 3 +BIOSFLUSH: DS 3 -BIOSINIT EQU 0 ;Reserve room for jump to init code -BIOSSTAT EQU 3 ;Console input status check -BIOSIN EQU 6 ;Get console character -BIOSOUT EQU 9 ;Output console character -BIOSPRINT EQU 12 ;Output to printer -BIOSAUXIN EQU 15 ;Get byte from auxilliary -BIOSAUXOUT EQU 18 ;Output byte to auxilliary -BIOSREAD EQU 21 ;Disk read -BIOSWRITE EQU 24 ;Disk write -BIOSFLUSH EQU 27 ;Disk buffer flush ; Start of code @@ -106,55 +99,56 @@ BIOSFLUSH EQU 27 ;Disk buffer flush JMP DOSINIT -ESCTAB: - DB "SC" ;Copy one character from template - DB "VN" ;Skip over one character in template - DB "TA" ;Copy up to specified character - DB "WB" ;Skip up to specified character - DB "UH" ;Copy rest of template - DB "HH" ;Kill line with no change in template (Ctrl-X) - DB "RM" ;Cancel line and update template - DB "DD" ;Backspace (same as Ctrl-H) - DB "P@" ;Enter Insert mode - DB "QL" ;Exit Insert mode - DB 1BH,1BH ;Escape sequence to represent escape character - DB ESCCH,ESCCH +ESCTAB: + DB "SC" ;Copy one char + DB "VN" ;Skip one char + DB "TA" ;Copy to char + DB "WB" ;Skip to char + DB "UH" ;Copy line + DB "HH" ;Kill line (no change in template) + DB "RM" ;Reedit line (new template) + DB "DD" ;Backspace + DB "P@" ;Enter insert mode + DB "QL" ;Exit insert mode + DB ESCCH,ESCCH ;Escape character + DB ESCCH,ESCCH ;End of table -ESCTABLEN EQU $-ESCTAB -HEADER DB 13,10,"86-DOS version 0.11" +ESCTABLEN:EQU $-ESCTAB + +HEADER: DB 13,10,"86-DOS version 0.11" DB 13,10 DB "Copyright 1980 Seattle Computer Products, Inc.",13,10,"$" DOSINIT: - CLI - CLD + DI + UP MOV AX,CS MOV ES,AX - LODB ;Get no. of drives & no. of I/O drivers + LODB CBW MOV CX,AX SEG CS - MOV [NUMIO],AL + MOV [NUMDRV],AL MOV DI,AX SHL DI - MOV AH,DPBSIZ ;Size of DPB + MOV AH,DPBSIZ MUL AX,AH MOV BX,DRVTAB - ADD DI,BX ;Point to first DPB + ADD DI,BX ADD AX,DI - MOV BP,AX ;Point to first FAT + MOV BP,AX SEG CS MOV [FATBASE],AX PERDEV: SEG CS - MOV [BX],DI ;Store DPB pointer to table entry + MOV [BX],DI INC BX INC BX MOV AL,CH - STOB ;DEVNUM - LODW ;Get pointer to DPT - PUSH SI ;Save INITTAB pointer - MOV SI,AX ;Load DPT + STOB ;DRVNUM + LODW ;Pointer to DPT + PUSH SI + MOV SI,AX MOVB ;SECSIZ LODB DEC AL @@ -167,7 +161,7 @@ FIGSHFT: MOV AL,AH STOB ;CLUSSHFT LODW - STOW ;FIRFAT + STOW ;FIRFAT (= number of reserved records) MOV DX,AX LODB STOB ;FATSIZ @@ -190,7 +184,7 @@ FIGSHFT: STOW ;MAXCLUS XOR AL,AL STOB - POP SI + POP SI ;Restore pointer to init. table LODW ;Allocation table displacement SEG CS ADD AX,[FATBASE] @@ -198,7 +192,7 @@ FIGSHFT: MOV DL,0 SHR DX ;FAT size in bytes ADD AX,DX - CMP AX,BP + CMP AX,BP ;Bigger than already allocated JBE SMFAT MOV BP,AX SMFAT: @@ -227,21 +221,21 @@ SMFAT: STOW MOV AX,BIOSSEG STOW - STOW ;Add 2 to DI + STOW ;Add 2 to DI STOW MOV [INTBASE+18H],BIOSWRITE MOV DX,CS MOV DS,DX - ADD DX,BP ;Next free segment - MOV [DMAADD],128 + ADD DX,BP + MOV [DMAADD],80H MOV [DMAADD+2],DX MOV AX,[DRVTAB] - MOV [CURDRV],AX - MOV CX,DX ;Start scanning just after DOS + MOV [CURDRVPT],AX + MOV CX,DX MOV BX,0FH MEMSCAN: INC CX - JZ SETEND + JZ HAVMEM MOV DS,CX MOV AL,[BX] NOT AL @@ -250,8 +244,7 @@ MEMSCAN: NOT AL MOV [BX],AL JZ MEMSCAN - -SETEND: +HAVMEM: SEG CS MOV [ENDMEM],CX XOR CX,CX @@ -282,7 +275,7 @@ ENTRY: ;System call entry point and dispatcher SEG CS POP [TEMP] ;IP from the CALL 5 PUSHF ;Start re-ordering the stack - CLI + DI PUSH AX ;Save segment SEG CS PUSH [TEMP] ;Stack now ordered as if INT had been used @@ -300,7 +293,7 @@ SAVREGS: POP [TEMP] MOV SP,CS MOV SS,SP - MOV SP,SSSAVE + MOV SP,STACK PUSH ES PUSH DS PUSH BP @@ -313,7 +306,7 @@ SAVREGS: MOV BL,AH MOV BH,0 SHL BX - CLD + UP SEG CS CALL [BX+DISPATCH] SEG CS @@ -331,8 +324,10 @@ SAVREGS: SEG CS MOV SP,[SPSAVE] IRET + +DISPATCH: ; Standard Functions -DISPATCH DW ABORT ;0 + DW ABORT ;0 DW CONIN DW CONOUT DW READER @@ -344,7 +339,7 @@ DISPATCH DW ABORT ;0 DW PRTBUF DW BUFIN ;10 DW CONSTAT - DW GETVER + DW VERSION DW DSKRESET DW SELDSK DW OPEN ;15 @@ -357,10 +352,10 @@ DISPATCH DW ABORT ;0 DW CREATE DW RENAME DW INUSE - DW GETDRV ;25 + DW CURDRV ;25 DW SETDMA DW GETFATPT - DW GETFATPTDL + DW WRTPROT DW GETRDONLY DW SETATTRIB ;30 DW GETDSKPT @@ -375,16 +370,17 @@ DISPATCH DW ABORT ;0 DW BLKRD DW BLKWRT ;40 +VERSION: GETIO: SETIO: -GETVER: -GETFATPTDL: +WRTPROT: GETRDONLY: SETATTRIB: USERCODE: MOV AL,0 RET + READER: CALL BIOSAUXIN,BIOSSEG RET @@ -423,7 +419,7 @@ HAVCLUS: AND DI,0FFFH RET HURTFAT: - MOV SI,BADFAT + MOV SI,BADMES CALL OUTMES JMP ERROR @@ -460,8 +456,7 @@ PACKIN: MOV [BX],DI RET - -GETNAME: +GETFILE: ; Inputs: ; DS,DX point to FCB @@ -475,15 +470,15 @@ GETNAME: ; BP = Base of drive parameters ; DS = CS ; ES = CS -; AX = Directory record number +; AL = Directory record number ; BX = Pointer into directory buffer +; SI = Pointer to First Cluster field in directory entry ; [DIRBUF] has directory record with match ; [NAME1] has file name ; All other registers destroyed. - CALL MOVNAME - JC RET + JC RET ;Bad file name? FINDNAME: MOV AX,CS MOV DS,AX @@ -504,7 +499,7 @@ NDIRREC: RET NEXTENT: - Add BX,16 + ADD BX,16 CMP BX,DIRBUF+127 JA RET CMP B,[BX],0E5H @@ -522,11 +517,11 @@ WILDCRD: DELETE: ; System call 19 - CALL GETNAME + CALL GETFILE JC ERRET PUSH AX PUSH BX - CALL LOADFAT + CALL FATREAD POP BX DELFILE: MOV B,[BX],0E5H @@ -572,9 +567,9 @@ RENFIL: NEWNAM: LODB CMP AL,"?" - JZ SKIPLET + JZ NOCHG MOV [DI],AL -SKIPLET: +NOCHG: INC DI LOOP NEWNAM CALL NEXTENT @@ -611,12 +606,12 @@ MOVNAME: MOV SI,DX LODB SEG ES - CMP [NUMIO],AL + CMP [NUMDRV],AL JC RET CBW XCHG AX,BP SHL BP - MOV BP,[BP+CURDRV] + MOV BP,[BP+CURDRVPT] LODNAME: ; This entry point copies a file name from DS,SI ; to ES,DI converting to upper case. @@ -624,12 +619,12 @@ LODNAME: MOVCHK: LODB AND AL,7FH - CMP AL,"a"-1 - JLE STOLET - AND AL,5FH ;Convert to upper case -STOLET: - CMP AL," " - JB RET + CMP AL,60H + JLE CASEOK + AND AL,5FH +CASEOK: + CMP AL,20H + JC RET STOB LOOP MOVCHK RET @@ -637,42 +632,47 @@ STOLET: OPEN: ;System call 15 PUSH DX PUSH DS - CALL GETNAME -OPENNAM: + CALL GETFILE +DOOPEN: +; Enter here to perform OPEN on file already found +; in directory. DS=ES=CS, BX points to directory +; entry in DIRBUF, and the top of the stack has the +; address and segment of the FCB to be opened. This +; entry point is used by CREATE. POP ES POP DI JC ERRET - MOV AH,[BP+DEVNUM] + MOV AH,[BP+DRVNUM] INC AH SEG ES MOV [DI],AH SEG ES - MOV [DI+EXTENT],0 - ADD DI,16 + MOV [DI+EXTENT],0 ;Set extent field to 0 + ADD DI,16 ;Point to entry pos. field MOV CX,BX SUB CX,DIRBUF MOV AH,CL - STOW ;ENTPOS + STOW ;directory location MOV AX,BP - STOW ;DRVBP + STOW ;pointer to driver parameters LEA SI,[BX+11] - LODW - STOW ;FIRCLUS - STOW ;LSTCLUS + LODW ;Get starting cluster + STOW ; first cluster + STOW ; last cluster accessed LODB SHL AL LODW RCL AX - STOW ;FILSIZ + STOW ; size of file in records XOR AX,AX - STOW ;CLUSPOS - STOW ;FLSFLG, SIZCHG + STOW ; position of last cluster + STOW ; file not dirty -LOADFAT: - TEST B,[BP+DIRTY],-1 +FATREAD: + TEST B,[BP+DIRTYFAT],-1 JNZ RET CALL FIGFAT -READFAT: +NEXTFAT: PUSH DX PUSH CX PUSH BX @@ -683,27 +683,32 @@ READFAT: POP BX POP CX POP DX - JNZ FATERR + JNZ BADFAT SUB AL,[BP+FATCNT] JZ RET NEG AL +;{Insert error code here. AL=number of bad fats. +;Since one good FAT was read, should include option +;to rewrite all FATs.} JP FATWRT -FATERR: + +BADFAT: ADD DX,CX DEC AL - JNZ READFAT + JNZ NEXTFAT POP BP - MOV SI,ALLBAD +;{Insert error code here. All FATs on drive are bad.} + MOV SI,BADFATMES CALL HARDERR - JP LOADFAT + JP FATREAD CLOSE: ;System call 16 MOV DI,DX - TEST B,[DI+FLSFLG],-1 + TEST B,[DI+DIRTYFIL],-1 JZ NOFLSH PUSH DI MOV BP,[DI+DRVBP] - MOV AL,[BP+DEVNUM] + MOV AL,[BP+DRVNUM] CALL BIOSFLUSH,BIOSSEG POP DI NOFLSH: @@ -712,7 +717,7 @@ NOFLSH: MOV DX,DI PUSH DX PUSH DS - CALL GETNAME + CALL GETFILE POP ES POP DI JC BADCLOSE @@ -736,7 +741,8 @@ NOFLSH: CHKFATWRT: ; Do FATWRT only if FAT is dirty - TEST B,[BP+DIRTY],-1 + + TEST B,[BP+DIRTYFAT],-1 JZ OKRET FATWRT: @@ -746,13 +752,13 @@ FATWRT: ; BP = Base of drive parameter table ; Function: ; Write the FAT back to disk and reset FAT -; dirty flag. +; dirty bit. ; Outputs: ; AL = 0 ; BP unchanged ; All other registers destroyed - MOV B,[BP+DIRTY],0 + MOV B,[BP+DIRTYFAT],0 CALL FIGFAT EACHFAT: PUSH DX @@ -772,7 +778,7 @@ OKRET: RET BADCLOSE: - MOV B,[BP+DIRTY],0 + MOV B,[BP+DIRTYFAT],0 MOV AL,-1 RET @@ -848,7 +854,7 @@ FREESPOT: CALL DIRWRITE POP BX POP AX - JMP OPENNAM + JMP DOOPEN DIRREAD: @@ -860,7 +866,7 @@ DIRREAD: ; Function: ; Read the directory block into DIRBUF. ; Outputs: -; AX,BP unchanged +; BP unchanged ; All other registers destroyed. CALL DIRCOMP @@ -875,9 +881,11 @@ DREAD: ; Function: ; Calls BIOS to perform disk read. If BIOS reports ; errors, will call HARDERR for further action. +; Outputs: +; AL = 0 if no error, otherwise non-zero ; BP preserved. All other registers destroyed. - MOV AL,[BP+DEVNUM] + MOV AL,[BP+DRVNUM] PUSH BP PUSH BX PUSH CX @@ -887,12 +895,12 @@ DREAD: POP DI POP BX POP BP - JC DSKRDERR + JC HARDREAD XOR AL,AL RET -DSKRDERR: - MOV SI,RDERR +HARDREAD: + MOV SI,RDERRMES CALL HARDERR JP DREAD @@ -921,9 +929,11 @@ DWRITE: ; Function: ; Calls BIOS to perform disk write. If BIOS reports ; errors, will call HARDERR for further action. +; Outputs: +; AL = 0 if no error, otherwise non-zero ; BP preserved. All other registers destroyed. - MOV AL,[BP+DEVNUM] + MOV AL,[BP+DRVNUM] MOV AH,0 CMP DX,[BP+FIRREC] RCR AH @@ -936,24 +946,23 @@ DWRITE: POP DI POP BX POP BP - JC DSKWRERR + JC HARDWRITE XOR AL,AL RET - -DSKWRERR: - MOV SI,WRERR +HARDWRITE: + MOV SI,WRTERRMES CALL HARDERR JP DWRITE HARDERR: SUB DI,CX - ADD DX,DI ;Next record to transfer - CALL RECTOBYT - ADD BX,DI ;Next location for transfer + ADD DX,DI + CALL SHFTDI7 + ADD BX,DI CALL OUTMES -GETRESP: +GETINSTR: CALL IN - OR AL,20H ;To lower-case + OR AL,20H CMP AL,"a" JZ ERROR CMP AL,"r" @@ -961,7 +970,7 @@ GETRESP: CMP AL,"i" JZ IGNORE CMP AL,"c" - JNZ GETRESP + JNZ GETINSTR POP AX MOV AL,1 RET @@ -972,7 +981,7 @@ IGNORE: ABORT: SEG CS - MOV DS,[TEMP] + MOV DS,[CSLOC] XOR AX,AX MOV ES,AX MOV SI,SAVEXIT @@ -986,7 +995,7 @@ ERROR: MOV AX,CS MOV DS,AX MOV ES,AX - CALL NOBUF + CALL WRTFATS XOR AX,AX MOV DS,AX MOV SI,EXIT @@ -1075,12 +1084,13 @@ SETUP: ; ES:DI point to FCB ; CX = No. of records to transfer ; BP = Base of drive parameters +; SI = FAT pointer ; [RECCNT] = Record count ; [RECPOS] = Record position in file ; [FCB] = DX ; [NEXTADD] = Displacement of disk transfer within segment ; [DSKERR] = 0 (no errors yet) -; [NUMTRNS] = 0 (No transfers yet) +; [TRANS] = 0 (No transfers yet) ; If SETUP detects no records will be transfered, it returns 1 level up ; with CX = 0. @@ -1094,7 +1104,7 @@ SETUP: MOV BX,[DMAADD] MOV [NEXTADD],BX MOV B,[DSKERR],0 - MOV [NUMTRNS],0 + MOV [TRANS],0 MOV SI,[BP+FAT] ADD BX,7FH ;See if there is any space left JC SEGEND @@ -1123,7 +1133,7 @@ FNDCLUS: ; Inputs: ; DS = CS -; CX = No. of clusters +; CX = No. of clusters to skip ; BP = Base of drive parameters ; SI = FAT pointer ; ES:DI point to FCB @@ -1214,16 +1224,16 @@ SETFCB: SEG ES MOV [DI+LSTCLUS],AX MOV AX,[RECPOS] - MOV BX,[NUMTRNS] + MOV BX,[TRANS] ADD AX,BX SEG ES CMP AX,[DI+FILSIZ] - JBE NOSZINC + JBE SAMSIZ SEG ES MOV [DI+FILSIZ],AX SEG ES MOV B,[DI+SIZCHG],-1 -NOSZINC: +SAMSIZ: DEC AX MOV DX,AX MOV CL,[BP+CLUSSHFT] @@ -1232,8 +1242,8 @@ NOSZINC: MOV [DI+CLUSPOS],DX MOV CX,BX RET -WRTERRJ: - JP WRTERR + +WRTERRJ:JP WRTERR HAVSTART: MOV CX,AX @@ -1245,7 +1255,7 @@ HAVSTART: JNC NOSKIP WRTERR: MOV B,[DSKERR],1 -ADDREC: +LVDSK: MOV AX,[RECPOS] XOR CX,CX MOV DI,[FCB] @@ -1256,9 +1266,9 @@ WRTEOF: MOV CX,AX CALL FNDCLUS OR CX,CX - JNZ ADDREC + JNZ LVDSK MOV DX,0FFFH - MOV B,[BP+DIRTY],-1 + MOV B,[BP+DIRTYFAT],-1 MOV DI,[FCB] MOV AX,[RECPOS] SEG ES @@ -1323,7 +1333,7 @@ WRTLP: JNZ WRTLP CALL SETFCB SEG ES - MOV B,[DI+FLSFLG],-1 + MOV B,[DI+DIRTYFIL],-1 RET @@ -1382,7 +1392,7 @@ FINCLUS: MOV SI,[NEXTADD] ADD BX,SI ;Adjust by size of transfer MOV [NEXTADD],BX - ADD [NUMTRNS],CX + ADD [TRANS],CX POP DX POP BX PUSH CX @@ -1407,7 +1417,7 @@ GETREC: ; Outputs: ; AX = Record number determined by EXTENT and NR fields ; DS:DI point to FCB -; No other registers affected. +; BX destroyed. No other registers affected. MOV DI,DX MOV AL,[DI+NR] @@ -1434,11 +1444,10 @@ ALLOCATE: ; IF insufficient space ; THEN ; Carry set -; CX = max. no. of records that could be added to file ; ELSE ; Carry clear ; BX = First cluster allocated -; FAT is fully updated including dirty flag +; FAT is fully updated including dirty bit ; FIRCLUS field of FCB set if file was null ; SI,BP unchanged. All other registers destroyed. @@ -1478,7 +1487,7 @@ HAVFRE: LOOP ALLOC MOV DX,0FFFH CALL PACK - MOV B,[BP+DIRTY],-1 + MOV B,[BP+DIRTYFAT],-1 POP BX CALL UNPACK XCHG BX,DI @@ -1534,7 +1543,7 @@ GETEOF: SRCHFRST: ;System call 17 - CALL GETNAME + CALL GETFILE SAVPLCE: ; Search-for-next enters here to save place and report ; findings. @@ -1574,7 +1583,7 @@ SRCHNXT: ;System call 18 FILESIZE: ;System call 35 PUSH DI PUSH DX - CALL GETNAME + CALL GETFILE POP DI POP ES MOV AL,-1 @@ -1603,14 +1612,14 @@ GETFATPT: ;System call 27 MOV AX,CS MOV DS,AX MOV [DSSAVE],CS - MOV BP,[CURDRV] - CALL LOADFAT + MOV BP,[CURDRVPT] + CALL FATREAD MOV BX,[BP+FAT] MOV AL,[BP+CLUSMSK] INC AL MOV DX,[BP+MAXCLUS] DEC DX - MOV B,[BP+DIRTY],-1 + MOV B,[BP+DIRTYFAT],-1 MOV [BXSAVE],BX MOV [DXSAVE],DX RET @@ -1620,7 +1629,7 @@ GETDSKPT: ;System call 31 SEG CS MOV [DSSAVE],CS SEG CS - MOV BX,[CURDRV] + MOV BX,[CURDRVPT] SEG CS MOV [BXSAVE],BX RET @@ -1632,12 +1641,13 @@ DSKRESET: ;System call 13 MOV AX,CS MOV DS,AX MOV [DMAADD],80H - MOV AX,[DRVTAB] - MOV [CURDRV],AX -NOBUF: - MOV CL,[NUMIO] + MOV AX,[CURDRVPT+2] + MOV [CURDRVPT],AX +WRTFATS: +; DS=CS. Writes back all dirty FATs. All registers destroyed. + MOV CL,[NUMDRV] MOV CH,0 - MOV SI,DRVTAB + MOV SI,CURDRVPT+2 WRTFAT: LODW PUSH CX @@ -1652,27 +1662,27 @@ WRTFAT: RET -GETDRV: ;System call 25 +CURDRV: ;System call 25 SEG CS - MOV BP,[CURDRV] - MOV AL,[BP+0] + MOV BP,[CURDRVPT] + MOV AL,[BP+DRVNUM] RET INUSE: ;System call 24 MOV AX,CS MOV DS,AX - MOV CL,[NUMIO] + MOV CL,[NUMDRV] MOV CH,0 MOV SI,CX SHL SI - ADD SI,CURDRV + ADD SI,CURDRVPT MOV BX,0 - STD + DOWN CHKUSE: LODW MOV BP,AX - TEST B,[BP+DIRTY],-1 + TEST B,[BP+DIRTYFAT],-1 JZ SETBIT STC SETBIT: @@ -1684,12 +1694,12 @@ SETBIT: SETRNDREC: ;System call 36 CALL GETREC - MOV [DI+RR],AX + MOV [DI+33],AX MOV AL,0 JZ BIGRR INC AL BIGRR: - MOV [DI+RR+2],AL + MOV [DI+35],AL RET @@ -1698,13 +1708,14 @@ SELDSK: ;System call 14 MOV BX,DX PUSH CS POP DS - CMP BL,[NUMIO] + CMP BL,[NUMDRV] JGE RET SHL BX - MOV AX,[BX+DRVTAB] - MOV [CURDRV],AX + MOV AX,[BX+CURDRVPT+2] + MOV [CURDRVPT],AX RET + BUFIN: ;System call 10 MOV AX,CS MOV ES,AX @@ -1744,13 +1755,13 @@ GETCH: JZ ENDLIN CMP AL,10 JZ PHYCRLF - CMP AL,CANCEL + CMP AL,"X"-"@" JZ KILNEW - CMP AL,27 + CMP AL,ESCCH JZ ESC SAVCH: CMP DH,DL - JNB GETCH + JAE GETCH STOB INC DH CALL OUT @@ -1831,7 +1842,7 @@ GETCH1: BAKTAB: PUSH DI DEC DI - STD + DOWN MOV CL,DH MOV AL," " PUSH BX @@ -1853,7 +1864,7 @@ HAVTAB: SUB BL,DH ADD CL,BL AND CL,7 - CLD + UP POP BX POP DI JZ OLDBAK @@ -1962,7 +1973,8 @@ EXITINS: MOV AH,0 JMP GETCH -ESCFUNC DW GETCH +ESCFUNC: + DW GETCH DW TWOESC DW EXITINS DW ENTERINS @@ -1990,7 +2002,6 @@ OUTCH: TEST B,[PFLAG],-1 JZ STATCHK CALL BIOSPRINT,BIOSSEG - STATCHK: CALL BIOSSTAT,BIOSSEG JZ RET @@ -1998,7 +2009,7 @@ INCHK: CALL BIOSIN,BIOSSEG CMP AL,'S'-'@' JNZ NOSTOP - CALL BIOSIN,BIOSSEG ;Eat Cntrl-S + CALL BIOSIN,BIOSSEG NOSTOP: CMP AL,'P'-'@' JZ PRINTON @@ -2013,12 +2024,10 @@ PRINTON: SEG CS MOV B,[PFLAG],1 RET - PRINTOFF: SEG CS MOV B,[PFLAG],0 RET - CTRLOUT: CMP AL,10 JZ OUTCH @@ -2039,7 +2048,6 @@ ZERPOS: SEG CS MOV B,[CARPOS],0 JP OUTCH - BACKPOS: SEG CS DEC B,[CARPOS] @@ -2077,7 +2085,7 @@ CONIN: ;System call 1 RET -IN: +IN: ;Internal input routine CALL INCHK JZ IN RET @@ -2133,7 +2141,7 @@ SETVECT: ; Interrupt call 37 NEWBASE: ; Interrupt call 38 MOV ES,DX SEG CS - MOV DS,[TEMP] + MOV DS,[CSLOC] XOR SI,SI MOV DI,SI MOV CX,80H @@ -2143,7 +2151,6 @@ NEWBASE: ; Interrupt call 38 SETMEM: ; Inputs: -; AX = Size of memory in paragraphs ; DX = Segment ; Function: ; Completely prepares a program base at the @@ -2156,7 +2163,7 @@ SETMEM: ; [5] to [9] form a long call to the entry point ; [10] to [13] have exit address (from INT 22H) ; [14] to [17] have ctrl-C exit address (from INT 23H) -; DX,BP unchanged. All other registers destroyed. +; AX,DX,BP unchanged. All other registers destroyed. XOR CX,CX MOV DS,CX @@ -2172,9 +2179,9 @@ SETMEM: SEG ES MOV [2],CX SUB CX,DX - CMP CX,0FFFH + CMP CX,MAXDIF JBE HAVDIF - MOV CX,0FFFH + MOV CX,MAXDIF HAVDIF: MOV BX,ENTRYPOINTSEG SUB BX,CX @@ -2189,7 +2196,8 @@ HAVDIF: MOV B,[5],LONGCALL RET -RECTOBYT: + +SHFTDI7: SHL DI SHL DI SHL DI @@ -2201,45 +2209,51 @@ RECTOBYT: ;***** DATA AREA ***** -BADFAT DB 13,10,"Bad FAT",13,10,"$" -ALLBAD DB 13,10,"All FATs on disk are bad",13,10,"$" -RDERR DB 13,10,"Disk read error",13,10,"$" -WRERR DB 13,10,"Disk write error",13,10,"$" -CARPOS DB 0 -STARTPOS DB 0 -PFLAG DB 0 -SRCHDON DB -1 -PDIR DS 2 -SRCHBP DS 2 -EXITHOLD DS 4 -ENDMEM DS 2 -FATBASE DS 2 -INBUF DS 255 -DIRBUF DS 128 -NUMIO DS 1 ;Number of disk tables -NAME1 DS 11 ;File name buffer -NAME2 DS 11 ;File name buffer -DMAADD DS 4 ;User's disk transfer address (disp/seg) -TEMP DS 2 -DSKERR DS 1 -FCB DS 2 ;Address of user FCB -RECPOS DS 2 -NEXTADD DS 2 -RECCNT DS 2 -CLUSNUM DS 2 -NUMTRNS DS 2 - DS 50 -AXSAVE DS 2 -BXSAVE DS 2 -CXSAVE DS 2 -DXSAVE DS 2 -SISAVE DS 2 -DISAVE DS 2 -BPSAVE DS 2 -DSSAVE DS 2 -ESSAVE DS 2 -SSSAVE DS 2 -SPSAVE DS 2 -CURDRV DS 2 + +BADMES: DB 13,10,"Bad FAT",13,10,"$" +BADFATMES:DB 13,10,"All FATs on disk are bad",13,10,"$" +RDERRMES:DB 13,10,"Disk read error",13,10,"$" +WRTERRMES:DB 13,10,"Disk write error",13,10,"$" + +CARPOS: DB 0 +STARTPOS:DB 0 +PFLAG: DB 0 +SRCHDON:DB -1 +PDIR: DS 2 +SRCHBP: DS 2 +EXITHOLD:DS 4 +ENDMEM: DS 2 +FATBASE:DS 2 +INBUF: DS 255 +DIRBUF: DS 128 +NUMDRV: DS 1 ;Number of drives +NAME1: DS 11 ;File name buffer +NAME2: DS 11 +DMAADD: DS 4 ;User's disk transfer address (disp/seg) +TEMP: +CSLOC: DS 2 +DSKERR: DS 1 +FCB: DS 2 ;Address of user FCB +RECPOS: DS 2 +NEXTADD:DS 2 +RECCNT: DS 2 +CLUSNUM:DS 2 +TRANS: DS 2 + + DS 50 ;Stack space +AXSAVE: DS 2 +BXSAVE: DS 2 +CXSAVE: DS 2 +DXSAVE: DS 2 +SISAVE: DS 2 +DISAVE: DS 2 +BPSAVE: DS 2 +DSSAVE: DS 2 +ESSAVE: DS 2 +STACK: +SSSAVE: DS 2 +SPSAVE: DS 2 + +CURDRVPT:DS 2 DRVTAB: ;Address of start of DPBs - \ No newline at end of file + \ No newline at end of file diff --git a/CHESS.A86 b/CHESS.A86 index 5d37c3c..5e2c466 100644 --- a/CHESS.A86 +++ b/CHESS.A86 @@ -11,10 +11,10 @@ ;*********************************************************** ; SYSTEM EQUATES ;*********************************************************** -INCHAR EQU 1 -PRINTBUF EQU 9 -INBUF EQU 10 -SYSTEM EQU 5 +INCHAR: EQU 1 +PRINTBUF:EQU 9 +INBUF: EQU 10 +SYSTEM: EQU 5 ;*********************************************************** ; EQUATES @@ -96,7 +96,7 @@ START: ORG START+80H PUT START+80H TBASE: EQU START+100H -;********************************************************** +;*********************************************************** ; DIRECT -- Direction Table. Used to determine the dir- ; ection of movement of each piece. ;*********************************************************** @@ -108,7 +108,7 @@ DIRECT: EQU $-TBASE DB +10,+10,+11,+09 DB -10,-10,-11,-09 ;*********************************************************** -; DPOINT -- Direction Table Pointer. Used to determine +; DPOINT -- Direction Table Pointer. Used to determine ; where to begin in the direction table for any ; given piece. ;*********************************************************** @@ -116,7 +116,7 @@ DPOINT: EQU $-TBASE DB 20,16,8,0,4,0,0 ;*********************************************************** -; DCOUNT -- Direction Table Counter. Used to determine +; DCOUNT -- Direction Table Counter. Used to determine ; the number of directions of movement for any ; given piece. ;*********************************************************** @@ -124,7 +124,7 @@ DCOUNT: EQU $-TBASE DB 4,4,8,4,4,8,8 ;*********************************************************** -; PVALUE -- Point Value. Gives the point value of each +; PVALUE -- Point Value. Gives the point value of each ; piece, or the worth of each piece. ;*********************************************************** PVALUE: EQU $-TBASE-1 @@ -132,7 +132,7 @@ PVALUE: EQU $-TBASE-1 ;*********************************************************** ; PIECES -- The initial arrangement of the first rank of -; pieces on the board. Use to set up the board +; pieces on the board. Use to set up the board ; for the start of the game. ;*********************************************************** PIECES: EQU $-TBASE @@ -140,7 +140,7 @@ PIECES: EQU $-TBASE ;*********************************************************** ; BOARD -- Board Array. Used to hold the current position -; of the board during play. The board itself +; of the board during play. The board itself ; looks like: ; FFFFFFFFFFFFFFFFFFFF ; FFFFFFFFFFFFFFFFFFFF @@ -156,15 +156,15 @@ PIECES: EQU $-TBASE ; FFFFFFFFFFFFFFFFFFFF ; The values of FF form the border of the ; board, and are used to indicate when a piece -; moves off the board. The individual bits of +; moves off the board. The individual bits of ; the other bytes in the board array are as ; follows: ; Bit 7 -- Color of the piece ; 1 -- Black ; 0 -- White ; Bit 6 -- Not used -; Bit 5 -- Not used -; Bit 4 --Castle flag for Kings only +; Bit 5 -- Pawn attack flag for ATTACK +; Bit 4 -- Castle flag for Kings only ; Bit 3 -- Piece has moved flag ; Bits 2-0 Piece type ; 1 -- Pawn @@ -180,16 +180,16 @@ BOARD: EQU $-TBASE BOARDA: DS 120 ;*********************************************************** -; ATKLIST -- Attack List. A two part array, the first +; ATKLIST -- Attack List. A two part array, the first ; half for white and the second half for black. ; It is used to hold the attackers of any given ; square in the order of their value. ; -; WACT -- White Attack Count. This is the first +; WACT -- White Attack Count. This is the first ; byte of the array and tells how many pieces are ; in the white portion of the attack list. ; -; BACT -- Black Attack Count. This is the eighth byte of +; BACT -- Black Attack Count. This is the eighth byte of ; the array and does the same for black. ;*********************************************************** ATKLST: DW 0,0,0,0,0,0,0 @@ -197,7 +197,7 @@ WACT: EQU ATKLST BACT: EQU ATKLST+7 ;*********************************************************** -; PLIST -- Pinned Piece Array. This is a two part array. +; PLIST -- Pinned Piece Array. This is a two part array. ; PLISTA contains the pinned piece position. ; PLISTD contains the direction from the pinned ; piece to the attacker. @@ -207,41 +207,41 @@ PLISTD: EQU PLIST+10 PLISTA: DW 0,0,0,0,0,0,0,0,0,0 ;*********************************************************** -; POSK -- Position of Kings. A two byte area, the first +; POSK -- Position of Kings. A two byte area, the first ; byte of which hold the position of the white ; king and the second holding the position of ; the black king. ; -; POSQ -- Position of Queens. Like POSK,but for queens. -;*********************************************************** +; POSQ -- Position of Queens. Like POSK,but for queens. +;************************************************************ POSK: DB 24,95 POSQ: DB 14,94 DB -1 -;*********************************************************** -; SCORE -- Score Array. Used during Alpha-Beta pruning to -; hold the scores at each ply. It includes two +;************************************************************ +; SCORE -- Score Array. Used during Alpha-Beta pruning to +; hold the scores at each ply. It includes two ; "dummy" entries for ply -1 and ply 0. -;*********************************************************** +;************************************************************ SCORE: DW 0,0,0,0,0,0 -;*********************************************************** -; PLYIX -- Ply Table. Contains pairs of pointers, a pair -; for each ply. The first pointer points to the +;************************************************************ +; PLYIX -- Ply Table. Contains pairs of pointers, a pair +; for each ply. The first pointer points to the ; top of the list of possible moves at that ply. ; The second pointer points to which move in the ; list is the one currently being considered. -;*********************************************************** +;************************************************************ PLYIX: DW 0,0,0,0,0,0,0,0,0,0 DW 0,0,0,0,0,0,0,0,0,0 -;*********************************************************** +;************************************************************ ; STACK -- Contains the stack for the program. -;*********************************************************** +;************************************************************ ORG START+2FFH STACK: -;*********************************************************** +;************************************************************ ; TABLE INDICES SECTION ; ; M1-M4 -- Working indices used to index into @@ -250,10 +250,10 @@ STACK: ; T1-T3 -- Working indices used to index into Direction ; Count, Direction Value, and Piece Value tables. ; -; INDX1 -- General working indices. Used for various +; INDX1 -- General working indices. Used for various ; INDX2 purposes. ; -; NPINS -- Number of Pins. Count and pointer into the +; NPINS -- Number of Pins. Count and pointer into the ; pinned piece list. ; ; MLPTRI -- Pointer into the ply table which tells @@ -262,7 +262,7 @@ STACK: ; MLPTRJ -- Pointer into the move list to the move that is ; currently being processed. ; -; SCRIX -- Score Index. Pointer to the score table for +; SCRIX -- Score Index. Pointer to the score table for ; the ply being examined. ; ; BESTM -- Pointer into the move list for the move that @@ -270,12 +270,12 @@ STACK: ; Alpha-Beta pruning process. ; ; MLLST -- Pointer to the previous move placed in the move -; list. Used during generation of the move list. +; list. Used during generation of the move list. ; ; MLNXT -- Pointer to the next available space in the move ; list. ; -;*********************************************************** +;************************************************************ ORG START+0 PUT START+0 M1: DW TBASE @@ -295,10 +295,10 @@ BESTM: DW 0 MLLST: DW 0 MLNXT: DW MLIST -;*********************************************************** +;************************************************************ ; VARIABLES SECTION ; -; KOLOR -- Indicates computer's color. White is 0, and +; KOLOR -- Indicates computer's color. White is 0, and ; Black is 80H. ; ; COLOR -- Indicates color of the side with the move. @@ -340,7 +340,7 @@ MLNXT: DW MLIST ; not on the move. ; ; MTRL -- A measure of the difference in material -; currently on the board. It is the total value of +; currently on the board. It is the total value of ; the white pieces minus the total value of the ; black pieces. ; @@ -355,7 +355,7 @@ MLNXT: DW MLIST ; BMOVES -- Our very tiny book of openings. Determines ; the first move for the computer. ; -;*********************************************************** +;************************************************************ KOLOR: DB 0 COLOR: DB 0 P1: DB 0 @@ -381,7 +381,7 @@ BMOVES: DB 35,55,10H DB 85,65,10H DB 84,64,10H -;*********************************************************** +;************************************************************ ; MOVE LIST SECTION ; ; MLIST -- A 2048 byte storage area for generated moves. @@ -392,7 +392,7 @@ BMOVES: DB 35,55,10H ; in the move list. ; ; MLPTR -- The Move List is a linked list of individual -; moves each of which is 6 bytes in length. The +; moves each of which is 6 bytes in length. The ; move list pointer(MLPTR) is the link field ; within a move. ; @@ -403,7 +403,7 @@ BMOVES: DB 35,55,10H ; board position to which the piece is moving. ; ; MLFLG -- A field in the move entry which contains flag -; information. The meaning of each bit is as +; information. The meaning of each bit is as ; follows: ; Bit 7 -- The color of any captured piece ; 0 -- White @@ -424,7 +424,7 @@ BMOVES: DB 35,55,10H ; MLVAL -- The field in the move entry which contains the ; score assigned to the move. ; -;*********************************************************** +;************************************************************ ORG START+300H PUT START+300H MLIST: DS 2048 @@ -435,11 +435,11 @@ MLTOP: EQU 3 MLFLG: EQU 4 MLVAL: EQU 5 -;*********************************************************** +;************************************************************ ; PROGRAM CODE SECTION -;*********************************************************** +;************************************************************ ; BOARD SETUP ROUTINE -;*********************************************************** +;************************************************************ ; FUNCTION: To initialize the board array, setting the ; pieces in their initial positions for the ; start of the game. @@ -449,7 +449,7 @@ MLVAL: EQU 5 ; CALLS: None ; ; ARGUMENTS: None -;*********************************************************** +;************************************************************* INITBD: MOV CX,60 ; Pre-fill board with -1's MOV DI,BOARDA MOV AX,-1 @@ -479,16 +479,16 @@ IB2: MOV AL,[SI-8] ; Fill non-border squares MOV B,[SI+3],94 RET -;*********************************************************** +;************************************************************ ; PATH ROUTINE -;*********************************************************** +;************************************************************ ; FUNCTION: To generate a single possible move for a given ; piece along its current path of motion including: - +; ; Fetching the contents of the board at the new ; position, and setting a flag describing the ; contents: -; 0 -- New position is empty +; 0 -- New postion is empty ; 1 -- Encountered a piece of the ; opposite color ; 2 -- Encountered a piece of the @@ -504,7 +504,7 @@ IB2: MOV AL,[SI-8] ; Fill non-border squares ; ; ARGUMENTS: Direction from the direction array giving the ; constant to be added for the new position. -;*********************************************************** +;************************************************************ PATH: ADD [M2],CL ; Add direction constant to previous position MOV SI,[M2] ; Load board index MOV AL,[SI+BOARD] ; Get contents of board @@ -523,9 +523,9 @@ PATH: ADD [M2],CL ; Add direction constant to previous position PA2: MOV AL,3 ; Set off board flag RET -;*********************************************************** +;************************************************************ ; PIECE MOVER ROUTINE -;*********************************************************** +;************************************************************ ; FUNCTION: To generate all the possible legal moves for a ; given piece. ; @@ -537,7 +537,7 @@ PA2: MOV AL,3 ; Set off board flag ; ENPSNT ; ; ARGUMENTS: The piece to be moved. -;*********************************************************** +;************************************************************* MPIECE: XOR AL,[BX] ; Piece to move AND AL,87H ; Clear flag bit CMP AL,BPAWN ; Is it a black Pawn ? @@ -624,7 +624,7 @@ MP36: CALL ENPSNT ; Try en passant capture ; ADJPTR ; ; ARGUMENTS: -- None -;*********************************************************** +;************************************************************ ENPSNT: MOV AL,[M1] ; Set position of Pawn TEST B,[P1],080H ; Check color, is it white ? JZ EP5 ; Yes - skip @@ -665,9 +665,9 @@ EP10: CMP AL,10 ; Is difference 10 ? MOV AL,[M3] ; Restore "from" position MOV [M1],AL -;*********************************************************** +;************************************************************ ; ADJUST MOVE LIST POINTER FOR DOUBLE MOVE -;*********************************************************** +;************************************************************ ; FUNCTION: -- To adjust move list pointer to link around ; second move in double move. ; @@ -679,16 +679,16 @@ EP10: CMP AL,10 ; Is difference 10 ? ; CALLS: -- None ; ; ARGUMENTS: -- None -;*********************************************************** +;************************************************************* ADJPTR: MOV BX,[MLLST] ; Get list pointer SUB BX,6 ; Back up list pointer MOV [MLLST],BX ; Save list pointer MOV [BX],0 ; Zero out link RET ; Return -;*********************************************************** +;************************************************************ ; CASTLE ROUTINE -;*********************************************************** +;************************************************************ ; FUNCTION: -- To determine whether castling is legal ; (Queen side, King side, or both) and add it ; to the move list if it is. @@ -700,7 +700,7 @@ ADJPTR: MOV BX,[MLLST] ; Get list pointer ; ADJPTR ; ; ARGUMENTS: -- None -;*********************************************************** +;************************************************************ CASTLE: TEST B,[P1],008H ; Has king moved ? JNZ RET ; Yes - return @@ -759,9 +759,9 @@ CA20: MOV AL,CH ; Scan Index MOV CX,01FCH ; Set Queen-side initial values JMP CA5 ; Jump -;*********************************************************** +;************************************************************ ; ADMOVE ROUTINE -;*********************************************************** +;************************************************************ ; FUNCTION: -- To add a move to the move list ; ; CALLED BY: -- MPIECE @@ -771,7 +771,7 @@ CA20: MOV AL,CH ; Scan Index ; CALLS: -- None ; ; ARGUMENT: -- None -;*********************************************************** +;************************************************************* ADMOVE: MOV DX,[MLNXT] ; Addr of next loc in move list MOV BX,MLEND ; Address of list end SUB BX,DX ; Calculate difference @@ -797,7 +797,7 @@ AM5: XCHG DX,DI ; Address of move area MOV [MLNXT],DI ; Save address for next move MOV DI,DX RET ; Return -AM10: MOV [BX],0 ; Abort entry on table ovflow +AM10: MOV [BX],0 ; Abort entry on table ovflow RET ;*********************************************************** @@ -915,27 +915,27 @@ ATTACK: PUSH CX ; Save Register CX CALL ATKADJ ; Scan adjacent squares MOV AH,KNIGHT ; Check for a Knight CALL ATKADJ ; Scan adjacent squares - MOV AH,20H ; Bit 5 set + MOV AH,20H ; Pawn attack flag MOV AL,[BP+11] ; Get piece at +11 AND AL,87H ; Clear flag bit CMP AL,BPAWN ; Black Pawn ? JNZ AT5 ; No - jump - OR [BP+11],AH ; Turn on bit 5 + OR [BP+11],AH ; Set Pawn attack flag AT5: MOV AL,[BP+9] ; Get piece at +9 AND AL,87H ; Clear flag bit CMP AL,BPAWN ; Black Pawn ? JNZ AT10 ; No - jump - OR [BP+9],AH ; Turn on bit 5 + OR [BP+9],AH ; Set Pawn attack flag AT10: MOV AL,[BP-11] ; Get piece at -11 AND AL,87H ; Clear flag bit CMP AL,PAWN ; White Pawn ? JNZ AT15 ; No - jump - OR [BP-11],AH ; Turn on bit 5 + OR [BP-11],AH ; Set Pawn attack flag AT15: MOV AL,[BP-9] ; Get piece at -9 AND AL,87H ; Clear flag bit CMP AL,PAWN ; White Pawn ? JNZ AT20 ; No - jump - OR [BP-9],AH ; Turn on bit 5 + OR [BP-9],AH ; Set Pawn attack flag AT20: MOV SI,DIRECT+TBASE ; Load direction table MOV AH,BISHOP ; Check for a Bishop CALL ATKOUT ; Scan outwards @@ -994,20 +994,20 @@ AO5: MOV DX,0C0H ; Bitmask for color flags MOV DI,BP ; Load pointer to piece AO10: ADD DI,BX ; Add direction constant MOV AL,[DI] ; Get attacking piece - AND AL,27H ; Get piece type and bit 5 + AND AL,27H ; Get piece type and Pawn attack flag JZ AO10 ; No piece, keep going CMP AL,AH ; Same as what we want ? JZ AO22 ; Yes - jump CMP AL,QUEEN ; Queen ? JZ AO20 ; Yes - jump - CMP AL,PAWN+20H ; Pawn with bit 5 ? + CMP AL,PAWN+20H ; Pawn with Pawn attack flag ? JZ AO21 ; Yes - jump AO15: LOOP AO5 ; Go check for next direction RET ; Return AO20: INC DH ; Set Queen found flag -AO21: AND B,[DI],0DFH ; Remove bit 5 for piece +AO21: AND B,[DI],0DFH ; Remove Pawn attack flag AO22: MOV AL,[DI] ; Get piece - ADD AL,80H ; CY if back, NC if white + ADD AL,80H ; CY if black, NC if white RCR AL ; Bit 7 set if black, bit 6 if white AND DL,AL ; Keep only bits 6 and 7 JZ AO15 ; Nothing, next direction @@ -1030,7 +1030,8 @@ AO22: MOV AL,[DI] ; Get piece ; the aforementioned routines as soon as an ; attacker of the opposite color is encountered. ; -; CALLED BY: -- ATTACK +; CALLED BY: -- ATKADJ +; ATKOUT ; ; CALLS: -- None ; @@ -1046,16 +1047,16 @@ ATKCHK: MOV AL,[DI] ; Get piece MOV AX,0DFFFH ; FF (border) in AL and DF in AH CMP [BP+9],AL ; Is +9 border ? JZ ACK5 ; Yes, jump - AND [BP+9],AH ; Remove bit 5 for piece + AND [BP+9],AH ; Remove Pawn attack flag ACK5: CMP [BP+11],AL ; Is +11 border ? JZ ACK6 ; Yes - jump - AND [BP+11],AH ; Remove bit 5 for piece + AND [BP+11],AH ; Remove Pawn attack flag ACK6: CMP [BP-9],AL ; Is -9 border ? JZ ACK7 ; Yes - jump - AND [BP-9],AH ; Remove bit 5 for piece + AND [BP-9],AH ; Remove Pawn attack flag ACK7: CMP [BP-11],AL ; Is -11 border ? JZ ACK8 ; Yes - jump - AND [BP-11],AH ; Remove bit 5 for piece + AND [BP-11],AH ; Remove Pawn attack flag ACK8: MOV AL,1 ; Set attacker found flag POP CX ; Restore CX reg RET ; Return from ATTACK @@ -2304,4 +2305,4 @@ IY: DS 2 BC: DS 2 DE: DS 2 HL: DS 2 - \ No newline at end of file + \ No newline at end of file diff --git a/COMMAND.A86 b/COMMAND.A86 index 23466eb..beb5e3c 100644 --- a/COMMAND.A86 +++ b/COMMAND.A86 @@ -1,25 +1,25 @@ -FCB EQU 5CH -DSKRESET EQU 13 -SETBASE EQU 38 -SRCHFRST EQU 17 -SRCHNXT EQU 18 -RENAM EQU 23 -INCHAR EQU 1 -GETFAT EQU 27 -OPEN EQU 15 -CLOSE EQU 16 -MAKE EQU 22 -DELETE EQU 19 -RDBLK EQU 39 -WRBLK EQU 40 -SETDMA EQU 26 -SELDRV EQU 14 -GETDRV EQU 25 -PRINTBUF EQU 9 -OUTCH EQU 2 -INBUF EQU 10 -RR EQU 33 -SYSTEM EQU 5 +FCB: EQU 5CH +DSKRESET:EQU 13 +SETBASE:EQU 38 +SRCHFRST:EQU 17 +SRCHNXT:EQU 18 +RENAM: EQU 23 +INCHAR: EQU 1 +GETFAT: EQU 27 +OPEN: EQU 15 +CLOSE: EQU 16 +MAKE: EQU 22 +DELETE: EQU 19 +RDBLK: EQU 39 +WRBLK: EQU 40 +SETDMA: EQU 26 +SELDRV: EQU 14 +GETDRV: EQU 25 +PRINTBUF:EQU 9 +OUTCH: EQU 2 +INBUF: EQU 10 +RR: EQU 33 +SYSTEM: EQU 5 ORG 100H PUT 100H @@ -87,7 +87,7 @@ GETCOM: PUSH SI COMTAIL: LODB - STOB ;Move command tail to 80H + STOB ;Move command tail to 80H CMP AL,13 LOOPNZ COMTAIL NOT CL @@ -113,16 +113,17 @@ FINDCOM: LAHF ADD SI,CX ;Bump to next position without affecting flags SAHF - LODW ;Get address of command + LODW ;Get address of command JNZ FINDCOM - CALL AX ;Call command + CALL AX ;Call command JMP COMMAND -SETDRV1: - JMP SETDRV + +SETDRVJ:JMP SETDRV + DRVCHK: DEC DL ;Adjust for correct drive number DEC AL ;Check if anything else is on line - JZ SETDRV1 + JZ SETDRVJ EXTERNAL: MOV AL,[SPECDRV] MOV [IDLEN],AL @@ -308,7 +309,7 @@ TYPE: MOV AH,OPEN INT 33 OR AL,AL - JNZ RET ; Not found + JNZ RET ;Not found MOV [FCB+RR],0 MOV CX,512 MOV AH,RDBLK @@ -354,11 +355,11 @@ CLRDSK: MOV DI,BX MOV AX,0FFFFH STOW - STOB ;Fill first 3 bytes with FF - INC AX ;AX = 0 + STOB ;Fill first 3 bytes with FF + INC AX ;AX = 0 SHR CX JNC DOFILL - STOB ;Odd byte + STOB ;Odd byte DOFILL: REP STOW @@ -378,7 +379,7 @@ COPY: MOV SI,FCB+10H MOV DI,DSTFCB MOVB - CMP B,[SI]," " ;Has file name? + CMP B,[SI]," " ;Has file name? JNZ HASDSTNAM MOV SI,FCB+1 HASDSTNAM: @@ -446,16 +447,19 @@ ID: DS 8 COM: DB "COM" DSTFCB: DS 36 -LINBUF: DB 80H,1,13 +LINBUF: + DB 80H,1,13 DS 80H -FILIFO: DB 8," " +FILIFO: + DB 8," " DB 0 DB 12," ",4,0 DB 12," ",8,0 DB 0 -COMTAB: DB 4,"DIR" +COMTAB: + DB 4,"DIR" DW DIR DB 7,"RENAME" DW RENAME @@ -472,4 +476,4 @@ COMTAB: DB 4,"DIR" DB 0 TPA: - \ No newline at end of file + \ No newline at end of file diff --git a/EDLIN.A86 b/EDLIN.A86 index 8221880..08b2e54 100644 --- a/EDLIN.A86 +++ b/EDLIN.A86 @@ -1,18 +1,18 @@ -FCB EQU 5CH -RENAM EQU 23 -OPEN EQU 15 -CLOSE EQU 16 -MAKE EQU 22 -DELFIL EQU 19 -RDBLK EQU 39 -WRBLK EQU 40 -SETDMA EQU 26 -PRINTBUF EQU 9 -OUTCH EQU 2 -INBUF EQU 10 -RR EQU 33 +FCB: EQU 5CH +RENAM: EQU 23 +OPEN: EQU 15 +CLOSE: EQU 16 +MAKE: EQU 22 +DELFIL: EQU 19 +RDBLK: EQU 39 +WRBLK: EQU 40 +SETDMA: EQU 26 +PRINTBUF:EQU 9 +OUTCH: EQU 2 +INBUF: EQU 10 +RR: EQU 33 -PROMPT EQU "*" +PROMPT: EQU "*" ORG 100H PUT 100H @@ -198,15 +198,12 @@ MAXLIN: RET -COMTAB DB "SFDLIE",13 +COMTAB: DB "SFDLIE",13 -NUMCOM EQU $-COMTAB +NUMCOM: EQU $-COMTAB -;-----------------------------------------------------------------------; -; Carefull changing the order of the next two tables. They are -; linked and chnges should be be to both. - -TABLE DW NOCOM ;No command--edit line +TABLE: + DW NOCOM ;No command--edit line DW ENDED DW INSERT DW LIST @@ -668,14 +665,14 @@ PARAM2: DS 2 QFLG: DS 1 HAVEOF: DS 1 OLDLEN: DS 1 -CURRENT: DS 2 -POINTER: DS 2 +CURRENT:DS 2 +POINTER:DS 2 LAST: DS 2 ENDTXT: DS 2 COMBUF: DS 2+128 -EDITBUF: DS 2+255 +EDITBUF:DS 2+255 DS 40 ALIGN STACK: START: - \ No newline at end of file + \ No newline at end of file diff --git a/RDCPM.A86 b/RDCPM.A86 index a6ddb1b..a519eaa 100644 --- a/RDCPM.A86 +++ b/RDCPM.A86 @@ -1,14 +1,14 @@ -FCB EQU 5CH -FCB2 EQU 6CH -OPEN EQU 15 -CLOSE EQU 16 -MAKE EQU 22 -DELETE EQU 19 -SEQWRT EQU 21 -SETDMA EQU 26 -GETDRV EQU 25 -PRINTBUF EQU 9 -SYSTEM EQU 5 +FCB: EQU 5CH +FCB2: EQU 6CH +OPEN: EQU 15 +CLOSE: EQU 16 +MAKE: EQU 22 +DELETE: EQU 19 +SEQWRT: EQU 21 +SETDMA: EQU 26 +GETDRV: EQU 25 +PRINTBUF:EQU 9 +SYSTEM: EQU 5 ORG 100H PUT 100H @@ -217,17 +217,17 @@ DSTFCB: DS 32 DIRBUF: DS 128 SECBUF: DS 128 -SPT EQU 0 -BLKSFT EQU 2 -BLKMSK EQU 3 -EXTMSK EQU 4 -DSISIZ EQU 5 -NUMENT EQU 7 -ALBMP0 EQU 9 -ALBMP1 EQU 10 -DIRCKS EQU 11 -RESTRK EQU 13 -XLTTBL EQU 15 +SPT: EQU 0 +BLKSFT: EQU 2 +BLKMSK: EQU 3 +EXTMSK: EQU 4 +DSISIZ: EQU 5 +NUMENT: EQU 7 +ALBMP0: EQU 9 +ALBMP1: EQU 10 +DIRCKS: EQU 11 +RESTRK: EQU 13 +XLTTBL: EQU 15 ;Below is the definition for standard single-density 8" drives @@ -257,4 +257,4 @@ CPMTAB2: DW 0,0,0,0 DW 0,0,0,0 DW 0,0,0,0 - \ No newline at end of file + \ No newline at end of file diff --git a/README.md b/README.md index d69d455..c0a9568 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@ By accessing and using the reconstructed source code provided in this repository *See [Building 86-DOS 0.11](./Building.md).* ## Special Thanks -* [@TimPaterson](https://github.com/TimPaterson) - For writing this amazing OS. +* [@TimPaterson](https://github.com/TimPaterson) - For writing this amazing OS and providing the source code of 86-DOS 1.00. * [@geneb](https://github.com/geneb) - For providing a copy of 86-DOS 0.11. -* [@LucasBrooks](https://github.com/LucasBrooks) - For providing an 86-DOS 1.14 kernel disassembly and for documenting the DPB structure. * [@RichCini](https://github.com/RichCini) - For figuring out some hard-to-decipher logic and for testing and debugging the reconstructed Tarbell-specific code on physical hardware. diff --git a/SYS.A86 b/SYS.A86 index b645695..7216589 100644 --- a/SYS.A86 +++ b/SYS.A86 @@ -1,4 +1,4 @@ -FCB EQU 5CH +FCB: EQU 5CH ORG 100H PUT 100H @@ -53,4 +53,4 @@ ERWRIT: DB "Disk write error$" DRVBAD: DB "Bad drive specification" END: - \ No newline at end of file + \ No newline at end of file