Code: Select all
struc foo
.bar: resb 1
endstruc
foobar:
istruc foo
at .bar, db 00h
iend
Code: Select all
struc foo
.bar: resb 1
endstruc
foobar:
istruc foo
at .bar, db 00h
iend
Code: Select all
struc foo
bar1: resb 1
.bar2: resb 1
endstruc
Code: Select all
struct foo{
int a,b;
};
a=3; //illegal,may be another var outside our struct
foo.a=3; //much better
For NASM, there's labels and there's local labels (and some other stuff). For example:CodeCat wrote:So then the foo.bar syntax is actually just a sneaky shorthand for .bar - start_of_foo or something?
Code: Select all
foo:
nop
.l1:
nop
.l2:
nop
bar:
nop
.l1:
nop
.l2:
nop
jmp .l2
Code: Select all
absolute 0x00000000
myStructureType:
.foo: resd 1
.bar: resb 8
.woot: resw 2
section .data
myStructure:
times (myStructureType.foo - myStructure) db 0
dd 0x12345678
times (myStructureType.foo - myStructure) db 0
db "Hello",0
times (myStructureType.woot - myStructure) db 0
dw 0x1234,0x5678
Well it helps you spot missing fields, if nothing else.Shrek wrote:Hi,
Macros are not really required , you can achieve the result without them .So the struct macro / construct is not really needed . I really do not know which is recommeded way , I think there are some programmers of "pure assembly blood" hanging around here.