About me
Home
Resumé
CV
Pictures

Course Work
CSE300-FA98

Teaching
Portfolio
CSE240-SP99
CSE207-FA03

Misc
eHarmony
Documents

Tools

Multiple Modules

For the second project you are required to have to seperately compiled modules and at least one library call. Below I have set up two basic modules. The first one is called main, and should be considered the top level module. The second one is called sub1 and is identical to a library procedure module, except you don't add it to a library. The file is compiled with Tasm just like a library procedure, but it is not added to the library. Instead the linker is called with two object files. BE CAREFUL - DO NOT USE COMMA'S WHEN LINKING!!! As I mentioned in class, if you use commas, the linker thinks you are specifying different types of parameters one of which is your destination file - do not accidently overwrite your source files!

TITLE main.asm

PUBLIC hello, count

_STACK SEGMENT USE16 STACK 'STACK'
    DW 100h dup(?)
_STACK ENDS

_DATA SEGMENT USE16 WORD PUBLIC 'DATA'
    hello DB "Hello $"
    count DB "1", 0Dh, 0Ah, "$"
    EXTRN world:NEAR
_DATA ENDS

_TEXT SEGMENT BYTE PUBLIC 'CODE'
        ASSUME cs:_TEXT, ds:_DATA
    Start:
        mov     ax, _DATA   ;initialize the data segment (only done once)
        mov     ds, ax

        mov     ah, 09h     ;print hello for the first time
        lea     dx, hello
        int     21h

        mov     ah, 09h     ;print world for the first time
        lea     dx, world
        int     21h

        mov     ah, 09h     ;print the count
        lea     dx, count
        int     21h

        inc     count       ;next time we print count we want a "2"

        ;end of first part of code... will be continued in next module
_TEXT ENDS

END Start

TITLE sub1.asm

PUBLIC world

_DATA SEGMENT USE16 WORD PUBLIC 'DATA'
    EXTRN hello:NEAR
    world DB "world $"
    EXTRN count:BYTE
_DATA ENDS


_TEXT SEGMENT BYTE PUBLIC 'CODE'
        ASSUME cs:_TEXT, ds:_DATA

        ;continuation of code from first module
        ;notice we do NOT need to reinitialize DS

        mov     ah, 09h     ;print hello for the second time
        lea     dx, hello
        int     21h

        mov     ah, 09h     ;print world for the second time
        lea     dx, world
        int     21h

        mov     ah, 09h     ;print the count
        lea     dx, count
        int     21h

        mov     ax, 4C00h   ;exit the program and return to DOS
        int     21h

_TEXT ENDS

END

To produce the output file:
   >tasm main.asm
   >tasm sub1.asm
   >tlink main sub1

To run:
   >main

download the files here
main
sub1

Last Modified: January 26, 1999 - Barry E. Mapen