flat assembler
Message board for the users of flat assembler.

flat assembler > Main > Struc

Author
Thread Post new topic Reply to topic
Chewy509



Joined: 19 Jun 2003
Posts: 297
Location: Bris-vegas, Australia
Hi all,

Just a quick question, regarding structures. I have a structure that is pointed to by "es", so by modifying es, I can point to different memory regions which hold the structure. At the moment, I am using "equ" to setup structures, but this is extremely messy.

So, after a quick read of the FASM manual, it quickly explains struc's, and the use of the virtual keyword, but how do I combine the 2 to do what I want?
Post 24 Jul 2003, 02:55
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
Hi. As I can understand, you talk about DOS programming. So, I am using following:

Code:
struc Mystruc {
  .field1 db ?
  .field2 dd ?
  .field3 rb 256
}

virtual at 0
  MyStruc MyStruc     ; Or see "struct" macro definition - it's the same
end virtual


; then in code:
; es points to variable of type Mystruc
; gs points to second variable of type Mystruc

         mov  eax, [es:Mystruc.field2]
         mov  [gs:Mystruc.field2], eax    ; copy field2 from first structure to second
    



Regards
Post 24 Jul 2003, 07:32
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Dear johnFound:
You code present a short bug, The complier will show "illeagul Instruction". Because the sources of fasm are case-sensitive. The successful code is belowing:
Code:

struc MyStruc { 
  .field1 db ? 
  .field2 dd ? 
  .field3 rb 256 
} 

virtual at      0 
  MyStruc MyStruc     ;Or see "struct" macro definition - it's the same 
end virtual 

       org     100H
        use16
; then in code: 
; es points to variable of type Mystruc 
; gs points to second variable of type Mystruc 

         mov  eax, [es:MyStruc.field2] 
         mov  [gs:MyStruc.field2], eax    ; copy field2 from first structure to second 
         mov  ax,4C00H
         int        21H
    

Thanks your helpping.


Description:
Download
Filename: macro2.zip
Filesize: 487 Bytes
Downloaded: 434 Time(s)

Post 24 Jul 2003, 12:21
View user's profile Send private message MSN Messenger Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
It's not a bug, it's due to oversight. I never try to compile this code. But you take the idea as I can see, so all is OK. Smile
Post 24 Jul 2003, 12:53
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Chewy509



Joined: 19 Jun 2003
Posts: 297
Location: Bris-vegas, Australia
Thanks for clarifying that. Very Happy
Post 24 Jul 2003, 23:09
View user's profile Send private message Visit poster's website 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-2019, Tomasz Grysztar.

Powered by rwasa.