Dec 162017
 
C library fr. CL mag 3-87.
File TINYLIB.ZIP from The Programmer’s Corner in
Category Files from Magazines
C library fr. CL mag 3-87.
File Name File Size Zip Size Zip Type
$$DAT.ASM 1078 469 deflated
$MAIN.ASM 2269 1058 deflated
%AZTEC.INC 11916 2841 deflated
%C86.INC 9653 2429 deflated
ABORT.ASM 503 273 deflated
CLOSE.ASM 419 262 deflated
CREAT.ASM 958 489 deflated
CROOT.ASM 512 254 deflated
D2IO.H 1031 489 deflated
D2IOH.INC 2255 784 deflated
EXIT.ASM 529 249 deflated
FCLOSE.ASM 633 369 deflated
FGETC.ASM 1745 809 deflated
FGETS.ASM 751 443 deflated
FINFO.ASM 2527 940 deflated
FOPEN.ASM 2007 962 deflated
FPRINTF.ASM 581 329 deflated
FPUTC.ASM 1136 582 deflated
FPUTS.ASM 679 320 deflated
FRDWR.ASM 1202 558 deflated
FSEEK.ASM 791 454 deflated
FTELL.ASM 369 222 deflated
GETDRV.ASM 666 346 deflated
GETS.ASM 1099 290 deflated
GETW.ASM 933 474 deflated
IOCTL.ASM 442 273 deflated
ISDIGIT.ASM 287 196 deflated
ISLOWER.ASM 295 208 deflated
ISUPPER.ASM 309 219 deflated
LBEGIN.ASM 4733 1879 deflated
LSEEK.ASM 444 271 deflated
MAKEFNM.ASM 4070 962 deflated
OPEN.ASM 841 470 deflated
PRINTF.ASM 565 319 deflated
PUTS.ASM 389 243 deflated
PUTW.ASM 964 483 deflated
RDWR.ASM 567 326 deflated
RENAME.ASM 354 230 deflated
REWIND.ASM 363 211 deflated
RINDEX.ASM 494 305 deflated
SDATIM.ASM 2401 978 deflated
SHRINK.MAP 2330 918 deflated
SPRINTF.ASM 553 312 deflated
STRCAT.ASM 586 319 deflated
STRCHR.ASM 408 262 deflated
STRCMP.ASM 791 436 deflated
STRCPY.ASM 598 346 deflated
STRLEN.ASM 312 210 deflated
TIMER.ASM 1012 551 deflated
TLBMAC.DOC 17555 4950 deflated
TOLOWER.ASM 297 211 deflated
TOUPPER.ASM 308 214 deflated
UNGETC.ASM 1006 529 deflated
UNLINK.ASM 272 188 deflated
XTRMOD.ASM 2886 828 deflated
_FMT.ASM 9805 3372 deflated
_MAIN.ASM 2106 845 deflated
_STRHAND.ASM 936 515 deflated
_XN.ASM 3981 1721 deflated

Download File TINYLIB.ZIP Here

Contents of the TLBMAC.DOC file


MAKING ASSEMBLER CODE PORTABLE

Tinylib uses compiler-specific "include" files to take care of all the
differences from one compiler's requirements to another. These files provide
standardized macros to generate ASM code that meets a specific compiler's
coding conventions. Separate include files for each compiler, and for each
memory model within any compiler that permits a choice, are required. At
present, include files for C86 V1.33 (small model), and for Aztec C V3.40
(large model) are provided.

Each file is a macro library. The one to be used should be copied with the
name "COMPILER.INC". Each separate module source file in the Tinylib package
begins with the directive "include compiler.inc", and makes extensive use of
these macro facilities to accomodate global-symbol name conventions, memory
models, storage allocation and reference, subroutine calling, and so forth.
The standard macros defined, their parameters (if any), and their actions are
described in the following paragraphs.

Macro Name: ttl
Parameters: modnam, vrsn, date, auth
Defines module name, title line, and revision status for the module.
Required as first macro in each module.


