home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
SIMTEL
/
CPMUG
/
CPMUG019.ARK
/
ADE.ASM
next >
Wrap
Assembly Source File
|
1984-04-29
|
17KB
|
552 lines
; ADE - ABSOLUTE DISK EDITOR
;
; L.E. HUGHES
; 8080 SOFTWARE DEVELOPMENT CENTER
; 1506 MYRICK ROAD
; TALLAHASSEE, FLORIDA 32303
;
; JULY, 1977
;
; *ADE* ALLOWS THE USER TO EDIT ABSOLUTE SECTORS AND/OR
; TRACKS ON A 3740 COMPATIBLE DISKETTE. THE USER SHOULD BE
; VERY FAMILIAR WITH THE CP/M FILE STRUCTURE BEFORE CHANGING
; SECTORS ON A DISKETTE CONTAINING CP/M FILES. THE
; FOLLOWING COMMANDS ARE CURRENTLY AVAILABLE:
;
; DX,Y - DUMP TRACK X, SECTOR Y TO CONSOLE
; DX - DUMP ALL OF TRACK X TO CONSOLE
; D - DUMP ENTIRE DISK TO CONSOLE
;
; LX,Y - LIST TRACK X, SECTOR Y TO PRINTER
; LX - LIST ALL OF TRACK X TO PRINTER
; L - LIST ENTIRE DISK TO PRINTER
;
; I - SET INTERLACE SECTOR MAPPING
; A - SET ABSOLUTE SECTOR MAPPING
; X - EXIT TO CP/M
; ABSOLUTE DISK I/O ENTRY POINTS
MSIZE EQU 32
BASE EQU MSIZE*1024-300H
SELDSK EQU BASE+1BH ;SELECT DISK
SETTRK EQU BASE+1EH ;SET TRACK ADDRESS
SETSEC EQU BASE+21H ;SET SECTOR ADDRESS
SETDMA EQU BASE+24H ;SET DMA ADDRESS
RDABS EQU BASE+27H ;READ ABSOLUTE SECTOR
WRABS EQU BASE+2AH ;WRITE ABSOLUTE SECTOR
; BDOS ENTRY POINT AND FUNCTION CODES
BDOS EQU 0005H
RCFC EQU 1 ;READ CONSOLE
WCFC EQU 2 ;WRITE CONSOLE
CCFC EQU 11 ;CHECK CONSOLE (FOR RDA)
; MISC. EQUATES
DBUF EQU 80H
CR EQU 0DH
LF EQU 0AH
DEL EQU 7FH
IOBYT EQU 0003H
; MAIN PROGRAM
ORG 100H
ADE: LXI H,0 ;DO THE STACK POINTER TRICK
DAD SP
SHLD OLDSP
LXI SP,STACK+64
LDA IOBYT
STA OLDIO
XRA A ;DEFAULT TO ABS MODE
STA MODE
LXI H,ADES1 ;PRINT HEADING
CALL WASC
ADE1: CALL WEOLC ;ISSUE PROMPT SEQUENCE
MVI A,'?'
CALL WACC
LXI H,IBUF ;READ COMMAND INTO IBUF
CALL RASC
CALL WEOLC ;WRITE END-OF-LINE TO CONSOLE
LXI H,IBUF ;PARSE COMMAND
MOV A,M ;FETCH COMMAND CODE
INX H
CPI 141Q ;IF LC, CONVERT TO UC
JC $+5
SUI 40Q
STA CODE
MOV A,M ;CHECK FIRST PARAM.
CPI CR ;JUMP IF NOT END-OF-LINE
JNZ ADE2
MVI A,77 ;SET 'ALL TRACKS' FLAG
STA NTRKS
MVI A,0
STA TRK
MVI A,26 ;SET 'ALL SECTORS' FLAG
STA NSECS
MVI A,1
STA SEC
JMP ADE6
ADE2: CALL DDB ;DECODE FIRST PARAM. INTO A
JC ADEX ;EXIT ON ERROR
STA TRK ;ELSE STORE PARAM.
MVI A,1
STA NTRKS
ADE3: MOV A,M ;IF COMMA, SKIP IT
CPI ','
JNZ $+4
INX H ;ELSE SKIP COMMA
MOV A,M ;CHECK SECOND PARAM.
CPI CR ;JUMP IF NOT END-OF-LINE
JNZ ADE4
MVI A,26 ;SET 'ALL SECTORS' FLAG
STA NSECS
MVI A,1
STA SEC
JMP ADE6
ADE4: CALL DDB ;DECODE SECOND PARAM. INTO A
JC ADEX ;EXIT ON ERROR
STA SEC ;SAVE SECOND PARAM.
MVI A,1
STA NSECS
ADE6: LDA CODE ;FETCH COMMAND CODE
CPI 'D' ;WAS IT 'D' FOR DUMP
JNZ ADE7
CALL DAS ;DUMP ABSOLUTE SECTORS
JMP ADE1 ;LOOP
ADE7: CPI 'L' ;WAS IT 'L' FOR LIST
JNZ ADE8
LXI H,IOBYT ;FETCH I/O MAP
MOV A,M
STA OLDIO ;SAVE IT
ANI 0FCH ;DISCARD OLD CONSOLE ASSIGNMENT
MOV M,A
ANI 0C0H ;COPY LIST ASSIGNMENT INTO IT
RLC
RLC
ORA M
MOV M,A
CALL DAS ;LIST ABSOLUTE SECTOR(S)
LDA OLDIO ;RESTORE OLD I/O MAP
STA IOBYT
JMP ADE1
ADE8: CPI 'I' ;JUMP IF NOT 'I'
JNZ ADE9
MVI A,1 ;SET MODE = INTERLACE
STA MODE
JMP ADE1
ADE9: CPI 'A' ;JUMP IF NOT 'A'
JNZ ADEA
XRA A ;SET MODE = ABSOLUTE
STA MODE
JMP ADE1
ADEA: CPI 'X' ;JUMP IF NOT 'X'
JNZ ADEB
LHLD OLDSP ;CLEAN UP ACT AND GO HOME TO MAMA
SPHL
RET
ADEB: LXI H,ADES2 ;PRINT 'ILLEGAL COMMAND'
CALL WASC
JMP ADE1
ADEX: LXI H,ADES3 ;PRINT 'SYNTAX ERROR'
CALL WASC
JMP ADE1
ADES1: DB 'ABSOLUTE DISK EDITOR V1.0',CR,LF,0
ADES2: DB 'ILLEGAL COMMAND',CR,LF,0
ADES3: DB 'SYNTAX ERROR',CR,LF,0
; DAS - DUMP ABSOLUTE DISK SECTOR(S)
DAS: LDA TRK ;SET ABSOLUTE TRACK
CALL SAT
JC DASX ;EXIT IF ILLEGAL TRACK NO.
DAS1: LDA SEC ;SET ABSOLUTE SECTOR
CALL SAS
JC DASX ;EXIT IF ILLEGAL SECTOR NO.
CALL RAS ;READ ABSOLUTE SECTOR INTO DBUF
CMA ;DISPLAY STATUS ON LIGHTS
OUT 0FFH
CMA
CALL WEOLC ;START NEW LINE
LXI H,DASS1 ;PRINT 'DUMP OF TRACK '
CALL WASC
LDA TRK
CALL WDBC ;PRINT TRACK NUMBER (DECIMAL)
LDA MODE ;PRINT MODE (ABS OR ISN)
ORA A
JNZ DAS2
LXI H,DASS4
JMP DAS3
DAS2: LXI H,DASS5
DAS3: CALL WASC
LXI H,DASS2 ;PRINT ' SECTOR '
LXI H,DASS2 ;PRINT ', SECTOR '
CALL WASC
LDA SEC ;PRINT SECTOR NUMBER (DECIMAL)
CALL WDBC
CALL WEOLC ;WRITE END OF LINE
LXI H,0 ;CLEAR DUMP ADDR
SHLD DMPAD
LXI H,DBUF ;DUMP DBUF TO CONOSOLE
LXI D,128
CALL DUMPC
LDA SEC ;SEC = SEC + 1
INR A
STA SEC
LDA NSECS ;NSECS = NSECS-1
DCR A
STA NSECS
JNZ DAS1 ;LOOP IF STILL NON-ZERO
MVI A,1 ;ELSE SET SEC = 1
STA SEC
MVI A,26 ;AND SET NSECS = 26
STA NSECS
LDA TRK ;THEN SET TRK=TRK+1
INR A
STA TRK
LDA NTRKS ;NTRKS = NTRKS - 1
DCR A
STA NTRKS
JNZ DAS ;LOOP IF STILL NON-ZERO
RET ;ELSE ALL DONE!
DASX: LXI H,DASS3 ;PRINT 'ILLEGAL ADDRESS'
JMP WASC ;AND RETURN
DASS1: DB 'DUMP OF TRACK ',0
DASS2: DB ' SECTOR ',0
DASS4: DB ', ABS',0
DASS5: DB ', ISN',0
DASS3: DB 'ILLEGAL ADDRESS',CR,LF,0
; WDBC - WRITE DECIMAL BYTE TO CONSOLE
WDBC: PUSH PSW ;SAVE REGS
PUSH B
MVI B,0
WDBC1: CPI 100 ;B = A/100, A = REMAINDER
JC WDBC2
SUI 100
INR B
JMP WDBC1
WDBC2: MOV C,A ;PRINT HUNDREDS DIGIT
MOV A,B
ADI '0'
CALL WACC
MOV A,C
MVI B,0 ;B = A/10, A = REMAINDER
WDBC3: CPI 10
JC WDBC4
SUI 10
INR B
JMP WDBC3
WDBC4: MOV C,A ;PRINT TENS DIGIT
MOV A,B
ADI '0'
CALL WACC
MOV A,C ;PRINT ONES DIGIT
ADI '0'
CALL WACC
POP B ;RESTORE REGS
POP PSW
RET
; DUMPC - DUMP MEMORY IN HEX (TO CONSOLE)
;
; ENTRY CONDITIONS
; HL - FWA OF BLOCK TO DUMP
; DE - NUMBER OF BYTES TO DUMP
; DMPAD - ADDRESS TO BE PRINTED AT START OF LINE
; AUTOMATICALLY INCREMENTED. INIT BY USER.
DUMPC: MOV A,D ;EXIT IF DONE
ORA E
JZ WEOLC
CALL CHECK ;JUMP IF NO RDA FROM CONSOLE
CPI 1
JNZ DUMP0
CALL RACC ;DISCARD CHAR
LXI SP,STACK+64 ;ABORT DUMP OR LIST
LDA OLDIO
STA IOBYT
JMP ADE1
DUMP0: CALL WEOLC ;START NEW LINE
LDA DMPAD+1 ;WRITE DUMP ADDRESS IN HEX
CALL WHBC
LDA DMPAD
CALL WHBC
PUSH H
PUSH D
MVI C,16 ;NUMBER OF BYTES PER LINE
DUMP1: MOV A,D ;JUMP IF DONE
ORA E
JZ DUMP2
MVI A,' ' ;PRINT 1 BLANK
CALL WACC
MOV A,M ;FETCH NEXT BYTE
INX H
CALL WHBC ;WRITE TO CONSOLE IN HEX
PUSH H ;INCREMENT DUMP ADDRESS
LHLD DMPAD
INX H
SHLD DMPAD
POP H
DCX D ;DECREMENT COUNT
DCR C ;CONTINUE UNTIL 16 BYTES DUMPED
JNZ DUMP1
JMP DUMP3 ;GO DUMP BYTES IN ASCII
DUMP2: INR C ;EXIT WHEN C=0
DCR C
JZ DUMP3
MVI A,' ' ;PRINT 3 SPACES
CALL WACC
CALL WACC
CALL WACC
DCR C ;CONTINUE
JMP DUMP2
DUMP3: POP D ;RESTORE COUNT
POP H ;RESTORE POINTER
MVI A,' ' ;PRINT 2 SPACES
CALL WACC
CALL WACC
MVI C,16 ;NUMBER OF BYTES PER LINE
DUMP4: MOV A,D ;EXIT VIA WEOLC IF DONE
ORA E
JZ WEOLC
MOV A,M ;FETCH NEXT BYTE
INX H
ANI 177Q ;DISCARD PARITY BIT
CPI 40Q ;SUBSTITUTE PERIOD FOR CONTROL CODES
JNC $+5
MVI A,'.'
CALL WACC ;PRINT BYTE IN ASCII
DCX D ;DECREMENT COUNT
DCR C ;CONTINUE UNTIL C=0
JNZ DUMP4
JMP DUMPC ;PROCEED TO NEXT LINE
; WHBC - WRITE HEX BYTE TO CONSOLE
WHBC: PUSH PSW ;PRINT FIRST DIGIT
RRC
RRC
RRC
RRC
CALL WHDC
POP PSW ;PRINT SECOND DIGIT
PUSH PSW
CALL WHDC
POP PSW
RET
; WHDC - WRITE HEX DIGIT TO CONSOLE
WHDC: ANI 0FH ;DISCARD TOP 4 BITS
CPI 10 ;ADJUST 10-15
JC $+5
ADI 7
ADI '0'
JMP WACC ;GO PRINT DIGIT
; WEOLC - WRITE END-OF-LINE TO CONSOLE
WEOLC: MVI A,CR
CALL WACC
MVI A,LF
JMP WACC
; WASC - WRITE ASCII STRING TO CONSOLE
WASC: MOV A,M ;FETCH NEXT BYTE IN STRING
ORA A ;RETURN IF END-OF-STRING
RZ
CALL WACC ;PRINT CHAR
INX H ;ADVANCE TO NEXT CHAR
JMP WASC
; WACC - WRITE ASCII CHARACTER TO CONSOLE
WACC: PUSH H
PUSH D
PUSH B
PUSH PSW
MOV E,A
MVI C,WCFC
CALL BDOS
POP PSW
POP B
POP D
POP H
RET
; RASC - READ ASCII STRING FROM CONSOLE
RASC: PUSH H ;SAVE BUFFER POINTER
MVI B,0 ;COUNT = 0
RASC1: CALL RACC ;READ NEXT CHAR FROM CONSOLE
CPI 'U'-100Q ;JUMP IF NOT CTRL-U
JNZ RASC2
CALL WEOLC ;ABORT OLD LINE
POP H ;RESTORE BUFFER POINTER
JMP RASC ;START OVER
RASC2: CPI DEL ;JUMP IF NOT DEL
JNZ RASC3
INR B ;IGNORE DEL IF IBUF EMPTY
DCR B
JZ RASC1
DCX H
MOV A,M ;ECHO DELETED CHAR TO CONSOLE
CALL WACC
DCR B ;DECREMENT COUNT
JMP RASC1
RASC3: MOV M,A ;STORE CHAR IN BUFFER
INX H ;INCREMENT BUFFER POINTER
INR B ;INCREMENT COUNT
CPI CR ;LOOP UNTIL CR
JNZ RASC1
POP H ;RESTORE BUFFER POINTER
RET ; AND RETURN
; RACC - READ ASCII CHARACTER FROM CONSOLE
RACC: PUSH H
PUSH D
PUSH B
MVI C,RCFC
CALL BDOS
POP B
POP D
POP H
RET
; CHECK - CHECK CONSOLE (FOR RDA)
CHECK: PUSH H
PUSH D
PUSH B
MVI C,CCFC
CALL BDOS
POP B
POP D
POP H
RET
; DDB - DECODE DECIMAL BYTE
DDB: PUSH B
XRA A ;CLEAR TEMPORARY
STA DDBT
DDB1: MOV A,M ;FETCH NEXT BYTE
CPI ',' ;EXIT IF DELIMITER
JZ DDB2
CPI CR
JZ DDB2
INX H
SUI '0' ;CONVERT FROM ASCII
JC DDBX
CPI 10
JNC DDBX
MOV B,A ;SAVE NEW DIGIT
LDA DDBT ;TEMP = TEMP * 10
ADD A
MOV C,A
ADD A
ADD A
ADD C
ADD B ;TEMP = TEMP + NEW DIGIT
STA DDBT
JMP DDB1
DDB2: POP B ;NORMAL EXIT
LDA DDBT
STC
CMC
RET
DDBX: POP B ;ERROR EXIT
XRA A
STC
RET
; ABSOLUTE DISK I/O SUBROUTINES
; SAT - SET ABSOLUTE TRACK
SAT: CPI 77 ;EXIT IF A>76
JNC SATX
STA TRKNO
STC ;NORMAL EXIT
CMC
RET
SATX: STC ;ERROR EXIT
RET
; SAS - SET ABSOLUTE SECTOR
SAS: CPI 1 ;EXIT IF A<1
JC SASX
CPI 27 ;EXIT IF A>26
JNC SASX
STA SECNO
STC ;NORMAL EXIT
CMC
RET
SASX: STC ;ERROR EXIT
RET
; RAS - READ ABSOLUTE SECTOR
RAS: PUSH H
PUSH D
PUSH B
LDA TRKNO
MOV C,A
CALL SETTRK
LDA MODE
ORA A
JNZ RAS1
LDA SECNO
JMP RAS2
RAS1: LDA SECNO
LXI H,LPMAP-1
ADD L
MOV L,A
JNC $+4
INR H
MOV A,M
RAS2: MOV C,A
CALL SETSEC
CALL RDABS
POP B
POP D
POP H
RET
; LPMAP - LOGICAL/PHYSICAL SECTOR MAP
LPMAP: DB 01,07,13,19,25,05,11,17,23,03,09,15,21
DB 02,08,14,20,26,06,12,18,24,04,10,16,22
; SCRATCH RAM AREA
OLDSP: DS 2
STACK: DS 2
IBUF: DS 256
CODE: DS 1
NTRKS: DS 1
TRK: DS 1
NSECS: DS 1
SEC: DS 1
DMPAD: DS 1
OLDIO: DS 1
DDBT: DS 1
MODE: DS 1
TRKNO: DS 1
SECNO: DS 1
END