It doesn't work
Because it is wrong. Here:
bits 32
struc rsdp
.signature: resb 8
.checksum: resb 1
.oemid: resb 6
.revision: resb 1
.rsdtaddr: resd 1
.length: resd 1
.xsdtaddr: resd 1
.extcksum: resb 1
.reserved: resb 3
.size: resd 1
endstruc
struc xsdt
.signature: resb 8
.length: resd 1
.revision: resb 1
.checksum: resb 1
.oemid: resb 6
.oemtableid: resb 8
.oemrevision: resd 1
.creatorid: resd 1
.creatorrevision: resd 1
.entry: resq 19
.size: resd 1
endstruc
section .data
acpitable:
.rsdp:
istruc rsdp
at rsdp.signature, db "RSD PTR "
at rsdp.xsdtaddr, dd acpitable.xsdt
at rsdp.size, dd rsdp.size ; or rsdp_size - 4
iend
.xsdt:
istruc xsdt
at xsdt.signature, db "XSDT"
at xsdt.size, dd xsdt.size ; or xsdt_size - 4
iend
section .text
global get_xsdt_creatorid
get_xsdt_creatorid:
call get_rsdp_xsdtaddr
mov eax,[eax + xsdt.creatorid]
ret
global get_rsdp_xsdtaddr
get_rsdp_xsdtaddr:
mov eax,[acpitable.rsdp + rsdp.xsdtaddr]
ret
omg, way too much complicated for label management.
This code looks like C trying to be OOP
I want something that keep the local label mechanism but enhanced, like this:
ACPITable:
;{
.RSDP:
;{
Signature: db "RSD PTR "
Checksum: db 0
OEMID: times 6 db 0
Revision: db 0
RsdtAddress: dd 0
Length: dd 0
XsdtAddress: dq 0
ExtendedChecksum: db 0
Reserved: times 3 db 0
Size: dd $ - RSDP
List:
;{
.VarA: db 0
.Case:
;{
VarA: db 0
;}
.EndCase:
;}
EndList:
;}
.EndRSDP:
.XSDT:
;{
Signature: db "XSDT"
Length: dd 0
Revision: db 0
Checksum: db 0
OEMID: times 6 db 0
OEMTableID: times 8 db 0
OEMRevision: dd 0
CreatorID: dd 0
CreatorRevision: dd 0
Entry: times 19 dq 0
Size: dd $ - XSDT
List:
;{
.VarA: db 0
.Case:
;{
VarA: db 0
;}
.EndCase:
;}
EndList:
;}
.EndXSDT:
;}
EndACPITable:
Ok I explain how this code can be parsed.
Root Label come without dot '.'
Local Label come with a dot '.'
First the assembler detect a root label (ACPITable:) and it ends its scope when seeing another root label (EndACPITable:) and not between root label (Signature: ect) since local label do have scope capability.
So the assembler start the name decoration with "ACPITable."
Then the assembler hit a local label (.RSDP:) add it to the name decoration and open a new scope that await to be closed when hitting another local label.
Inside this local scope(.RSDP:) assembler can add all the labels between and they have to be root label in order to not break the current label scoping.
But seeing root label (List:) inside the current local label scope (.RSDP:) activate another nested scope (3 scope layers at this stage) and ends its scope level when seeing another root label (EndList:)
Thus when arrived at the root label (List:) the assembler add all local label inside the root label (List:) until he found another root label (EndList:) but remember that the assembler open scope each time it see a root or a local label.
Thus the local label (.Case:) open a new inner scope that will add the root label (VarA:) and end its scope to (.EndCase:).
Hope I was clear enough.
I can make a working demo in order to implement it to the next NASM update.