Macro Name: dseg
(no parameters)
Defines start of data segment, and establishes compiler-specific segment-name
or group-name.Required in each module even if data segment is not used.


Macro Name: exterr
(no parameters)
Declares global error value symbol (as external). Actual symbol used depends
on compiler's conventions. See also , , and .


Macro Name: defptr
Parameters: ptrnam
Defines as a global symbol and reserves space to store a pointer
value.May modify actual symbol as required by compiler conventions. Defines
symbol as a WORD for small or program model, or as a DWORD for large or data
model.


Macro Name: extv
Parameters: vname, type
Defines as a global symbol external to the current module. May
modify actual symbol as required by compiler conventions. Defines symbol type
as ; no checks of are made. Can be used for CODE or DATA.


Macro Name: glblvl
Parameters: list
Permits several global symbols to be defined on one line of the source file.
Parameter is a list of parameter sets for macro . Invokes
with first set as parameters, repeating until is empty.


Macro Name: glblv
Parameters: vname, type, val
Defines as a global symbol. May modify actual symbol as required by
compiler conventions. Defines symbol to be of type defined by ,
initialized to .

Valid Types:produces DB definition
produces DW definition
produces DD definition
No other symbols may appear as the .


Macro Name: cseg
(no parameters)
Defines end of data segment and start of code segment, and establishes
compiler-specific segment-name or group-name. Required in each module even if
code segment is not used.

Macro Name: xtfs
Parameters: list
Permits several external functions to be defined on one line of the source
file. Parameter is a list of parameters for macro . Invokes
with first parameter, repeating until is empty.


Macro Name: extf
Parameters: fname
Defines as a code-relative symbol external to the current module.
Type (NEAR or FAR) is compiler-dependent and is automatically included. Symbol
may be modified to comply with compiler conventions.


Macro Name: moverr
Parameters: val
Sets global error value from (which may be a register or a symbol
reference). Actual symbol used for global error value depends on compiler's
conventions. See .


