flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Assign a name to a line of code

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 15 Oct 2010, 17:13
Hello,

I was wondering if it's possible to do something like this:

Code:
sMyStruct struct 

   p1 dd 0
   p2 dd 0

ends

struct1 sMyStruct

this EQU struct1 + sMyStruct    ; ERROR HERE!!!

mov [this.p1], 0     ; FAILS!    


How can we define "this" to make the above work?

Thanks!
Post 15 Oct 2010, 17:13
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 15 Oct 2010, 19:41
Code:
struct sMyStruct

   p1 dd 0
   p2 dd 0

ends

struct1 sMyStruct

virtual at struct1
  this sMyStruct
end virtual

mov [this.p1], 0     ; WORKS!    
But still, I'm not sure this is really useful for you, what are you trying to do exactly?
Post 15 Oct 2010, 19:41
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 15 Oct 2010, 23:19
alorent,

Are you trying to overwrite part of mov [this.p1], 0 instruction with 0? This works:
Code:
struct sMyStruct
   p1 dd 0
   p2 dd 0
ends

struct1 sMyStruct

virtual
  this sMyStruct
end virtual

mov [this.p1], 0    
Though mov [$], dword 0 looks simpler.
Post 15 Oct 2010, 23:19
View user's profile Send private message Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 16 Oct 2010, 05:47
Thanks guys!

I have tried to make a set of macros to simulate basic OO (Objected Oriented) programming, with the idea of making things more "organized" in assembly and better programming.

I have realized that at the end I will make the code more obscure and dirty as assembly is what it is, assembly Smile So I was going to get the opposite of my main objective (clarity, better coding).

Well, hopefully someone will make in FASM something that is really OO coding and not something that makes things more obscure Smile

Thanks!
Post 16 Oct 2010, 05:47
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.