need help compiling modules

Hi!
I wrote a small program that prints on the screen whatever's in AX. I tested a stand-alone version of it, that works. But now I'd like to compile it in an external obj file, along with other basic subroutines that I will eventually write (I'm only beginning in assembly, and I don't like using pre-chewed stuff, so I write my own routines).

I tried all kinds of way of compiling the subroutine file and the main file, but none worked. I have both TASM and MASM, but my ML version doesn't work (someone ever heard of the "z2: unrecognised option name" error?) Here's what I have:

[code]
;-----------------------
;PRINTHEX.ASM
;this is my subroutine file, that only contains the PRINTHEX procedure


public outputstr,printhex ;outputstr is the output of
;the function

CodeSEG segment public ;I,m not too sure if this is
;right
assume cs:CodeSEG, ds:CSEG

jmp printhex

hexdigits db "0123456789ABCDEF"
outputstr db "0000h$"

printhex proc near ;this is the only procedure
;in the file.

... ;
ret

printhex endp
CSEG ends
end
;--------------------
[/code]

so, I have one procedure , with it's code & data in the same segment.
I want to be able to call printhex and access outputstr from a test program, which could look like this:

[code]
;-------------
;TESTMAIN.ASM

.model small
.CODE
org 100h ;I just want a small COM file


extern outputstr,printhex:NEAR

entry: jmp testmain

;eventual data

testmain proc near

mov AX,0123h ;just for testing
call printhex

int 20h

testmain endp
end entry
;------------
[/code]

now, what? I want to keep things small, so just a small COM file is what I want.
some thing I tried was this:

d: estsTASM printhex.asm

-no complaints

d: estsTASM printhex.obj testmain.asm

-still nothing, I now have a testmain.obj file that Should
-contain the complete program, but I don't know for sure

d: estsTLINK testmain.obj /t

-"Invalid entry point for COM file"

Any help/advice is very welcome.


christian

Comments

  • : d: estsTASM printhex.asm
    :
    : -no complaints
    :
    : d: estsTASM printhex.obj testmain.asm
    :
    : -still nothing, I now have a testmain.obj file that Should
    : -contain the complete program, but I don't know for sure
    :
    : d: estsTLINK testmain.obj /t
    :
    : -"Invalid entry point for COM file"
    :
    : Any help/advice is very welcome.
    :
    :
    : christian
    :
    TASM printhex.asm
    TASM testmain.asm

    *looks at TASM manual, fails to find info, checks (bad) memory*

    TLINK testmain.exe printhex.obj testmain.obj

    I think that's right. You use TASM to produce .OBJ files, then link the two together with TLINK. Haven't used either program in years, though...
    If you want a .COM file, use DOS's EXE2BIN utility (won't work if you use a stack).
  • Hi
    In FASM you can right it like this:

    [code]
    ;-----------------------
    ;PRINTHEX.inc
    ;this is my subroutine file, that only contains the PRINTHEX procedure

    printhex: ;this is the only procedure
    ;in the file.

    ... ;
    ret

    ;--------------------
    [/code]

    [code]
    ;-------------
    ;TESTMAIN.ASM

    org 100h ;I just want a small COM file
    use16

    mov AX,0123h ;just for testing
    call printhex
    int 20h

    include "PRINTHEX.inc"
    ;------------
    [/code]

    Assemble it like this:

    c:fasm TESTMAIN.ASM TESTMAIN.com

    No linker is needed.
    ASHLEY4.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories