Hi again,
I hope Mike can answer this Q.
I make a *.INC file, and then I put %include "printoscrn.inc"
and I wrote
mov si, message ;Load the message into SI-register.
call printOnScrn ;Invoke the printOnScrn function located in "printonscrn.inc".
int 0x10 ;BIOS video interrupt.
BTW, shall I tell the NASM that I have an extern function somewhere else?
Please help me out, and explain how I shall invoke the function in the *.inc
and how INC files shall be structured.
Thanks!
Q: How to invoke function in *.INC files?
Moderator:Moderators
Re: Q: How to invoke function in *.INC files?
Hello,
Because of the way *.inc files are included, if the function is defined in the *.inc file it can be invoked the same way as any other routine (using CALL). I do personally recommend a more structured approach however you must be careful as the boot loader in the series is flat binary.
Because of the way *.inc files are included, if the function is defined in the *.inc file it can be invoked the same way as any other routine (using CALL). I do personally recommend a more structured approach however you must be careful as the boot loader in the series is flat binary.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com
Re: Q: How to invoke function in *.INC files?
Since you are the actual OS developer and Kernel guy, can't you provide meMike wrote:Hello,
Because of the way *.inc files are included, if the function is defined in the *.inc file it can be invoked the same way as any other routine (using CALL). I do personally recommend a more structured approach however you must be careful as the boot loader in the series is flat binary.
with more in-depth details? Thanks!
Re: Q: How to invoke function in *.INC files?
Hello,
%include in NASM works the same as #include in C. It copies the contents of the file to include directly into the file to be assembled with the %include directive. The end result is the same as if you just written all of the code in one file.
Because of this, you can access any defined label (variable or function) in your code without anything special needed. extern is only needed for declaring external symbol names which we dont have here.
This method was used in the boot loader provided by the series for simplicity. Larger boot loaders are typically more structured, where the core of the loader is written in a higher level language.
%include in NASM works the same as #include in C. It copies the contents of the file to include directly into the file to be assembled with the %include directive. The end result is the same as if you just written all of the code in one file.
Because of this, you can access any defined label (variable or function) in your code without anything special needed. extern is only needed for declaring external symbol names which we dont have here.
This method was used in the boot loader provided by the series for simplicity. Larger boot loaders are typically more structured, where the core of the loader is written in a higher level language.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com