flat assembler
Message board for the users of flat assembler.

Index > Main > labels and includes

Author
Thread Post new topic Reply to topic
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph 09 Oct 2003, 19:46
And I have yet another questions. I get the following error:

inc\idt.inc [46]:
IDTInt20 InterruptDscr OffsetInt20,0008h,8E00h,0001h
inc\idt.inc [2] InterruptDscr [1]:
.Offset0_15 DW ID1 ;low word of int offset
error: undefined symbol.

InterruptDscr is defined in idt.inc as:
Code:
STRUC InterruptDscr ID1,ID2,ID3,ID4 {
      .Offset0_15   DW ID1  ;low word of int offset
      .Selector0_15 DW ID2  ;segment selector
      .Flags        DW ID3  ;flags
      .Offset16_31  DW ID4  ;high word of int offset
}    

Now, I have one file which looks sort of like this:
Code:
;some code
INCLUDE 'inc\idt.inc'
INCLUDE 'boot.asm'
    

Boot.asm in turn contains this:
Code:
;some code
INCLUDE 'inc\ivt.inc'
    

Now, OffsetInt20 comes from ivt.inc and is used by idt.inc. I'm assuming the error comes from the fact that idt.inc can't see OffsetInt20 from ivt.inc due to the include mess. Is that correct? If so, how would I get around that and why does the error occur? Shouldn't the preprocessor simply insert the contents of those files wherever they're referenced and thus make all labels global throughout all files?
Post 09 Oct 2003, 19:46
View user's profile Send private message Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph 10 Oct 2003, 01:10
I rewrote that EQU in ivt.inc with a =, and it works now. Could anyone explain to me why?
Post 10 Oct 2003, 01:10
View user's profile Send private message Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Dunduk 10 Oct 2003, 02:47
Ralph wrote:
I rewrote that EQU in ivt.inc with a =, and it works now. Could anyone explain to me why?

As I know "equ" is not equal to "=" in fasm... if I read right fasm documentation. "=" is used for definition constants and "equ" is used for definition symbolic constants.
Post 10 Oct 2003, 02:47
View user's profile Send private message Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph 10 Oct 2003, 03:07
Yeah, EQU replaces it with a symbolic constant while = replaces it with the actual value. I just rewrote "Label EQU $-PreviousLabel" as:
Code:
Label = NextLabel-PreviousLabel
NextLabel:
    

Just a different way of doing the same thing. I'm just curious as to why the = gets picked up and the EQU does not. Does that have to do with the scope?
Post 10 Oct 2003, 03:07
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 10 Oct 2003, 04:47
Ralph wrote:
I just rewrote "Label EQU $-PreviousLabel" as:

When using Label in you code it will be replaced with $-PreviousLabel, so the value will vary depending on where in the code you are when you use it.
But with "Label = $-PreviousLabel" you'll have the value of $ will be that which it has/had on the line where the label is defined.

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 10 Oct 2003, 04:47
View user's profile Send private message Visit poster's website Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Dunduk 10 Oct 2003, 05:18
When you define "Label equ $-SomeLabel" and use it in various places of code, you'll get various values of Label. And with "Label = $-SomeLabel" you will get the same value... Or I didn't understand what you wanted to say?
Post 10 Oct 2003, 05:18
View user's profile Send private message Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Dunduk 10 Oct 2003, 05:21
Ooops, scientica already answered the question Smile
Post 10 Oct 2003, 05:21
View user's profile Send private message Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph 10 Oct 2003, 05:35
Right, I understand that, hence the use of a hardcoded value instead of $. That wasn't my question :). I want to know why fasm complains about not finding a label when it is declared using EQU, but does when it is using =.
Post 10 Oct 2003, 05:35
View user's profile Send private message Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Dunduk 10 Oct 2003, 05:46
Ralph wrote:
I want to know why fasm complains about not finding a label when it is declared using EQU, but does when it is using =.

Can you introduce some small piece of compilable code with that thing? Maybe we'll find the truth together.
Post 10 Oct 2003, 05:46
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 10 Oct 2003, 07:47
Post 10 Oct 2003, 07:47
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.