From: Michael K T. L. <mte...@gm...> - 2002-11-09 18:24:08
|
> In particular I'm trying to define a label with a really large segment > portion, by using ABSOLUTE and EQU. This is not the correct way to go about it. When you use EQU you are defining a lable that is not attached to *any* segment. If you want your lable attached to the current ABSOLUTE segment you should res- to the label location and then just declare it using label: . > the use of 'segment' is broken -- on one side it holds the segment > number (whereas the lowest bit has that special meaning), but on the > other side it holds an absolute address In absolute segments, the segment base is kept in abs_segment, which is a completely different variable from location.segment. location.segment carries the NO_SEG status, and when the label is defined that status tells Nasm to use abs_segment for the segment portion of the label. The only time SEG_ABS comes into play is when using EQUs, and it is perfectly fine there since EQUs *do not* have a segment portion (unless you are using the undocumented two-operand form of EQU). See in nasm.c where it only defines the EQU when the operand is wrt NO_SEG (lines 1141-1150). > ABSOLUTE F0000000h I don't think this makes much sense (see below). > label: > > ; later, inside some code/data segment > > DD SEG label ; should emit 00 00 00 F0 > > DB (SEG label) >> 24 ; should emit F0 > > I'm writing protected mode code, and I know in advance at which address > that code is going to reside in memory. Said address is above 1 MB, > i.e. has a segment base that doesn't fit into 20 bits. > > Then I am trying to define various labels, so that I can use both their > segment and their offset portion, either to perform arithmetic > or to emit actual code. A GDT for example. > > So I'm trying to use a single label, and since x86 provides a 4 GB > virtual address space, I'm expecting labels to be able to cope with > both, a dword offset _and_ a dword segment part. This is why I think the above example of 'ABSOLUTE 0F0000000h' doesn't make sense. If you have a 4Gb address space, then you can very well have a dword offset but you're limited to a 28-bit segment. An address is computed using ((segment << 4) + offset), so 0F0000000h would describe a segment that only exists in a 36-bit address space. >> dd seg label ; should result in a dword = 40000000h It does (see HPA's example), however it requires that you're using *labels* and not EQUs. If you really must use EQUs, you can try using the undocumented segment:offset format: some_label EQU 0x0F000000:0 but I don't guarantee that it will work. For what you're trying to do you should probably stick to using ABSOLUTE, and then pad to the label offset using resb, resw, resd, etc.. In any case, I think this one can safely be removed from the bug list. Mike |