flat assembler
Message board for the users of flat assembler.
Index
> Main > problem with calling a label from other files |
Author |
|
revolution 06 Nov 2011, 16:43
'Include' will include the external file just as if you had typed it directly
Code: org 100h ;include 'Header.inc' PrintChar: mov ah, 2 int 21 ret mov dl, 'A' jmp PrintChar |
|||
06 Nov 2011, 16:43 |
|
majidkamali1370 06 Nov 2011, 16:52
there are 2 files. first, header.inc and the second, project.asm file.
I don't know why it does not work. Actually I want to create a function that prints a character and be in another file. |
|||
06 Nov 2011, 16:52 |
|
revolution 06 Nov 2011, 17:06
majidkamali1370: Look at the code I posted above. That is exactly what fasm assembles.
If you need me to give you a direct answer then do this: Code: org 100h mov dl, 'A' jmp PrintChar include 'Header.inc' |
|||
06 Nov 2011, 17:06 |
|
majidkamali1370 06 Nov 2011, 19:55
Thanks. It works. but in big projects, should I include all header files at the end?
|
|||
06 Nov 2011, 19:55 |
|
revolution 06 Nov 2011, 20:04
You need to understand what include does. It inserts the text of the included file directly at the place of the include directive.
This would also work: Code: org 100h jmp start: ;skip over the included code include 'Header.inc' ;include our print function here start: mov dl, 'A' jmp PrintChar |
|||
06 Nov 2011, 20:04 |
|
AsmGuru62 07 Nov 2011, 15:38
You need CALL - not a JMP.
Also, JMP START: may trigger anti-virus. You can include all functions at the end of COM file: Code: org 100h ... include 'Module1.asm' include 'Module2.asm' include 'Module3.asm' Last edited by AsmGuru62 on 08 Nov 2011, 18:04; edited 1 time in total |
|||
07 Nov 2011, 15:38 |
|
edfed 07 Nov 2011, 20:35
depending on what is in your header, you can also do that:
Code: include 'header.inc' mov dl,'A' call printchar ret it will let you separate system specific code and applications codes. Header.inc Code: org 100h call start ret ;quit the program include 'printchar.inc' start: |
|||
07 Nov 2011, 20:35 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.