flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > complex struct. How do ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 2108
Roman 10 Aug 2026, 14:27
I want do somthing like this.
Code:
struc affaf [x] { x dd 0 }
struct frettt
       life affaf x,y,z
ends
jumpii frettt  

;in code error
mov [jumpii.life.x],1 ;undefined jumpii.life.x
mov [jumpii.life.y],2
mov [jumpii.life.z],3
    
Post 10 Aug 2026, 14:27
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2108
Roman 10 Aug 2026, 16:53
Code:
struc affaf [x] { .x dd 0 }
struct frettt
       life affaf x,y,z ;fasm error alredy defined frettt.life.x
ends
jumpii frettt 
    
Post 10 Aug 2026, 16:53
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2108
Roman 10 Aug 2026, 17:11
I try this but error
Code:
struc affaf x { irp r,x \{
;display r
r dd 0
\} }
struct frettt
       life affaf <.x,.y,.z>
ends
jumpii frettt  

mov [jumpii.life.x],1 ;undefined jumpii.life.x
mov [jumpii.life.y],2 ;undefined jumpii.life.y
    
Post 10 Aug 2026, 17:11
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2108
Roman 10 Aug 2026, 17:23
This work !
Code:
struc affaf pp { irp r,pp \{
;display pp
r dd 0
\} }
struc frettt   {
         .x affaf <.life.x,.life.y,.life.z>
}
jumpii frettt  

;in code
mov [jumpii.life.x],1  
mov [jumpii.life.y],2
mov [jumpii.life.z],3

mov [jumpii.x],3 ;= mov [jumpii.life.x],3
    
Post 10 Aug 2026, 17:23
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2108
Roman 11 Aug 2026, 04:36
Code:
macro zero@Struct ss { local up
                       mov eax,ss#.bgn
                  up:  if ss#.Type = 1
                       mov dword [eax],0
                       add eax,4
                       end if
                       if ss#.Type = 0                 ;byte
                       mov byte [eax],0
                       inc eax
                       end if
                       if ss#.Type = 2
                       mov dword [eax],1.0
                       add eax,4
                       end if
                       cmp eax,ss#.end
                       jnz up
}

macro cs@. v,n { if v#.Type = 1
               mov dword [v],n
               end if
               if v#.Type = 0
               mov byte [v],n
               end if
               if v#.Type = 2
               mov dword [v],n#f
               end if
}
struc csafint pp { irp r,pp \{
;display pp
r dd 0
r\#\.Type equ 1
\} }

struc csafbyte pp { irp r,pp \{
r db 0
r\#\.Type equ 0
\} }

struc csaflt pp { irp r,pp \{
;display pp
r dd 0
r\#\.Type equ 2
\} }
macro mmm@cs4  v,e {
         v#.bgn csaflt <v#.x,v#.y,v#.z,v#.w>
         v#.end:
         v#.Type equ e
}
struc complexStructF   {
         .life.bgn csafint <.life.x,.life.y>
         .life.end:
         .life.Type equ 1  ;int
         .pos.bgn csaflt <.pos.x,.pos.y,.pos.z>
         .pos.end:
         .pos.Type equ 2  ;float
         mmm@cs4 .quat,2
}
jumpii complexStructF

        mov eax,jumpii.life.x.Type
        mov eax,jumpii.pos.x.Type
        cs@. jumpii.life.x , 2
        cs@. jumpii.pos.z , 2
        

        zero@Struct  jumpii.life
        zero@Struct  jumpii.pos
    
Post 11 Aug 2026, 04:36
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1235
Location: Russia
macomics 11 Aug 2026, 16:25
Code:
struc A [x] { .#\.#x dd 0 }
struc B { .life A x,y,z }
C B
mov dword [C.life.x], eax
mov [C.life.y], eax
mov [C.life.z], eax
    
Post 11 Aug 2026, 16:25
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2108
Roman 12 Aug 2026, 04:33
Thanks macomics. Good variant.
I rewrited to my solution.
Code:
struc cssA [x] { .#\.#x dd 0
.#\.#x#\.Type equ 2
}
struc cssB { 
      .life.bgn:
      .life cssA x,y,z,w,d,g
      .life.end:
      .life.Type equ 2
      }
;in code
new cssB
    
Post 12 Aug 2026, 04:33
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2108
Roman 12 Aug 2026, 07:56
I want do macro. But error
Code:
macro m@cs obj {  ;display  obj
match a,obj \{  a 
\}
}  
macro mInc {inc dword [eax] }
struc cssB { 
      .life.bgn:
      .life cssA x,y,z,w,d,g
      .life.end:
      .life.Type equ 2
      .life.macro equ mInc
      }

;in code i do
jj cssB
m@cs jj.life.macro ;i want get inc dword [eax]. but get fasm error
    
Post 12 Aug 2026, 07:56
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1235
Location: Russia
macomics 12 Aug 2026, 15:26
Code:
struc cssA [x] { .#\.#x dd 0
 .#\.#x#\.#Type equ 2
;^  ^ ^  ^ ^- Type
;|  | |  +- \. = '.'
;|  | +- 'x' or 'y' or 'z' or 'w' or 'd' or 'g'
;|  +- \. = '.'
;+- jj.life
; jj.life.x.Type
}
macro m@cs obj {  ;display  obj
match a,obj \{  a 
\}
}  
macro mInc {inc dword [eax] }
struc cssB { 
      .life.bgn:
      .life cssA x,y,z,w,d,g
      .life.end:
      .life.Type equ 2
      .life.macro equ mInc
      }

;in code i do
jj cssB
m@cs jj.life.macro    
bash wrote:
Code:
$ fasm fasm_RomanStrucFields.asm
flat assembler  version 1.73.34  (16384 kilobytes memory, x64)
1 passes, 28 bytes.

$ hexdump -C fasm_RomanStrucFields.bin
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000010  00 00 00 00 00 00 00 00  67 66 ff 00              |........gf..|    

Code:
inc dword [eax] ; 67 66 ff 00    
Post 12 Aug 2026, 15:26
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1235
Location: Russia
macomics 12 Aug 2026, 15:36
bash wrote:
Code:
$ cat fasm_RomanStrucFields.asm
struc cssA [x] { .#\.#x dd 0
.#\.#x#\.#Type equ 3
}
macro m@cs obj {  ;display  obj
match a,obj \{  a 
\}
}  
macro mInc {inc dword [eax] }
struc cssB { 
      .life.bgn:
      .life cssA x,y,z,w,d,g
      .life.end:
      .life.Type equ 1
      .life.macro equ mInc
      }

;in code i do
jj cssB
m@cs jj.life.macro ;i want get inc dword [eax]. but get fasm error
display 'jj.life.Type = ', '0' + jj.life.Type, 0xa
display 'jj.life.x.Type = ', '0' + jj.life.x.Type, 0xa
$ fasm fasm_RomanStrucFields.asm
flat assembler  version 1.73.34  (16384 kilobytes memory, x64)
jj.life.Type = 1
jj.life.x.Type = 3
1 passes, 28 bytes.
$ hexdump -C fasm_RomanStrucFields.bin
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000010  00 00 00 00 00 00 00 00  67 66 ff 00              |........gf..|    
Post 12 Aug 2026, 15:36
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2108
Roman 12 Aug 2026, 18:56
Thanks.
Now compiled fine.
Post 12 Aug 2026, 18:56
View user's profile Send private message 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-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.