home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / cpm / utils / f / rlib12.lbr / LIBLIB.HZP / LIBLIB.HLP
Encoding:
Text File  |  1991-10-19  |  9.5 KB  |  311 lines

  1. LIBLIB INTRODUCTION
  2. FILL    Fill n bytes of memory with a constant
  3. GETBIT  Retrieve the next n bits from a REL source
  4. GETZFS  Parse a Z3 filespec into a FCB
  5. INIFCB  Initialize a File Control Block
  6. MPY16   16 bit multiply with 32 bit result
  7. PKGOFF  convert offset in Z3ENV to absolute address
  8. RADBIN  convert ASCII in any radix to binary
  9. SDELM   see if current character is a delimiter
  10. SKSP    increment a pointer past spaces
  11. UCASE   converts char to upper case
  12. :INTRODUCTION TO LIBLIB
  13.  
  14. LIBLIB is a M-REL library required during linking of the RLIB
  15. library manager program. It was built using RLIB.
  16.  
  17. A library contains two or more concatenated REL modules each
  18. of which was (in principle, at least) separately assembled.
  19. Each module has a name which is either the name of the original
  20. source file (by default) or a name assigned with the NAME assembler
  21. instruction. Such names are used only by the library manager to
  22. distinguish one complete module from the next. 
  23.  
  24. Each (named) module contains one or more Entry Points: symbols which
  25. are usually the start of a subroutine. Such symbols were declared
  26. PUBLIC in the original source. For convenience, one of the entry points
  27. may have the same name as the module. Module names are meaningless to
  28. the linker; only entry points are recognized. See the GETZFS module,
  29. whose entry point is FNAME, for a case where the two are not the same.
  30.  
  31. LIBLIB is organized by Module Name. Examples show proper calls.
  32. The command 'RLIB LIBLIB' will display Module Names and Entry points.
  33. :FILL    Fill n bytes of memory with a constant
  34.  
  35. Fill memory pointed to by DE with character in A for B bytes
  36.  
  37. usage:    ext    fill
  38.     ...
  39.     ld    b,10
  40.     ld    a,' '        ;fill with 10 spaces
  41.     call    fill
  42.  
  43. CALL FILL WITH
  44.     B  = number of bytes to fill
  45.     A  = value to fill with
  46.     DE = address to start filling
  47.  
  48. RETURN WITH
  49.     DE = address of next unfilled byte
  50.     The block specified has been filled with (A)
  51.  
  52. :GETBIT  Retrieve the next n bits from a REL source
  53. Routines to get B bits from M-REL bit stream
  54.  
  55. The GETBIT module contains two entry points, GETBIT, and INIBIT.
  56. INIBIT is used before the first call to GETBIT to provide initial
  57. data for processing the first byte of a REL file. Each new REL file
  58. requires such initialization before GETBIT is called.
  59.  
  60. usage:    ext    getbit,inibit
  61.     <open the file, read first buffer-full>
  62.     ...
  63.     ld    a,(hl)        ;hl -> first byte of file
  64.     ld    hl,getrel
  65.     call    inibit        ;see INIBIT for parameters
  66.     ...
  67.     ld    b,3        ;to get the next 3 bits
  68.     call    getbit
  69.  
  70. CALL GETBIT WITH
  71.     B  = number of bits to get
  72.  
  73. RETURN WITH
  74.     A  = contains the B bits
  75.     HL = current value of (bitcnt)
  76.     BC munched
  77.     DE is unused, depending on the GETREL routine.
  78.  
  79. (bitcnt) is an internally stored word variable. The high byte
  80. contains the remaining bits yet to be extracted from the REL
  81. bit stream. The low byte contains the number of bits left to
  82. extract before a new byte is requested (via GETREL). During
  83. initialization with INIBIT, the first byte of the rel file is
  84. stored in the high byte and the low byte is set to 8.
  85.  
  86. INIBIT initializes (bitcnt) and provides the address of the routine
  87. (GETREL, for example) that will be called by GETBIT when it needs
  88. another byte from the REL file buffer.
  89.  
  90. usage:    see GETBIT
  91.  
  92. CALL INIBIT WITH
  93.     HL = Address of the GETREL routine (see below)
  94.     A  = first byte from the rel file
  95. RETURN WITH
  96.     H  = byte from which bits will be extracted (A)
  97.     L  = bits remaining in the byte (8)
  98.  
  99. GETREL is a user written routine in the calling program which, when
  100. called, passes the next byte from the .REL file in A. File access
  101. and file buffer maintenance are GETREL responsibilities. When End
  102. of File is reached, it is an error condition which GETREL must
  103. handle. (An M-REL EOF normally occurs first and stops file processing)
  104. The BC register pair must be preserved across calls to GETREL.
  105. :GETZFS  Parse a Z3 filespec into a FCB
  106. Routine to perform parse of [DU/DIR:]FN[.FT]
  107.  
  108. The Entry for this subroutine is FNAME. It is almost the same as
  109. the FNAME routine in Z3LIB.REL. The difference: this routine
  110. deposits the user number for the filespec in the address FCB-1.
  111. In addition, the list of delimiters recognized is different than
  112. those used by the Z3LIB fname routine. See routine SDELM for the
  113. delimiter list.
  114.  
  115. FNAME uses the following routines in LIBLIB:
  116.     fill,ifcb,inifcb,mpy16,pkgoff,radbin
  117.     rten1,sdelm,sksp,ucase
  118.  
  119. usage:    ext    fname
  120.     ...
  121.     ld    hl,(bufptr)        ;ascii string to parse
  122.     ld    de,fcb            ;place to parse to
  123.     ld    bc,(defdu)        ;currently logged DU
  124.     call    fname
  125.  
  126. CALL FNAME WITH:
  127.     HL -> Token to be parsed as Z3 filespec
  128.     DE -> FCB drive byte
  129.     B  =  Default Drive, (A...P = 1...16)
  130.     C  =  Default User, 0...31
  131.  
  132. RETURN WITH:
  133.     HL -> Delimiter which terminated the parse
  134.     DE    is preserved
  135.     BC =  D/U, with defaults replaced by explicit D or U
  136.     FCB drive byte, FN, FT, data fields initialized
  137.     FCB+13 =Default or declared User area (the S1 byte)
  138.     FCB-1 = Default or declared User area
  139.     NZ = Error, FCB+15 contains error flag
  140.     Z  = no error
  141.     A  = number of '?' in fn/ft. (wildcard count)
  142.  
  143. :INIFCB  Initialize a File Control Block
  144.  
  145. Two entry points are available in the INIFCB module, INIFCB and IFCB.
  146.  
  147. INIFCB initializes the FCB pointed to by DE. It initializes 32 bytes
  148. as fcb1 and fcb2. The Drive byte is not affected. This routine simply
  149. increments DE and then calls IFCB twice. See IFCB for details.
  150.  
  151. usage:    ext    inifcb
  152.     ...
  153.     call    inifcb
  154.  
  155. CALL WITH:
  156.     DE = address of the drive byte (byte 0) of an FCB
  157.  
  158. RETURN WITH:
  159.     DE = FCB+34
  160.  
  161. Other LIBLIB routines used:    fill
  162.  
  163. IFCB
  164. Initializes part of FCB whose file name field is pointed to by DE on entry.
  165. The file name and type are set to space characters; the EX, S2, RC, and the
  166. following CR (current record ) or DN (disk number) fields are set to zero.
  167. The S1 byte is set to the current user number.  On exit, DE points to the
  168. byte at offset 17 in the FCB (two bytes past the record count byte).
  169.  
  170. usage:    ext    ifcb
  171.     ...
  172.     ld    de,fcb+17    ;for fcb2 (for a Rename, for example)
  173.     call    ifcb
  174.  
  175. CALL WITH:
  176.     DE = address of the NAME field of the FCB to be initialized
  177.  
  178. RETURN WITH:
  179.     DE = <Name field address> + 16.
  180.  
  181. :MPY16   16 bit multiply with 32 bit result
  182.  
  183. This routine multiplies the 16-bit values in DE and HL and returns the
  184. 32-bit result in HLBC (HL has high 16 bits; BC has low 16 bits).
  185. Register pair AF is preserved.
  186.  
  187. usage:    ext    mpy16
  188.     ...
  189.     ld    hl,val1
  190.     ld    de,val2
  191.     call    mpy16
  192.  
  193. :PKGOFF  convert offset in Z3ENV to system module address
  194.  
  195. Calculate address of a package from Z3ENV.  On entry, E contains the
  196. offset to the address of the package in the environment.  On exit,
  197. DE points to the beginning of the package and HL points to the fifth
  198. byte (where the command table starts in the RCP and FCP modules).
  199. The zero flag is set on return if the package is not supported.
  200.  
  201. usage:    ext    pkgoff
  202.     public    z3env
  203.     ...
  204.     ld    e,offset
  205.     call    pkgoff
  206.  
  207. CALL WITH:
  208.     E = offset in the Z3 environment
  209.     Z3ENV is a label for the address of the 
  210.        ZCPR3x Environment Descriptor
  211.  
  212. RETURN WITH:
  213.     DE = Address of the environment package.
  214.  
  215. :RADBIN  convert ASCII in any radix to binary
  216.  
  217. The RADBIN module contains two entry points, RADBIN and RTEN1.
  218.  
  219. RTEN1 performs decimal conversion of the string at HL.
  220.  
  221. usage:    ext rten1
  222.     ...
  223.     call rten1    ;converts (HL) asumming a decimal number
  224.  
  225. RADBIN converts the string pointed to by HL using the radix passed in DE.
  226. If the conversion is successful, the value is returned in BC. HL points
  227. to the character that terminated the number, and A contains that
  228. character.  If an invalid character is encountered, the routine returns
  229. with the carry flag set, and HL points to the offending character.
  230.  
  231. usage:    ext radbin
  232.     ...
  233.     ld    de,13        ;for base 13
  234.     ld    hl,(bufptr)
  235.     call radbin
  236.  
  237. CALL WITH:
  238.     HL = address of an ascii string in any radix
  239.     DE = Number Base used to interpret the string
  240.          (2 for binary, 8 for Octal, etc.)
  241.  
  242. RETURN WITH:
  243.     BC = Binary value of the ASCII number represented
  244.     Carry flag set if the string contains an invalid character
  245.     
  246. Other LIBLIB routines used:    mpy16,sdelm
  247.  
  248. :SDELM   see if current character is a delimiter
  249.  
  250. This routine checks for a delimiter character pointed to by HL.
  251. It returns with the character in A and the zero flag set if it
  252. is a delimiter.  The delimiters tested for include all control
  253. characters, space, and the following characters.
  254.  
  255.     ','        ; comma
  256.     '/'        ; indicates lib srch (22/08/88)
  257.     ':'        ; colon
  258.     '.'        ; period
  259.     '='        ; equality sign
  260.     ';'        ; semicolon
  261.     '<'        ; left angle bracket
  262.     '>'        ; right angle bracket
  263.     '_'        ; underline
  264.  
  265. usage:    ext sdelm
  266.     ...
  267.     call sdelm
  268.     ...
  269.  
  270. CALL WITH:
  271.     HL = address of character to test
  272.  
  273. RETURN WITH:
  274.     A = the byte at HL
  275.     Z flag set means this is one of the delimiters
  276.     NZ means the character is NOT a delimiter
  277.     Other registers are preserved
  278.  
  279. :SKSP    increment a pointer past spaces
  280.     public    sksp
  281.  
  282. Subroutine to skip over spaces in the buffer pointed to by HL.  On return,
  283. the zero flag is set if we encountered the end of the line or a command
  284. separator character.
  285.  
  286. usage:    ext sksp
  287.     ...
  288.     ld hl,(bufptr)
  289.     call sksp
  290.  
  291. CALL WITH:
  292.     HL = address of a character in memory
  293.  
  294. RETURN WITH:
  295.     HL = address of next non-space character
  296.  
  297. :UCASE   converts char to upper case
  298.  
  299. Converts the  character in A to upper case.
  300.  
  301. usage:    ext ucase
  302.     ...
  303.     call ucase
  304.  
  305. CALL WITH:
  306.     A  = contains a lower case ASCII character
  307.  
  308. RETURN WITH:
  309.     A  = same character converted to upper case
  310.     All other registers are preserved
  311.