home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / zsys / simtel20 / z3lib / zlib1.lbr / Z3APPCL.Z80 < prev    next >
Encoding:
Text File  |  1986-02-07  |  2.0 KB  |  102 lines

  1. ;
  2. ; Z3LIB Module Name:  Z3APPCL
  3. ; Author:  Richard Conn
  4. ; Z3LIB  Version Number:  1.3
  5. ; Module Version Number:  1.1
  6. ;
  7.     public    appcl
  8.  
  9.     ext    getcl1,getcl2
  10.  
  11. ;
  12. ; Macros
  13. ;
  14. putrg    macro
  15.     push    bc
  16.     push    de
  17.     push    hl
  18.     endm
  19.  
  20. getrg    macro
  21.     pop    hl
  22.     pop    de
  23.     pop    bc
  24.     endm
  25.  
  26. ;
  27. ;    APPCL stores a command line in the ZCPR3 command line buffer.
  28. ; This command line is pted to by HL.  On return, A=0 and Zero Flag Set
  29. ; if command line overflow is possible (no change to command line).
  30. ;
  31. appcl:
  32.     putrg            ;save registers
  33.     push    hl        ;save ptr to new line
  34.     call    getcl1        ;is command line available?
  35.     jp    nz,pcl0
  36. ;
  37. ; Error Return
  38. ;
  39. nocl:
  40.     pop    hl        ;get ptr to new line
  41.     getrg            ;restore registers
  42.     xor    a        ;ret Z
  43.     ret
  44. ;
  45. ; Pack old command line
  46. pcl0:
  47.     ld    b,a        ;count of chars in B
  48.     push    hl
  49.     call    getcl2        ;get address of new first command
  50.     ld    (oldcmd),hl    ;save position
  51.     pop    hl
  52.     ld    de,4        ;pt to first char in buffer
  53.     ex    de,hl
  54.     add    hl,de
  55.     ex    de,hl
  56.     ld    (hl),e        ;store address
  57.     inc    hl
  58.     ld    (hl),d        ;DE pts to first char of buffer
  59.     ld    hl,(oldcmd)    ;get address of first char of remaining CL
  60. ;
  61. ; Copy Old Command Line into Front of Buffer
  62. ;
  63. pcl1:
  64.     ld    a,(hl)        ;copy
  65.     ld    (de),a
  66.     inc    hl
  67.     inc    de
  68.     dec    b        ;count down
  69.     or    a        ;EOL?
  70.     jp    nz,pcl1
  71.     inc    b        ;B = number of bytes left in buffer
  72.     pop    hl        ;HL = address of first char of new command line
  73. ;
  74. ;    HL pts to first char of new command line
  75. ;    DE pts to after ending 0 of old command line
  76. ;    B = number of chars remaining before overflow of Z3 command line
  77. ;
  78.     push    de        ;save ptr on stack
  79. pcl2:
  80.     ld    a,(hl)        ;get next char
  81.     ld    (de),a        ;put next char
  82.     dec    b        ;count down remaining chars
  83.     jp    z,nocl        ;overflow if reached zero
  84.     inc    hl        ;pt to next
  85.     inc    de
  86.     or    a        ;EOL?
  87.     jp    nz,pcl2
  88.     pop    hl        ;get ptr to first char of new line
  89.     dec    hl        ;pt to ending 0 of old line
  90.     ld    (hl),';'    ;store semicolon separator
  91.     getrg
  92.     or    0ffh        ;no error
  93.     ret
  94.  
  95. ;
  96. ; Data
  97. ;
  98. oldcmd:    ds    2        ;pointer to old command line in CL buffer
  99.  
  100.     end
  101.