News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Including asm files

Started by rshadarack, August 13, 2005, 05:59:40 PM

Previous topic - Next topic

rshadarack

I tried to do some searches on this, but I came up empty handed on google.  I'm kinda just shooting the moon here, so I am most likely way off, but here goes nothing:

I am trying to include other assembly files into a project.  Here is how I think it should work:

I have main.asm:

INCLUDE Irvine32.inc
INCLUDE mult.asm

Mult PROTO num1:PTR DWORD, num2:DWORD

.data
numA DWORD 4
numB DWORD 1

.code

main PROC
INVOKE mult, ADDR numA, numB
mov eax, numA
call WriteInt ; in Irvine32.inc
exit ; also in Irvine32.inc
main ENDP
END main


And then I have mult.asm:

.data

.code

Mult PROC num1:PTR DWORD, num2:DWORD
  push esi

mov eax, 0
mov ecx, 32
mov esi, num1

@@MultLoop:
shl num2, 1
.IF CARRY?
mov edx, [esi]
dec ecx
shl edx, cl
inc ecx
add eax, edx
.ENDIF
LOOP @@MultLoop
mov [esi], eax

    pop esi
ret
Mult ENDP


But apparently it doesn't.  I keep getting this error:

QuoteLINK32 : error LNK2001: unresolved external symbol _mainCRTStartup

So is there a way I can do this, or does it only work with .lib files?

Jeff

what the include directive does is literally pastes the lines of the file into your proggie at assemble time.  so based on your "included" file, it shouldnt cause problems.  tho in the future, i think it would be better if you were to assemble that file seperately and link it to your program.

as for that error, fortunately, it has nothing to do with the include.  :)  AFAIK, that only shows up when you do not provide a valid entry point for your program.  and before someone mentions the cpu, memory model and calling convention, it is in the Irvine32.inc file (actually in SmallWin.inc).

tho at first glance, it probably should work.  i cant see any obvious errors.  perhaps playing around with how you "include" that may correct it.  or maybe even better, just pasting it in your code alltogether might fix it.  try it out.

rshadarack

Ah, I fixed it.  Stupid mistake.  I was going to try to link them before, so I had an "END" on the last line of mult.asm.  By just removing this, it works.

So I guess I wasn't far off after all.