Author Topic: %include Directive  (Read 10269 times)

nobody

  • Guest
%include Directive
« on: February 04, 2005, 08:31:09 PM »
Can the %include directive be used to include external *.asm files, that would, for instance, include functions, or labels?

For instance, if I had the main source file, which did a few instructions, and then I had a procedure to print text in the other file, "printtext:", could I then jump/call it ?

Because I used it, and it assembled fine, but still didn't work at runtime.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: %include Directive
« Reply #1 on: February 04, 2005, 08:43:59 PM »
Should work - "%include" effectively just does a text "paste" where it's used. (which may mean you need to be careful *where* you use it) If you can't figure it out, post the code.

Best,
Frank

nobody

  • Guest
Re: %include Directive
« Reply #2 on: February 04, 2005, 11:07:46 PM »
Thanks.

I won't post the code, for several reasons, one of them being it is elsewhere. :/

But anyways, I basically have a series of procedures, that is labels, in an ASM file called funcs.asm.

Can it have anything to do with the fact that it's a 16 bit program? A bootsector on a floppy to be precise?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: %include Directive
« Reply #3 on: February 05, 2005, 01:33:14 AM »
The fact that it's a 16-bit program shouldn't be a problem. A bootsector is limited to 512 bytes. If including "funcs.asm" drives it over 512 bytes, that would make a difference. If you end your bootsector in the "usual way":

times 510 - ($ - $$) db 0
sig db 55h, 0AAh ; or 0AAh, 55 - I forget

... and the "%include 'funcs.asm'" comes before that, Nasm *should* complain about the parameter to "times" being negative, if the size is too big. There might be a problem in there somewhere...

When you get to where your code is, look it over for any obvious errors - sometimes a "new look" turns up things you missed... If you can't find anything, post it, or mail it to me... I wouldn't say I was an "expert" at bootsectors, but I've debugged a few and can *usually* get 'em working.

Happy Bootin',
Frank