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: 2090
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: 2090
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: 2090
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: 2090
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: 2090
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
\} }

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
}
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
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.