home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol144 / makefile.asm < prev    next >
Encoding:
Assembly Source File  |  1984-04-29  |  5.6 KB  |  148 lines

  1. ;****************************************************************
  2. ;*                                                              *
  3. ;*  TEST FILE BUILDING PROGRAM - BUILDS MARKED 1024 BYTE BLOCKS *
  4. ;*                                                              *
  5. ;****************************************************************
  6.  
  7. ; CP/M function call definitions
  8. ;
  9. PRINT    EQU    9    ;Print string @ DE, terminate with "$"
  10. OPEN    EQU    15    ;Open file, FCB @ DE
  11. CLOSE    EQU    16    ;Close file, FCB @ DE
  12. SRCHF    EQU    17    ;Search for first match, FCB @ DE
  13. SRCHN    EQU    18    ;Search for next match, FCB @ DE
  14. ERASE    EQU    19    ;Erase specified file(s), FCB @ DE
  15. READ    EQU    20    ;Read from file, FCB @ DE
  16. WRITE    EQU    21    ;Write to file, FCB @ DE
  17. MAKE    EQU    22    ;Make a new file name in dir, FCB @ DE
  18. SETDMA    EQU    26    ;Set DMA address for disk I/O @ DE
  19.  
  20. ; CP/M Entry and FCB definitions
  21. ;
  22. BDOS    EQU    0005H    ;BDOS call address, or entry point
  23. FCB    EQU    005CH    ;Default FCB, set up by CP/M CCP.
  24.  
  25. ; ASCII Character definitions
  26. ;
  27. CR    EQU    0DH    ;Carriage Return
  28. LF    EQU    0AH    ;Line Feed
  29.  
  30. ORG    100H            ;CPM TPA convention, program starts
  31.  
  32. START:    LXI    H,0000        ;Save the system
  33.     DAD    SP        ;stack pointer for
  34.     SHLD    OLDSP        ;use at program exit.
  35.     LXI    SP,STACK    ;Allocate local stack.
  36.  
  37.     LDA    FCB+1        ;Consider the requested
  38.     CPI    ' '        ;file name. (all sp=none specified)
  39.     JZ    NONAM        ;If name was specified, then
  40.  
  41.     LXI    D,FCB        ;Use the default FCB (file name)
  42.     MVI    C,ERASE        ;Erase the specified file
  43.     CALL    BDOS        ;if it already exists.
  44.  
  45.     LXI    D,FCB        ;Use the default FCB (file name)
  46.     MVI    C,MAKE        ;Create an empty file name
  47.     CALL    BDOS        ;as requested, ready to use.
  48.  
  49.     CALL    WFILE        ;Fill the new file with data
  50.  
  51.     LXI    D,FCB        ;Use the default FCB (file name)
  52.     MVI    C,CLOSE        ;Close the now-written file
  53.     CALL    BDOS        ;completing the file operation.
  54.  
  55. NONAM:    LHLD    OLDSP        ;Use the system stack pointer
  56.     SPHL            ;restoring SP to entry value.
  57.     RET            ;Return to operating system.
  58.  
  59. ; BUILD A DATA FILE IN 1024 BYTE BLOCKS, LABELED WITH BLOCK I/D
  60. ;
  61. WFILE:    MVI    A,8        ;Eight sectors in each block.
  62.     LXI    H,DBLOCK    ;Start at the beginning of
  63. WSECL:    SHLD    BLKPT        ;the data block for each set.
  64.     STA    SECNT        ;Record current sector count.
  65.     XCHG            ;DE <- Address of next sector
  66.     MVI    C,SETDMA    ;Set data transfer address for
  67.     CALL    BDOS        ;this sector write (128 bytes)
  68.  
  69.     LXI    D,FCB        ;Use the default FCB (file name)
  70.     MVI    C,WRITE        ;Write the selected sector data
  71.     CALL    BDOS        ;to the open disk file.
  72.  
  73.     LHLD    BLKPT        ;The block pointer must
  74.     LXI    D,128        ;step over one sector
  75.     DAD    D        ;(128 bytes of data).
  76.  
  77.     LDA    SECNT        ;If the sector count has run out
  78.     DCR    A        ;its quota of 128 byte sectors,
  79.     JNZ    WSECL        ;(this block is done), then:
  80.  
  81. ; COUNT UP THE LABEL IN THE DATA BLOCK, TO NEXT VALUE (IN ASCII)
  82. ; (NUMBER MUST HAVE BEEN PRE-INITIALIZED TO ASCII 000001)
  83.  
  84.     LXI    H,LABEL+5    ;Point to lowest digit of label
  85.     MVI    B,6        ;Consider up to the full 6 digits
  86. LCNTL:    MOV    A,M        ;Examine the current digit
  87.     INR    A        ;plus 1, whether still numeric.
  88.     MOV    M,A        ;Assume no overflow, number is done.
  89.     CPI    '9'+1        ;If numeric overflow did occur
  90.     JNZ    LTCMP        ;then (else compare termination)
  91.     MVI    M,'0'        ;reset this digit to "0"
  92.     DCX    H        ;step to the next higher digit.
  93.     DCR    B        ;If there was a next higher digit,
  94.     JNZ    LCNTL        ;propagate the carry. (else truncate)
  95.  
  96.  
  97. ; COMPARE THE DATA BLOCK LABEL WITH THE TERMINATION VALUE (IN ASCII)
  98. ; (TERMINATION VALUE MUST HAVE BEEN PRESET TO AN ASCII NUMBER)
  99. ;
  100. LTCMP:    LXI    H,LABEL        ;Point to highest digit of label
  101.     LXI    D,TERMV        ;Point to highest digit of terminator
  102.     MVI    B,6        ;Compare up to 6 equal digits.
  103. LTCML:    LDAX    D        ;If the current terminator digit
  104.     CMP    M        ;is the same as the current label digit
  105.     JNZ    PLNUM        ;then: (else print out this label number)
  106.     INX    H        ;Step over label digit
  107.     INX    D        ;Step over terminator digit
  108.     DCR    B        ;If there is another digit to compare
  109.     RZ            ;then: (else all digits are equal - end)
  110.     JMP    LTCML        ;compare next digit of label (block number).
  111.  
  112. ; PRINT OUT THE CURRENT BLOCK NUMBER BEING WRITTEN TO DISK
  113. ;
  114. PLNUM:    LXI    D,PLABL        ;Point to label numeric string
  115.     MVI    C,PRINT        ;print it out on the console
  116.     CALL    BDOS        ;for operator observation.
  117.     JMP    WFILE        ;write this block to disk
  118.  
  119.  
  120.     DS    64        ;Local stack allocation
  121. STACK:                ;Stack pointer initialization address
  122. OLDSP:    DW    0080H        ;System stack pointer    
  123. BLKPT:    DW    DBLOCK        ;Sector data pointer (in block)
  124. SECNT:    DB    8        ;Sectors done in block - counter
  125. TERMV:    DB    '001024'    ;Required block count, in ASCII
  126. PLABL:    DB    CR        ;Cursor position for label display
  127. LABEL:                ;Label occupies first 6 Chars of data block
  128. DBLOCK:                ;Data block to be written to disk
  129.  DB '000001 $$ Is the current block number in this test data file..',CR,LF
  130.  DB 'Sector 1 in this block of a test file of 1024 byte data blocks',CR,LF
  131.  DB 'ABCDEFGHI This is a test file containing 1024 byte data blocks',CR,LF
  132.  DB 'Sector 2 in this block of a test file of 1024 byte data blocks',CR,LF
  133.  DB 'JKLMNOPQR This is a test file containing 1024 byte data blocks',CR,LF
  134.  DB 'Sector 3 in this block of a test file of 1024 byte data blocks',CR,LF
  135.  DB 'STUVWXYZ. This is a test file containing 1024 byte data blocks',CR,LF
  136.  DB 'Sector 4 in this block of a test file of 1024 byte data blocks',CR,LF
  137.  DB 'abcdefghi This is a test file containing 1024 byte data blocks',CR,LF
  138.  DB 'Sector 5 in this block of a test file of 1024 byte data blocks',CR,LF
  139.  DB 'jklmnopqr This is a test file containing 1024 byte data blocks',CR,LF
  140.  DB 'Sector 6 in this block of a test file of 1024 byte data blocks',CR,LF
  141.  DB 'stuvwxyz. This is a test file containing 1024 byte data blocks',CR,LF
  142.  DB 'Sector 7 in this block of a test file of 1024 byte data blocks',CR,LF
  143.  DB '123456789 This is a test file containing 1024 byte data blocks',CR,LF
  144.  DB 'Sector 8 in this block of a test file of 1024 byte data blocks',CR,LF
  145.  
  146.     END
  147.  
  148.