Creating and Using a Subroutine Library

This page shows the creation and use of a library of simple assembly language procedures. These are all "I/O" related procedures. All available procedure names are listed in step (4) below.

(1) Assemble the procedures.
B:\>
B:\>ml /c IO_ver01.asm GD16bran.asm PN16bran.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: IO_ver01.asm
 Assembling: GD16bran.asm
 Assembling: PN16bran.asm
(2) Check the result.
B:\>
B:\>dir
01-04-23  12:10p                 2,822 GD16BRAN.ASM    GD16bran.asm
01-04-23  12:43p                   373 GD16BRAN.OBJ    GD16bran.obj
01-04-23  12:21p                 1,742 IO_VER01.ASM    IO_ver01.asm
01-04-23  12:43p                   195 IO_VER01.OBJ    IO_ver01.obj
01-04-23  12:10p                 2,752 PN16BRAN.ASM    PN16bran.asm
01-04-23  12:44p                   247 PN16BRAN.OBJ    PN16bran.obj
               8 File(s)          8,131 bytes
(3) Collect the objects into a library.
B:\>
B:\>lib  IO_ver01.lib  +IO_ver01.obj  +GD16bran.obj  +PN16bran.obj

Microsoft (R) Library Manager  Version 3.20.010
Copyright (C) Microsoft Corp 1983-1992.  All rights reserved.

List file: IO_ver01.lst
(3b) (Check the result again. The library and its listing file have been created.)
B:\>
B:\>dir
01-04-23  12:10p                 2,822 GD16BRAN.ASM    GD16bran.asm
01-04-23  12:43p                   373 GD16BRAN.OBJ    GD16bran.obj
01-04-23  12:21p                 1,742 IO_VER01.ASM    IO_ver01.asm
01-04-23  12:45p                 2,075                 IO_VER01.LIB
01-04-23  12:45p                   647                 IO_VER01.LST
01-04-23  12:43p                   195 IO_VER01.OBJ    IO_ver01.obj
01-04-23  12:10p                 2,752 PN16BRAN.ASM    PN16bran.asm
01-04-23  12:44p                   247 PN16BRAN.OBJ    PN16bran.obj
              10 File(s)         10,853 bytes
(4) Look at the library listing.
It shows available procedures, what object file they came from, and total code sizes.
B:\>
B:\>type io_ver01.lst

doCRLF1...........IO_ver01          DOSstr1...........IO_ver01
GetChr1...........IO_ver01          GetDec16s.........GD16bran
GetStr1...........IO_ver01          GetUnsigned.......GD16bran
PutChr1...........IO_ver01          PutNum16..........PN16bran
Uns2ASC...........PN16bran

IO_ver01          Offset: 00000010H  Code and data size: 25H
  doCRLF1           DOSstr1           GetChr1           GetStr1
  PutChr1

GD16bran          Offset: 000000f0H  Code and data size: d0H
  GetDec16s         GetUnsigned

PN16bran          Offset: 00000280H  Code and data size: 4dH
  PutNum16          Uns2ASC

B:\>
(5) Use the library...
Put the library in the same directory as the source file that uses it (or specify a path as part of the library's name).
Then assemble them together.
B:\>
B:\>ml /Fl  GPdemo.asm  io_ver01.lib
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: GPdemo.asm

Microsoft (R) Segmented Executable Linker  Version 5.31.009 Jul 13 1992
Copyright (C) Microsoft Corp 1984-1992.  All rights reserved.

Object Modules [.obj]: GPdemo.obj
Run File [GPdemo.exe]: "GPdemo.exe"
List File [nul.map]: NUL
Libraries [.lib]: "io_ver01.lib"
Definitions File [nul.def]:

B:\>
(6) Try the program.
These versions of GetDec() and PutNum() are "branded" --- they add my initials to their outputs.
B:\>GPdemo
Enter number:  (RAM) 998
Enter number:  (RAM) -23400
+00998 (RAM) 
-23400 (RAM) 

B:\>
  ·  mail to: bobmon@.bloomu.edu   ·  home page   ·  Page last updated: