home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / ampro / diskpram.asm < prev    next >
Encoding:
Assembly Source File  |  1994-09-02  |  9.9 KB  |  513 lines

  1. ; DISKPRAM.ASM
  2. ; DISKPRAM intended use is to determine the the values of the DISK
  3. ; PARAMETER BLOCK and the SKEW TRANSLATION TABLE of a system alien
  4. ; to Ampro MULTIDSK program.  After the host system parameters are
  5. ; are determined ESET may be used to set up the E: drive on the 
  6. ; AMPRO system
  7. ;
  8. ; DISKPRAM displays the disk parameter block and the skew translation
  9. ; table maintained in the target cp/m 2.2 bios in any selected system
  10. ;
  11. ; DISKPRAM is the conbination of DPB.ASM and SKEW.ASM by 
  12. ; Robert C. Kuhman, Sysop of the Cro's Nest RCP/M. 
  13. ;
  14. ;****************************************************************
  15. ; Revisions:
  16. ;        V1.00 as of 27/10/84  Fred Willink
  17. ;****************************************************************
  18. ;
  19. BOOT    EQU    0        ;
  20. BDOS    EQU    05H        ;
  21. FCB1    EQU    5CH        ;
  22. ;
  23. ;  other equates
  24. ;
  25. ACROSS    EQU    8
  26. ;
  27. ; ampro bios disk id save area
  28. ;
  29. ; ascii equates
  30. ;
  31. BELL    EQU    07H        ; bell
  32. TAB    EQU    09H        ; horz tab
  33. LF    EQU    0AH        ; line feed
  34. CR    EQU    0DH        ; carriage return
  35. SPC    EQU    20H        ; space
  36. ;
  37.     ORG    100H
  38. ;
  39. START:    LXI    H,0
  40.     DAD    SP        ; hl=ccp stack pointer
  41.     LXI    SP,STACK    ; set up local stack
  42.     PUSH    H        ; save the ccp pointer for return
  43. TEST:    LDA    FCB1+1
  44.     CPI    '/'
  45.     JZ    HELP        ; help
  46.     CPI    '?'
  47.     JZ    HELP
  48.     CALL    DPB
  49.     CALL    SKEW
  50.     JMP    EXIT
  51. ;
  52. HELP:    LXI    H,HLPMSG    ; point to help message
  53.     CALL    COSTR        ; display help
  54. ;
  55. ; exit no warm boot
  56. ;
  57. EXIT:    POP    H        ; recover ccp"s stack ptr
  58.     SPHL
  59.     RET
  60. ;
  61. DPB:    LDA    FCB1        ; drive code given ?
  62.     DCR    A        ; convert a=1 to 0
  63.     JP    DPB2
  64.     CALL    FCN25
  65. DPB2:    MOV    E,A        ; save for select
  66.     ADI    'A'        ; make drive code printable
  67.     STA    DRIVE
  68.     CALL    FCN14
  69.     CALL    FCN31
  70.     PUSH    H        ; save it for dump
  71. ;
  72.     LXI    D,SPT        ; make dph values printable
  73.     CALL    CVT2
  74.     LXI    D,BSH
  75.     CALL    CVT1
  76.     LXI    D,BLM
  77.     CALL    CVT1
  78.     LXI    D,EXM
  79.     CALL    CVT1
  80.     LXI    D,DSM
  81.     CALL    CVT2
  82.     LXI    D,DRM
  83.     CALL    CVT2
  84.     LXI    D,ALV0
  85.     CALL    CVT1
  86.     LXI    D,ALV1
  87.     CALL    CVT1
  88.     LXI    D,CKS
  89.     CALL    CVT2
  90.     LXI    D,OFF
  91.     CALL    CVT2
  92. ;
  93.     LXI    H,DSPLAY    ; dph table
  94.     CALL    COSTR        ; print it all
  95.     POP    H
  96.     MVI    B,15
  97.     CALL    HEXDMP        ; print hexdump of dpb
  98.     CALL    COCRLF
  99.     CALL    COCRLF
  100.     RET
  101. ;
  102. SKEW:    MVI    A,ACROSS    ; number of records to display across screen
  103.     STA    NPRINT        ; save
  104.     LDA    FCB1        ; see if drive was specified
  105.     DCR    A        ; test ff=no
  106.     JP    REC2        ; yes, select drive
  107.     CALL    FCN25        ; no, get current drive
  108. REC2:    MOV    E,A
  109.     MOV    C,A
  110.     CALL    FCN14        ; select drive
  111.     CALL    FCN31        ; get address of dph
  112.     MOV    E,M
  113.     INX    H
  114.     MOV    D,M
  115.     XCHG
  116.     SHLD    NRECS        ; save dph address for records per track
  117.     MVI    A,24        ; offset for seldsk:
  118.     CALL    BIOS        ; hl=dph, de=xlate table
  119.     MOV    E,M
  120.     INX    H
  121.     MOV    D,M        ; de=dph
  122.     PUSH    H
  123.     PUSH    D
  124.     PUSH    B
  125.     XCHG            ; dph in hl
  126.     SHLD    DPHADR        ; and save
  127.     CALL    HEXADR        ; display dph address
  128.     LXI    H,DPH        ; trailer message for address
  129.     CALL    COSTR        ; display
  130.     POP    B
  131.     POP    D
  132.     POP    H
  133.     MOV    A,E        ; get low byte
  134.     ORA    D        ; or with high
  135.     JNZ    REC3        ; if zero no translate done
  136.     LXI    H,NXLATE    ; no translate message
  137.     CALL    COSTR
  138.     RET
  139. ;
  140. REC3:    LXI    B,0        ; clear record number
  141.     XRA    A        ; clear a
  142.     STA    POSIT        ; initialize counter
  143. ;
  144. RECLOP:    MVI    A,45        ; offset to sectran
  145.     CALL    BIOS        ; hl=xlate (bc)
  146.     CALL    PRINT        ; display results
  147.     LHLD    NRECS        ; 
  148.     DCX    H
  149.     MOV    A,L
  150.     ORA    H
  151.     JZ    SHOWD
  152.     SHLD    NRECS
  153.     INX    B
  154.     JMP    RECLOP        ; till through
  155. ;
  156. SHOWD:    LXI    H,TBLMSG    ; for skew table
  157.     CALL    COSTR        ; display
  158.     MVI    A,20        ; number of entries
  159.     STA    POSIT        ; set counter
  160.     LHLD    DPHADR        ; get dph address
  161.     SHLD    LAST        ; save it
  162.     JMP    ENTRY
  163. ;
  164. MORE:    LHLD    LAST        ; get last position
  165.     INX    H        ; update and
  166.     SHLD    LAST        ; save it
  167. ENTRY:    MOV    E,M        ; get byte
  168.     MVI    D,0        ; zero d
  169.     MOV    A,E        ; value in a
  170.     CPI    27        ; largest value
  171.     JNC    ZERFIL        ;
  172.     CPI    1        ; start of table
  173.     JZ    WHERE        ; what position
  174.     CPI    0        ;
  175.     JNZ    NOPE        ; none of those
  176. WHERE:    LDA    POSIT        ; see where in table
  177.     CPI    20        ; first position of 20
  178.     JNZ    ZERFIL        ; see if need zeros
  179. NOPE:    XCHG            ; hl has value
  180.     CALL    DECOUT        ; print decimal value
  181.     LDA    POSIT        ; get count
  182.     CPI    0        ; see if done
  183.     RZ            ; yes, return
  184.     MVI    A,','        ; insert comma
  185.     CALL    COUT
  186.     CALL    COSPAC        ; insert space
  187.     LDA    POSIT        ; see if done
  188.     CPI    0
  189.     JZ    ZERFIL        ; fill remainder
  190. NOTDON:    DCR    A        ; count down
  191.     STA    POSIT        ; and save
  192.     JMP    MORE
  193. ;
  194. ZERFIL:    LDA    POSIT        ; how many zero's
  195.     CPI    0
  196.     RZ            ; done if zero
  197.     DCR    A        ; count down
  198.     STA    POSIT        ; and save
  199.     MVI    A,'0'
  200.     CALL    COUT        ; print '0'
  201.     LDA    POSIT
  202.     CPI    0        ; see if through now
  203.     RZ
  204.     MVI    A,','
  205.     CALL    COUT        ; print ','
  206.     CALL    COSPAC        ; print space
  207.     JMP    ZERFIL
  208. ;
  209. ; convert binary in hl to ascii decimal
  210. ;
  211. DECOUT:    MVI    B,0        ; leading zero fill
  212.     LXI    D,-100
  213.     CALL    SUBTR        ; hundreds
  214.     LXI    D,-10
  215.     CALL    SUBTR        ; tens
  216.     MOV    A,L
  217.     ADI    '0'        ; ascii bias
  218.     JMP    COUT        ; print and return to caller
  219. ;
  220. ; subtract powers of 10
  221. ;
  222. SUBTR:    MVI    C,'0'-1        ; ascii count
  223. SUBT2:    INR    C
  224.     DAD    D        ; add neg number
  225.     JC    SUBT2
  226. ;
  227. ; one to many add one back
  228. ;
  229.     MOV    A,D        ; complement
  230.     CMA            ; de
  231.     MOV    D,A
  232.     MOV    A,E
  233.     CMA
  234.     MOV    E,A
  235.     INX    D
  236.     DAD    D
  237.     MOV    A,C        ; get count
  238. ;
  239. ; check for zero
  240. ;
  241.     CPI    '1'        ; less than 1?
  242.     JNC    NZERO        ; no
  243.     MOV    A,B        ; check 0 flag
  244.     ORA    A
  245.     MOV    A,C        ; restore
  246.     RZ            ; skip leading zero
  247.     JMP    COUT        ; print character
  248. ;
  249. ; set flag for non-zero character
  250. ;
  251. NZERO:    MVI    B,0FFH        ; set to zero
  252.     JMP    COUT        ; print
  253.     RET
  254. ;
  255. ; print record entry
  256. ;
  257. PRINT:    CALL    HEXADR        ; print hl as hex words
  258.     CALL    COSPAC        ; insert space
  259.     LDA    NPRINT        ; see if end of line
  260.     DCR    A
  261.     STA    NPRINT        ; update
  262.     RNZ
  263.     MVI    A,ACROSS    ; how many lines across
  264.     STA    NPRINT        ; save
  265.     CALL    COCRLF        ; start new line
  266.     RET
  267. ;
  268. ; select disk, 'e' has drive number
  269. ;
  270. FCN14:    PUSH    B
  271.     PUSH    D
  272.     PUSH    H
  273.     MVI    C,14
  274.     CALL    BDOS
  275.     POP    H
  276.     POP    D
  277.     POP    B
  278.     RET
  279. ;
  280. ; get current disk number, returns current disk in 'a'
  281. ;
  282. FCN25:    PUSH    B
  283.     PUSH    D
  284.     PUSH    H
  285.     MVI    C,25        ; no drive given, get current disk
  286.     CALL    BDOS
  287.     POP    H
  288.     POP    D
  289.     POP    B
  290.     RET
  291. ;
  292. ; get disk parameters, returns 'hl'=dpb address
  293. ;
  294. FCN31:    PUSH    B
  295.     PUSH    D
  296.     MVI    C,31        ; hl = dpb for current disk
  297.     CALL    BDOS
  298.     POP    D
  299.     POP    B
  300.     RET
  301. ;
  302. CVT2:    PUSH    H        ; display 16 bit integer
  303.     INX    H
  304.     CALL    CVT1
  305.     XTHL
  306.     CALL    CVT1
  307.     POP    H
  308.     RET
  309. ;
  310. CVT1:    MOV    A,M        ; display byte at 'hl'
  311.     INX    H
  312. CVT1A:    CALL    HEXBYT        ; a,c=ascii display
  313.     STAX    D
  314.     INX    D
  315.     MOV    A,C
  316.     STAX    D
  317.     INX    D
  318.     RET
  319. ;
  320. ; Subroutine to do an addressed dump of one line. HL point to data,
  321. ; 'B' has length
  322. ;
  323. HEXDMP:    CALL    HEXADR        ; display hl contents in hex
  324.     MVI    A,':'
  325.     CALL    COUT
  326.     CALL    COSPAC
  327. ;
  328. HEXLIN:    PUSH    B
  329.     PUSH    H
  330. HEXL2:    MOV    A,M
  331.     CALL    COHEX        ; display hl in hex
  332.     CALL    COSPAC        ; space
  333.     INX    H
  334.     DCR    B
  335.     JNZ    HEXL2
  336.     POP    H
  337.     POP    B
  338.     RET 
  339. ;
  340. ; Subroutine to print hl as an address in hex
  341. ;
  342. HEXADR    MOV    A,H
  343.     CALL    COHEX
  344.     MOV    A,L
  345.     CALL    COHEX
  346.     RET
  347. ;
  348. ; print the hex byte in 'a'
  349. ;
  350. COHEX:    PUSH    PSW        ; save byte
  351.     CALL    HEXLFT        ; get left half
  352.     CALL    COUT        ; and print
  353.     POP    PSW        ; restore byte
  354.     CALL    HEXRHT        ; right half and
  355.     CALL    COUT        ; print
  356.     RET
  357. ;
  358. HEXLFT:    RAR            ; make left nibble
  359.     RAR
  360.     RAR
  361.     RAR
  362. ;
  363. HEXRHT:    ANI    0FH        ; make right nibble
  364.     CPI    0AH
  365.     JC    HEXLR
  366.     ADI    'A'-3AH
  367. ;
  368. HEXLR:    ADI    '0'
  369.     RET
  370. ;
  371. ; suboutrine to return the hex value of 'a',
  372. ; least significant half in 'c', most significant in 'a'.
  373. ; used when ascii-hex is to be stored.
  374. ;
  375. HEXBYT:    PUSH    PSW        ; save
  376.     CALL    HEXRHT        ; get right nibble
  377.     MOV    C,A        ; save in c
  378.     POP    PSW        ; restore and get
  379.     CALL    HEXLFT        ; left nibble
  380.     RET
  381. ;
  382. ; subroutine to write 'a' to console
  383. ;
  384. COUT:    PUSH    B
  385.     PUSH    D
  386.     PUSH    H
  387.     ANI    7FH        ; strip bit 7
  388.     MOV    E,A
  389.     MVI    C,2        ; cp/m fcn 2
  390.     CALL    BDOS        ; 
  391.     POP    H
  392.     POP    D
  393.     POP    B
  394.     RET
  395. ;
  396. ; print cr,lf to the console
  397. ;
  398. COCRLF:    PUSH    PSW
  399.     MVI    A,CR        ; carriage return
  400.     CALL    COUT        ; print it
  401.     MVI    A,LF        ; line feed
  402.     CALL    COUT        ; and print it
  403.     POP    A
  404.     RET
  405. ;
  406. ; subroutine to write a space to the console
  407. ;
  408. COSPAC:    PUSH    PSW
  409.     MVI    A,SPC        ; space
  410.     CALL    COUT        ; and print it
  411.     POP    PSW
  412.     RET
  413. ;
  414. ; subroutine to write bytes addressed by hl, terminated by last byte with
  415. ; 80 bit set.
  416. ;
  417. COSTR    MOV    A,M        ; get byte
  418.     CALL    COUT        ; print
  419.     MOV    A,M        ; again and test
  420.     RLC            ; for bit 7 set
  421.     RC            ; yes, return
  422.     INX    H        ; next byte
  423.     JMP    COSTR        ; and continue
  424. ;
  425. ; bios service, offset in 'a'
  426. ;
  427. BIOS:    PUSH    B
  428.     PUSH    D
  429.     LHLD    BOOT+1        ; get warm boot address
  430.     ADD    L        ; add offset to wboot
  431.     MOV    L,A        ; to address of service
  432.     PUSH    H        ; save it
  433.     LXI    H,BIORET    ; return address
  434.     XTHL
  435.     PCHL
  436. ;
  437. BIORET:    POP    D
  438.     POP    B
  439.     RET
  440. ;
  441. ;  message strings
  442. ;
  443. DSPLAY:    
  444.     DB    'DPB table for drive '
  445. DRIVE:    DS    1
  446.     DB    ':',CR,LF
  447.     DB    'SPT:  '
  448. SPT:    DS    4
  449.     DB    'H',TAB,'Sectors per track.',cr,lf
  450.     DB    'BSH:  '
  451. BSH:    DS    2
  452.     DB    'H',TAB,'Block shift.',cr,lf
  453.     DB    'BLM:  '
  454. BLM:    DS    2
  455.     DB    'H',TAB,'Block mask.',cr,lf
  456.     DB    'EXM:  '
  457. EXM:    DS    2
  458.     DB    'H',TAB,'Extent mask.',cr,lf
  459.     DB    'DSM:  '
  460. DSM:    DS    4
  461.     DB    'H',TAB,'Disk size-1.',cr,lf
  462.     DB    'DRM:  '
  463. DRM:    DS    4
  464.     DB    'H',TAB,'Directory entries-1.',cr,lf
  465.     DB    'ASV0: '
  466. ALV0:    DS    2
  467.     DB    'H',TAB,'Directory group allocation 0.',cr,lf
  468.     DB    'ALV1: '
  469. ALV1:    DS    2
  470.     DB    'H',TAB,'Directory group allocation 1.',cr,lf
  471.     DB    'CKS:  '
  472. CKS:    DS    4
  473.     DB    'H',TAB,'Check size.',cr,lf
  474.     DB    'OFF:  '
  475. OFF:    DS    4
  476.     DB    'H',TAB,'Offset (number of reserve tracks).',cr,lf,lf
  477. ;
  478. DMPMSG:    DB    '"DPB address and hex dump of table."'
  479.     DB    CR,LF+80H
  480. ;
  481. NXLATE:    DB    BELL,'Diskette needs no translation.',cr,lf+80h
  482. ;
  483. TBLMSG:    DB    'Skew table decimal values.',cr,lf+80h
  484. ;
  485. DPH:    DB    ': (DPH address)',CR,LF+80H
  486. ; User help
  487. ;
  488. HLPMSG:    DB    'DISKPRAM.COM - <H E L P>',CR,LF,LF
  489.     DB    'Syntax:',CR,LF
  490.     DB    'A0>DISKPRAM <cr>    - DPB and SKEW table for defalt drive',CR,LF
  491.     DB    'A0>DISKPRAM d:      - Tables for selected drive',CR,LF
  492.     DB    'A0>DISKPRAM ? or /  - Displays this message',CR,LF
  493. ;
  494.     DB    CR,LF,'This program is designed to provide the user with a tool'
  495.     DB    CR,LF,'that is able to display the DPB and SKEW table of a CP/M'
  496.     DB    CR,LF,'2.2 system.  This information can be used as the decimal'
  497.     DB    CR,LF,'input for a program such as ESET.COM written for the AMPRO'
  498.     DB    CR,LF,'system.  With ESET the AMPRO''s E: drive may be used to read'
  499.     DB    CR,LF,'and write alien 5" diskette formats',CR,LF,LF+80H
  500. ;
  501. NRECS:    DS    2
  502. NPRINT:    DS    1
  503. DPHADR:    DS    2
  504. POSIT:    DS    1
  505. LAST:    DS    2
  506. ;
  507.     DS    30
  508. STACK:    EQU    $
  509. ;
  510.     END
  511.