flat assembler
Message board for the users of flat assembler.

Index > Main > How to move value to structure?

Author
Thread Post new topic Reply to topic
jeff



Joined: 07 Apr 2005
Posts: 28
jeff 20 Jul 2008, 18:05
How do you use a structure with a pointer in fasm? I have allocated memory and want to fill it with a structure.
;
; ebp points to allocated memory
; we have a structure called struc with
{
.name rb 1
.token rb 1
}
; in nasm you would code:
mov [ebp+struc.name],byte value
;
I've tried: mov [ebp.name],value
mov [ebp+ .name],value
Post 20 Jul 2008, 18:05
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 20 Jul 2008, 18:12
struc in fasm are an special case of macros actually so they not provide an actual type definition, yet, there is a well known workaround for it:
Code:
struc Point{
  .x dd ?
  .y dd ?
}
;; Workaround
virtual at 0
  Point Point
end virtual

; Now you can use the struc as an offset
mov [ebp+Point.y], 7    
Post 20 Jul 2008, 18:12
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.