flat assembler
Message board for the users of flat assembler.

Index > Main > How to expand Extrn and AS instruction to support struct

Author
Thread Post new topic Reply to topic
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng 06 Sep 2006, 02:02
Hi, All:
I'm writting a pure assembly win32 application through MS COFF format, there are three assembly files on it, I've defined a struct variable on first file, and I want to use extrn syntax to access this struct variable. But unfortunately, I've found that the extrn and as instrcution don't support struct macro. Are you good advise for it?

Hi, Tomas:
I think that you maybe define the struct as a internal keyword for example align keyword, it maybe more useful than macro define.

Thanks.

Kevin Zheng

Code:
A.file:
struct SPIOpStruct
  Preop0         db     ?; preop 0 (Write enable)            
  Preop1         db     ?; preop 1 (Write status register)   
ends

b.file:
EXTRN   '_SpiReg'               AS      SpiReg:SpiOpStruct

mov     [SpiReg.Preop0], ebx
    
Post 06 Sep 2006, 02:02
View user's profile Send private message MSN Messenger Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent 06 Sep 2006, 06:07
You must use a struct declaration as in the HLL and 'virtual' wrapper:

Code:
; struct.inc
struct SPIOpStruct 
  Preop0         db     ?; preop 0 (Write enable)             
  Preop1         db     ?; preop 1 (Write status register)    
ends

; A.file
include 'struct.inc'

; data definition
SpiReg SPIOpStruct
public SpiReg as '_SpiReg'

B.file
include 'struct.inc' ; struct declaration
EXTRN   '_SpiReg'               AS      SpiReg:word ; SpiReg declaration

; place new ..SpiReg at external SpiReg address
virtual at SpiReg
        ..SpiReg SPIOpStruct
end virtual

; and now use it
mov             [..SpiReg.Preop0],al    
Post 06 Sep 2006, 06:07
View user's profile Send private message Reply with quote
Kevin_Zheng



Joined: 04 Jul 2003
Posts: 125
Location: China
Kevin_Zheng 08 Sep 2006, 00:45
Hi, IceStudent:
Thank you very much! It's a very good soultion for it. And other, I have another method to do it.
Code:
; struct.inc 
struct SPIOpStruct  
  Preop0         db     ?; preop 0 (Write enable)              
  Preop1         db     ?; preop 1 (Write status register)     
ends 

; A.file 
include 'struct.inc' 

; data definition 
SpiReg SPIOpStruct 
public SpiReg as '_SpiReg' 

B.file 
include 'struct.inc' ; struct declaration 
EXTRN   '_SpiReg'               AS      SpiReg:word ; SpiReg declaration 

lea     esi, [SpiReg]
mov     [esi+SpiRegStruct.PreOp0], al

    


Thanks.

Kevin Zheng
Post 08 Sep 2006, 00:45
View user's profile Send private message MSN Messenger 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.