Search code examples
assemblydostasmmulti-module

Multimodule assembler program


I'm having troubles with creating simple multimodule program in DOS.

What I want is to create procedure which increments ax with 5 and call it from main procedure. But every time I start debugging I get strange problem with infinite one-instruction cycle:

add [bx:si], al

Down here is my first file:

;(tmp1.bat)
.model small
.386
extrn mytmp

.code
org 100h
start:
  mov ax, 5
  push ax
  call mytmp
  pop ax
  mov dl, al
  mov ah, 06h
  int 21h
  ret
end start
end

And the second file:

;(tmp2.bat)
.model small
.386
public mytmp

.code
mytmp: 
  pop ax
  add ax, 5
  push ax
  ret
END

What am I doing wrong? P.S. compiling from DOS:

tasm tmp1.bat
tasm tmp2.bat
tlink /t tmp1.obj tmp2.obj

Solution

  • TASM assembles call mytmp as an indirect call according to a value in mytmp. It doesn't know that mytmp is a procedure.

    Change

    extrn mytmp
    

    to

    extrn mytmp:PROC