Macro Name: geterr
Parameters: val
Gets global error value into (which may be a register or a symbol
reference. Actual symbol used for global error value depends on compiler's
conventions. See .


Macro Name: saverr
(no parameters)
Copies global error value into stream table, assuming SI points to it.
Actual symbol used for global error value depends on compiler's conventions.
See .


Macro Name: procdef
Parameters: pname, args
Defines a global procedure with name . Symbol may be modified to
conform to compiler's conventions. Saves BP and defines symbols to reference
arguments passed to procedure as specified by the list.Establishes
PROC block which must be closed with . Note that these procedures may
NOT be nested.


Macro Name: dargs
Parameters: list
Interfaces procedure-defining macros and to the
macro.Parameter is a list of parameter sets for macro .Invokes
with first parameter set, repeating until is empty.


Macro Name: darg
Parameters: aname, type
Equates to offset (BP-relative) for argument on stack. For strongly
typed assemblers such as MASM, defines symbol same as with "_v"
suffixed to be actual offset value, and defines as typed BP reference.
Automatically maintains offset values using argument size obtained from
parameter.

Valid Types: - 1 BYTE
- 1 WORD
- 2 WORDs for "long" or "float" data
- 4 WORDs for "double" data
- 2 or 4 WORDs for data pointer
- 2 or 4 WORDs for function pointer
No other strings are valid for .


Macro Name: locs
Parameters: list
Terminates set of declarations and adjusts SP value to reserve local
variable space. Parameter is a list of parameter sets for . This
macro should be used only once per procedure definition.


Macro Name: dclv
Parameters: lvnm, type, asiz
Defines as a local automatic (BP-relative) variable with size
determined by . If indicates an array, is size of array;
else is ignored. Same typing considerations discussed for apply
here; major difference between and is the sign of the offset
values.

Valid Types: - 1 BYTE
- 1 WORD
- 2 WORDs for "long" or "float" data
- 4 WORDs for "double" data
- 2 or 4 WORDs for data pointer
- 2 or 4 WORDs for function pointer
- array of BYTEs
- array of WORDs
No other strings are valid for .


Macro Name: alias
Parameters: pname, altnam
Declares to be equivalent to ; used to provide alternate name
for procedures such as "strchr()" and "index()". May modify actual symbol to
conform to compiler's global-symbol conventions.


Macro Name: entrdef
Parameters: pname
Declares as an alternate entry point for a global procedure,
accepting the same list of arguments declared with macro at the
procedure's primary definition. May modify actual symbol to conform to
compiler's global-symbol conventions.


Macro Name: statdef
Parameters: pname, args
Local equivalent of . Defines a static (local) procedure with name
. Saves BP and defines symbols to reference arguments passed to
procedure as specified by the list. Establishes PROC block which must
be closed with .Note that these procedures may NOT be nested.


Macro Name: internal
Parameters: pname
Defines a static (local) procedure with name that has no arguments.
Establishes PROC block which must be closed with . Note that these
procedures may NOT be nested.


Macro Name: intrdef
Parameters: pname
Local equivalent of . Declares as an alternate entry point
for a local procedure, accepting the same list of arguments declared with macro
at the procedure's primary definition.


Macro Name: callit
Parameters: pname, args
Generates complete call sequence to global procedure . Uses
macro to push argument values listed in onto stack, keeping
count of the number of bytes pushed, issues CALL (modifying as required
by compiler's conventions), and flushes stack upon return. Note that
list is processed left to right while C conventions usually require
reverse-order stacking; thus arguments must appear in the REVERSE of their
normal sequence in the list.


Macro Name: pushargs
Parameters: list
Interfaces procedure-calling macros such as to . Parameter
is a list of parameter sets for macro . Invokes with
first parameter set, repeating until is empty. Thus the LAST parameter
set in the will be at the lowest stack address when this macro
terminates.


Macro Name: pusharg
Parameters: varib, type, segref
Pushes word or words specified by , , and onto stack as
arguments for a call to another procedure. Number of words pushed is specified
by parameter . Parameter is used only when the requires
a segment reference. Maintains count of number of bytes pushed for use in
flushing stack later.

Valid Types:pushes 2 bytes onto stack from memory
location .
pushes 2 bytes onto stack from memory
location .
pushes register onto stack.
Must be 16-bit register; counts 2 bytes.
pushes onto stack, followed by
pointer register . If is
omitted, uses default value for .
Counts 4 bytes.
pushes 4 bytes starting at memory location
onto stack, by words. Word at
+2 is pushed first.
pushes 8 bytes starting at memory
location onto stack, by words.
Word at +6 is pushed first, then
+4, +2, and .
pushes content of pointer onto
stack.Counts 2 bytes in small or program
model, 4 in data or large.
pushes address of memory reference
onto stack. Counts 2 bytes in small or
data model, 4 in program or large.
Segment address is pushed first, in large
or program model, followed by offset.
No other strings are valid for .


Macro Name: pushptr
Parameters: pointer
For data or large model, pushes content of memory reference [2] to
the stack. For all models, pushes content of to stack.


Macro Name: popptr
Parameters: pointer
Inverse of macro ; pops from stack into memory reference
for all models. For data or large model, then pops from stack into
[2].


Macro Name: pshloc
Parameters: vnam
Pushes content of local variable onto stack. Regardless of type
declared for , this macro references it as a WORD.


Macro Name: psharg
Parameters: anam
Pushes content of argument onto stack. Like , the argument is
referenced as a WORD.


Macro Name: pushreg
(no parameters)
Generates PUSH DI/PUSH SI and sets HAVEREG flag to indicate that registers
have been saved.


Macro Name: popreg
(no parameters)
If HAVEREG is clear, does nothing. If set, generates POP SI/POP DI and
clears HAVEREG flag to indicate that registers have been restored.


Macro Name: pushds
(no parameters)
In small or program model, does nothing. In large or data model, generates
PUSH DS and sets HAVEDS flag to indicate that DS has been saved.


Macro Name: popds
(no parameters)
In small or program model, or if HAVEDS flag is clear, does nothing.In
large or data model, if HAVEDS flag is set, generates POP DS and clears HAVEDS
flag to indicate that DS has been restored.


Macro Name: ldptr
Parameters: dest, argname, segref
Loads register from memory reference . In small or program
model, generates a MOV , instruction and the parameter
is ignored.
In data or large models the macro is much more complex: If is "DS",
a "LDS" instruction is generated. If it is "ES", a "LES" instruction results.
If is omitted, a "LDS" is generated for of "SI", "LES" for
"DI", and any other value for the parameter produces an error message.
If is present and is any other value, a pair of MOV instructions are
generated. The first loads from and the second loads
from [2].


Macro Name: svptr
Parameters: dest, argname, segref
Stores an arg pointer from registers : into 4 bytes of memory
starting at , in standard offset:segment format, for data or large
models. If is missing, determines default value by rules similar to
those described for macro . For small or program model, ignores
and stores register in WORD at .


Macro Name: setptr
Parameters: ptrnam, sym, segref
Sets global, static, or auto memory location to point to address
:. In small or program memory model, parameter is
ignored; if omitted large or data model macro will assign default. Note that
AX is destroyed.


Macro Name: ptrcpyinc
Parameters: from, to
Copies value pointed to by parameter , into global, static, or auto
memory location , and post-increments pointer . Uses register AX
(and DX in the large or data model) for the transfer; fetches with macro .


Macro Name: extraseg
(no parameters)
Forces ES to same value as DS, by PUSH/POP sequence.No other registers or
flags are affected.


Macro Name: gci
Parameters: ptrnam
Fetches single byte pointed to by into AL register and
post-increments . Uses the macro to load SI register from
, LODSB to fetch byte and increment SI, and macro to store
incremented register back into . Use primarily for single- byte
actions; if more than a couple of bytes are to be fetched, separate ,
LODSB, and calls have much less overhead.


Macro Name: pci
Parameters: ptrnam
Inverse of macro above. Stores AL register where points,
using DI register, and post-increments . Same overhead considerations
apply.


Macro Name: gwi
Parameters: ptrnam
Same as except that it moves a 16-bit word into AX. All considerations
apply.


Macro Name: pwi
Parameters: ptrnam
Same as except that it moves a 16-bit word from AX. All considerations
apply.


Macro Name: caseb
Parameters: val, goto
Compares content of AL with parameter , which may be constant, memory
reference, or register. If equal, branches to "short label" .


Macro Name: casew
Parameters: val, goto
Same as except compares AX to .


Macro Name: retptrm
Parameters: src
Generates code to return a pointer value in DX:AX. If CY flag is set when
this code is reached, a NULL pointer value is returned. If not, the value from
memory location (which may be relative to either BP or DS) is returned in
AX, and that from the following word is returned in DX. Uses macro to
generate actual return code.


Macro Name: retptrr
Parameters: src,seg
Generates code to return a pointer value in DX:AX. If CY flag is set when
this code is reached, a NULL pointer value is returned. If not, the value from
(which may be a memory reference or a register) is returned in AX, and
that from is returned in DX. Uses macro to generate actual return
code.


Macro Name: retnull
(no parameters)
Generates code to return a NULL value in AX (and DX for large model). Uses
macro to generate actual return code.


Macro Name: retyes
(no parameters)
Generates code to return a value of 0001 in AX only.Uses macro to
generate actual return code.


Macro Name: pret
(no parameters)
Restores BP and registers, then executes RET. Note that since clears
flags that indicate registers have been pushed, it must not be used more than
once per procedure. Since the other "ret" macros all invoke , only one
of this group should be used.


Macro Name: iend
Parameters: pname
Ends definition of the static or internal procedure named .


Macro Name: pend
Parameters: pname
Ends definition of the global procedure named (as modified by the
macro which began the definition).


Macro Name: finish
(no parameters)
Ends definition of the code segment and the module. Required for all
modules; must be last line of source file.

============= end of description =============


 December 16, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)