Author Topic: Combine structures  (Read 1117 times)

Offline akasei

  • Jr. Member
  • *
  • Posts: 8
Combine structures
« on: April 27, 2017, 07:54:30 PM »
Is it possible in some way to attach the structure to another?
eg.
Code: [Select]
struc RIZE_STRUCTURE_OBJECT
.x resb 8
.y resb 8
.width resb 8
.height resb 8
.state_address resb 8
endstruc

struc RIZE_STRUCTURE_WINDOW
RIZE_STRUCTURE_OBJECT
.size resb 8
.width_virtual resb 8
.height_virtual resb 8
.status resb 1
.background_color resb 4
.border resb 1
.elements resb 8
.SIZE:
endstruc

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2358
  • Country: us
Re: Combine structures
« Reply #1 on: April 27, 2017, 09:03:57 PM »
I suppose...
Code: [Select]
struc RIZE_STRUCTURE_OBJECT
.x resb 8
.y resb 8
.width resb 8
.height resb 8
.state_address resb 8
endstruc

struc RIZE_STRUCTURE_WINDOW
.RIZE_STRUCTURE_OBJECT resb RIZE_STRUCTURE_OBJECT_size
.size resb 8
.width_virtual resb 8
.height_virtual resb 8
.status resb 1
.background_color resb 4
.border resb 1
.elements resb 8
.SIZE:                     resb 8 ;?
endstruc
Didn't I just answer this?

This is rather horrible, with ".size" and ".SIZE" as elements, plus "struc_name_size", but it ought to work(?). Untested!

Probably should note that you've just got a "typedef" here - no memory allocated for it/them as yet. Use "istruc" to initialize it/them or "resb ..._size" in section .bss.

Best,
Frank

EDIT: Ah, yes, here:
https://forum.nasm.us/index.php?topic=2325.0
I don't think this is exactly what Kazu wanted. May not be what you want either...
« Last Edit: April 27, 2017, 09:12:56 PM by Frank Kotler »

Offline akasei

  • Jr. Member
  • *
  • Posts: 8
Re: Combine structures
« Reply #2 on: May 03, 2017, 09:04:47 PM »
Probably should note that you've just got a "typedef" here - no memory allocated for it/them as yet.
Don't worry, everything is working just fine.

BTW. the last line of struct is good too, don't ever try to add "resb/w/d/q" or anything else there.
eg.
Code: [Select]
; next record of table
add rsi, RIZE_STRUCTURE_WINDOW.SIZE
so, this LABEL inside structure is what i need.

Your answer, error, nasm complain about "undefined symbols"
Code: [Select]
[...]
daemon/rize/window.asm:422: error: symbol `RIZE_STRUCTURE_WINDOW.x' undefined
daemon/rize/window.asm:423: error: symbol `RIZE_STRUCTURE_WINDOW.width_virtual' undefined
daemon/rize/window.asm:476: error: symbol `RIZE_STRUCTURE_WINDOW.x' undefined
daemon/rize/window.asm:571: error: symbol `RIZE_STRUCTURE_WINDOW.width_virtual' undefined
daemon/rize/window.asm:572: error: symbol `RIZE_STRUCTURE_WINDOW.height_virtual' undefined
daemon/rize/window.asm:597: error: symbol `RIZE_STRUCTURE_WINDOW.state_address' undefined
daemon/rize/window.asm:656: error: symbol `RIZE_STRUCTURE_WINDOW.width_virtual' undefined
daemon/rize/window.asm:661: error: symbol `RIZE_STRUCTURE_WINDOW.height_virtual' undefined
daemon/rize/window.asm:682: error: symbol `RIZE_STRUCTURE_WINDOW.width_virtual' undefined
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 1
cp: cannot stat 'build/kernel': No such file or directory



struc RIZE_STRUCTURE_OBJECT
.x resb 8
.y resb 8
.width_virtual resb 8
.height_virtual resb 8
.color_foreground resb 8
.state_address resb 8
.SIZE:
endstruc

struc RIZE_STRUCTURE_WINDOW
.RIZE_STRUCTURE_OBJECT resb RIZE_STRUCTURE_OBJECT.SIZE
.width resb 8
.height resb 8
.size resb 8
.status resb 1
.background_color resb 4
.border resb 1
.elements resb 8
.SIZE:
endstruc

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2358
  • Country: us
Re: Combine structures
« Reply #3 on: May 03, 2017, 10:42:11 PM »
Okay... I guess you know what you're doing...

Best,
Frank