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 / CPM / MODEMS / MODEM / GETIT.AQM / GETIT.ASM
Assembly Source File  |  2000-06-30  |  8KB  |  218 lines

  1. ;   COPYRIGHT 1984 BY JOHN M. BLALOCK
  2.  
  3. ;   ####################################
  4. ;   ##                      ##
  5. ;   ##        GETIT.ASM          ##
  6. ;   ##                      ##
  7. ;   ##        Written by:           ##
  8. ;   ##                      ##
  9. ;   ##        John M. Blalock       ##
  10. ;   ##        April 22, 1984          ##
  11. ;   ##                      ##
  12. ;   ####################################
  13.  
  14. ; This    program  is a very simple CP/M terminal  and  ASCII
  15. ; text     capture   program.    Once  customized  for   your
  16. ; particular computer, it will enable you to communicate to
  17. ; another computer via a serial port.    It is expected that
  18. ; the serial port will be connected to a modem.  GETIT will
  19. ; allow  you  to  transfer  ASCII  files  from    the  remote
  20. ; computer  to    yours  and save them on disk as long as the
  21. ; files  are no larger than the available  capture  buffer.
  22. ; Longer  files  will  have to be broken  up  into  smaller
  23. ; segments and recombined on your computer with PIP.
  24.  
  25. ; Once you have established communications with the  remote
  26. ; computer,  entering  Ctl-Y  from your console will  cause
  27. ; GETIT  to start saving text sent from the remote computer
  28. ; into    a RAM buffer that starts at  0100H.   This  capture
  29. ; function can be toggled on and/or off by subsequent entry
  30. ; of another Ctl-Y.  An ASCII BELL character is sent to the
  31. ; console  when capture is toggled on,    and nothing is sent
  32. ; when it is toggled off.
  33.  
  34. ; Entering  Ctl-E  will cause GETIT to exit to    CP/M  after
  35. ; first  telling  you the decimal number of  pages  in    the
  36. ; capture buffer.   GETIT will also exit when the buffer is
  37. ; filled.  An  X-OFF  (Ctl-S) is first sent to    the  remote
  38. ; computer  that will stop further output by it as long  as
  39. ; it supports the X-ON/X-OFF protocol.     The captured  data
  40. ; will be in your RAM starting at 0100H and can be saved to
  41. ; disk    by  entering SAVE nn FILENAME.EXT where nn  is    the
  42. ; number of pages GETIT told you to SAVE.
  43.  
  44. ; GETIT  is  purposefully  short and simple  to  facilitate
  45. ; entry  of its source code from the keyboard.     Leave    out
  46. ; the comments - you have them here.   Probably  the  first
  47. ; thing for which you will want to use it (and perhaps    its
  48. ; only    use)  is  to  download    a  better,   more   capable
  49. ; communications  program.   But it does solve the Catch-22
  50. ; problem of not being able to download any  communications
  51. ; program  because  you don't have any to start  with.   If 
  52. ; MDM730.HEX is available on the remote  computer,  capture
  53. ; it  with  GETIT,  LOAD  it,  and  now  you  have  a  good
  54. ; communications program.
  55.  
  56. ; GETIT  is released for use in the public domain for  non-
  57. ; profit usage only.   If it helps you sell your product, I
  58. ; would like to share in the profits.  If you sell GETIT, I
  59. ; want all the profits.   Any questions should be addressed
  60. ; to John Blalock,  Blalock and Associates,  PO Box  39356,
  61. ; Phoenix, AZ 85069.  Include an SASE if you want a reply.
  62.  
  63.  
  64. ; MODEM CONSTANTS - You will need to change these to  match
  65. ; your particular UART.  If your UART transmit buffer empty
  66. ; and/or receive data available bits are low  true,  you'll
  67. ; have to change the conditional jumps that test these bits
  68. ; from JNZ to JZ  and  from  JZ to JNZ.  The affected lines
  69. ; are marked with an asterick (*) in the comments below.
  70.  
  71. MDATA    EQU    080H        ;MODEM DATA PORT
  72. MSTAT    EQU    081H        ;MODEM STATUS PORT
  73. TXRDY    EQU    001H        ;TX BUFFER EMPTY BIT
  74. RXRDY    EQU    002H        ;RX DATA AVAILABLE BIT
  75.  
  76.  
  77. ; Equate DEST to 0C0H bytes or more  below  the CCP in your
  78. ; version of CP/M.   The  higher  it  is,  the    larger    the
  79. ; capture buffer will be.  I have 52.5K bytes  available in
  80. ; the capture buffer  with  my    version  of  CP/M  and    the
  81. ; following DEST value.
  82.  
  83. DEST    EQU    0D340H        ;PROGRAM IS RELOCATED TO HERE
  84.  
  85. ; The following equates shouldn't require any changes for a
  86. ; standard CP/M system.
  87.  
  88. BASE    EQU    0000H        ;CP/M BASE ADDRESS
  89. BUFF    EQU    BASE + 0100H    ;CAPTURE BUFFER START ADDRESS
  90. BDOS    EQU    0005H        ;BDOS ENTRY ADDRESS
  91. CAPT    EQU    'Y'-40H        ;CTL-Y = START/STOP CAPTURE
  92. EXIT    EQU    'E'-40H        ;CTL-E = STOP, EXIT TO CP/M
  93. BELL    EQU    07H        ;BEEP THE CONSOLE
  94. CR    EQU    0DH        ;ASCII CARRIAGE RETURN
  95. LF    EQU    0AH        ;ASCII LINE FEED
  96.  
  97.     ORG    BUFF        ;PROGRAM STARTS HERE
  98.  
  99. BEGIN    LDA    BASE+2        ;GET BIOS PAGE NUMBER AND
  100.     STA    PCONST+2    ; PATCH PROGRAM WITH YOUR
  101.     STA    PCONIN+2    ; BIOS ENTRY ADDRESSES
  102.     STA    PCONOUT+2
  103. INIT    ;Insert here any code required to initialize your
  104.     ;UART if it is not already initialized by some
  105.     ;other program or your CP/M cold boot routine.
  106. BMOVE    LXI    D,DEST        ;BLOCK MOVE DESTINATION
  107.     LXI    H,START        ;FIRST ADDRESS TO MOVE
  108.     MVI    C,PEND-START    ;NUMBER OF BYTES TO MOVE
  109. MVLOOP    MOV    A,M        ;GET A BYTE
  110.     STAX    D        ;MOVE IT
  111.     INX    H        ;BUMP POINTERS
  112.     INX    D
  113.     DCR    C        ;COUNT THE BYTE
  114.     JNZ    MVLOOP        ;LOOP 'TIL DONE
  115.     JMP    GETIT        ;NOW GO RUN THE PROGRAM
  116. START    EQU    $        ;START OF RELOCATED CODE
  117. OFFSET    EQU    DEST-START    ;PROGRAM OFFSET AMOUNT
  118. GETIT    EQU    $+OFFSET    ;PROGRAM START IN HI MEMORY
  119.     LXI    H,BUFF        ;INITIALIZE BUFFER POINTER
  120. GETLP    EQU    $+OFFSET    ;MAIN PROGRAM LOOP
  121.     IN    MSTAT        ;GET MODEM STATUS
  122.     ANI    RXRDY        ;DATA AVAILABLE ?
  123.     JNZ    RXDRDY        ;YES, THEN JUMP        *
  124.     CALL    CONST        ;NO, CHECK KEYBOARD
  125.     ORA    A        ;ANYTHING TYPED ?
  126.     JZ    GETLP        ;NO, THEN LOOP FOREVER
  127.     CALL    CONIN        ;YES, GET IT
  128.     CPI    CAPT        ;CTL-Y ?
  129.     JZ    TOGCAPT        ;YES, TOGGLE CAPTURE FLAG
  130.     CPI    EXIT        ;CTL-E ?
  131.     JZ    ENDIT1        ;YES, WE'RE DONE FOR NOW
  132.     MOV    C,A        ;NO, MOVE CHARACTER TO C
  133.     CALL    SENDIT        ;SEND THE CHARACTER
  134.     JMP    GETLP        ;LOOP FOREVER
  135. SENDIT    EQU    $+OFFSET    ;SEND (C) TO MODEM
  136.     IN    MSTAT        ;GET MODEM STATUS
  137.     ANI    TXRDY        ;TX BUFFER EMPTY ?
  138.     JZ    SENDIT        ;NO, LOOP UNTIL EMPTY       *
  139.     MOV    A,C        ;CHAR TO REG A
  140.     OUT    MDATA        ;SEND TO MODEM
  141.     RET
  142. RXDRDY    EQU    $+OFFSET    ;RX DATA IS AVAILABLE
  143.     IN    MDATA        ;GET MODEM CHARACTER
  144.     ANI    7FH        ;CLEAR PARITY BIT
  145.     MOV    C,A        ;PUT IN REG C
  146.     LDA    CAPTFG        ;GET CAPTURE FLAG
  147.     ORA    A        ;WANT TO SAVE IT ?
  148.     JZ    NOSAVE        ;NO, THEN DON'T SAVE
  149.     MOV    M,C        ;YES, PUT CHAR IN MEMORY
  150.     INX    H        ;INCREMENT POINTER
  151.     MOV    A,H        ;CHECK FOR TOO FAR
  152.     CPI    DEST SHR 8    ;CAN'T SAVE THIS MUCH
  153.     JZ    ENDIT        ;EXIT IF BUFFER IS FULL
  154.     ;Insert "  JMP    GETLP" here if using a slow console.
  155.     ;You won't see the data as it's being saved, but
  156.     ;you'll get it without missing characters.
  157. NOSAVE    EQU    $+OFFSET    ;NOT SAVING OR NOT FULL
  158.     CALL    CONOUT        ;DISPLAY RECEIVED CHAR
  159.     JMP    GETLP        ;AND LOOP SOME MORE
  160. TOGCAPT    EQU    $+OFFSET    ;TOGGLE CAPTURE FLAG
  161.     LDA    CAPTFG        ;GET IT
  162.     CMA            ;COMPLEMENT IT
  163.     STA    CAPTFG        ;RESTORE FLAG
  164.     ORA    A        ;CAPTURE NOW ON ?
  165.     JZ    GETLP        ;NO, BACK TO LOOPING
  166.     MVI    C,BELL        ;YES, TELL USER CAPTURE
  167.     CALL    CONOUT        ; HAS BEEN TOGGLED ON
  168.     JMP    GETLP        ;BACK TO LOOPING
  169. ENDIT    EQU    $+OFFSET    ;BUFFER FULL, GO TO CP/M
  170.     MVI    C,'S'-40H    ;STOP OUTPUT IF POSSIBLE
  171.     CALL    SENDIT        ; WITH A CTL-S
  172. ENDIT1    EQU    $+OFFSET    ;ENTER HERE TO EXIT W/O ^S
  173.     MVI    A,'Z'-40H    ;END OF FILE FLAG
  174.     MOV    M,A        ;SAVE IN BUFFER
  175.     MOV    A,H        ;GET NUM OF PAGES TO SAVE
  176.     PUSH    PSW        ;SAVE ON STACK
  177.     LXI    D,SAVE        ;POINT DE TO "SAVE" MESSAGE
  178.     MVI    C,9        ;PRINT STRING FUNCTION
  179.     CALL    BDOS        ;PRINT EXITING MESSAGE
  180.     POP    PSW        ;RESTORE NUMBER OF PAGES
  181.     MVI    C,'0'        ;INIT HUNDREDS DIGIT
  182. HUND    EQU    $+OFFSET    ;LOOP HERE 'TIL < 100
  183.     SUI    100        ;ANY HUNDREDS DIGITS?
  184.     JC    TENS        ;NO, CHECK TENS
  185.     INR    C        ;YES, BUMP HUNDREDS DIGIT
  186.     JMP    HUND        ;ANY MORE HUNDREDS ?
  187. TENS    EQU    $+OFFSET    ;NO MORE HUNDREDS
  188.     ADI    100        ;PUT BACK 100
  189.     PUSH    PSW        ;SAVE COUNT
  190.     CALL    CONOUT        ;PRINT HUNDREDS DIGIT
  191.     POP    PSW        ;RESTORE COUNT
  192.     MVI    C,'0'        ;INIT TENS DIGIT
  193. TEN1    EQU    $+OFFSET    ;LOOP HERE 'TIL < 10
  194.     SUI    10        ;ANY TENS DIGITS?
  195.     JC    ONES        ;NO, CHECK ONES
  196.     INR    C        ;YES, BUMP TENS DIGIT
  197.     JMP    TEN1        ;ANY MORE TENS?
  198. ONES    EQU    $+OFFSET    ;NO MORE TENS
  199.     ADI    10+'0'        ;PUT BACK 10, ADD ASCII BIAS
  200.     PUSH    PSW        ;SAVE NUMBER
  201.     CALL    CONOUT        ;PRINT TENS DIGIT
  202.     POP    PSW        ;RESTORE ONES DIGIT
  203.     MOV    C,A        ;PASS TO CONOUT IN REG C
  204.     CALL    CONOUT        ;PRINT ONES DIGIT
  205.     RET            ;BACK TO CP/M
  206. CONST    EQU    $+OFFSET    ;PATCHED BY PROGRAM TO
  207. PCONST    JMP    BASE+6H        ; YOUR BIOS CONST ADDRESS
  208. CONIN    EQU    $+OFFSET    ;PATCHED BY PROGRAM TO
  209. PCONIN    JMP    BASE+9H        ; YOUR BIOS CONIN ADDRESS
  210. CONOUT    EQU    $+OFFSET    ;PATCHED BY PROGRAM TO
  211. PCONOUT    JMP    BASE+0CH    ; YOUR BIOS CONOUT ADDRESS
  212. SAVE    EQU    $+OFFSET    ;EXITING MESSAGE
  213.     DB    BELL,CR,LF,LF,'GETIT exiting, SAVE $'
  214. CAPTFG    EQU    $+OFFSET    ;CAPTURE FLAG
  215.     DB    0        ;00 = NO CAPTURE, DEFAULT
  216. PEND    EQU    $        ;END OF RELOCATED PROGRAM
  217.     END
  218.