English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 19 October 2018, 22:58   #1
guy lateur
Registered User

guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 45
Posts: 279
vasm/mot: structure

Here's what I would like to use:
Code:
STRUCTURE   TextPage,0          ;what does this 0 mean/do?
    UWORD   tp_NrLines          ;# of lines
    UWORD   tp_CurrLine         ;current line index
    APTR    tp_TextPointersPtr  ;pointer to text pointers 
    APTR    tp_NrsCharsPtr      ;pointer to #s of chars
    LABEL   tp_SIZEOF           ;end structure (?)
I have seen this used in several books (even RKRM: includes & autodocs), and in some include files (eg, intuition.i), but I can't seem to get it to work in vasm/mot. The documentation says its support should be implemented in the syntax module (mot), and it's not mentioned there. So I'm guessing this is not supported?

If not, how do I 'roll my own'? I can imagine some offset definitions, like this (to be used with a pointer to a block of memory initialised at startup):
Code:
tp_NrLines          equ 0
tp_CurrLine         equ 2
tp_TextPointersPtr  equ 4
tp_NrsCharsPtr      equ 8
tp_SIZEOF           equ 12
Is this how it's done? Any chance of dynamic allocation of such 'structures'? Any good examples I could look at? TIA!
guy lateur is offline  
Old 19 October 2018, 23:04   #2
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,146
STRUCTURE is a macro that is defined in exec/types.i, did you include that very file? The 0 means the initial offset.
StingRay is offline  
Old 19 October 2018, 23:30   #3
guy lateur
Registered User

guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 45
Posts: 279
Quote:
Originally Posted by StingRay View Post
STRUCTURE is a macro that is defined in exec/types.i, did you include that very file? The 0 means the initial offset.
Well I have included that file now, and I must say it's much better, so thanks a lot!

I'm still a bit confused about vasm mentioning structures as a feature, though. For once, I have been Reading TFM, and it says on page 7 of the vasm.pdf, under 2.6: "Vasm supports structures, but the directives for defining them have to be implemented in the syntax module."

Anyway, it seems like this is just a little helper for obtaining those sequential offsets I was talking about earlier, right? So you'd have something like this:
Code:
textResetPage:
    lea     testTP,a0
    move.w  #0,tp_NrLines(a0)
    move.w  #0,tp_CurrLine(a0)
    ;and so on
.return:
    rts 

    STRUCTURE   TextPage,0          
    UWORD       tp_NrLines          ;# of lines
    UWORD       tp_CurrLine         ;current line index
    APTR        tp_TextPointersPtr  ;pointer to text pointers 
    APTR        tp_NrsCharsPtr      ;pointer to #s of chars
    LABEL       tp_SIZEOF           ;end structure (?)

testTP:
    ds.b    tp_SIZEOF,0
Is this about right? Anything else I should consider/remember?
guy lateur is offline  
Old 20 October 2018, 00:08   #4
clenched
Registered User

 
Join Date: Sep 2008
Location: Gainesville U.S.A.
Posts: 639
Quote:
Originally Posted by guy lateur View Post
For once, I have been Reading TFM, and it says on page 7 of the vasm.pdf, under 2.6: "Vasm supports structures, but the directives for defining them have to be implemented in the syntax module."
The vasm manual is talking about an assembler directive named structure instead of a macro named structure. Used with oldstyle syntax. So stay with what you are doing.
clenched is offline  
Old 20 October 2018, 00:19   #5
guy lateur
Registered User

guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 45
Posts: 279
Quote:
Originally Posted by clenched View Post
The vasm manual is talking about an assembler directive named structure instead of a macro named structure. Used with oldstyle syntax. So stay with what you are doing.
Ok, thanks.

I seem to be not doing anything with the structure name (TextPage), ATM. I can't seem to write TextPage.tp_NrLines or anything like that. That would be cool, though, because then I would actually write TextPage.NrLines. So what purpose does this name serve?
guy lateur is offline  
Old 20 October 2018, 11:21   #6
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 45
Posts: 3,235
Quote:
Originally Posted by guy lateur View Post
I seem to be not doing anything with the structure name (TextPage), ATM. I can't seem to write TextPage.tp_NrLines or anything like that. That would be cool, though, because then I would actually write TextPage.NrLines. So what purpose does this name serve?
It does not seem to serve a useful purpose, considering the definition of the macro : it is just a label set to 0.


Personnally i would define your structure as :
Code:
 rsreset                   ; start struct TextPage
tp_NrLines rs.w 1          ; # of lines
tp_CurrLine rs.w 1         ; current line index
tp_TextPointersPtr rs.l 1  ; pointer to text pointers 
tp_NrsCharsPtr rs.l 1      ; pointer to #s of chars
tp_SIZEOF so               ; size of structure
meynaf is offline  
Old 20 October 2018, 11:39   #7
guy lateur
Registered User

guy lateur's Avatar
 
Join Date: May 2017
Location: Belgium
Age: 45
Posts: 279
Quote:
Originally Posted by meynaf View Post
Personnally i would define your structure as :
Code:
 rsreset                   ; start struct TextPage
tp_NrLines rs.w 1          ; # of lines
tp_CurrLine rs.w 1         ; current line index
tp_TextPointersPtr rs.l 1  ; pointer to text pointers 
tp_NrsCharsPtr rs.l 1      ; pointer to #s of chars
tp_SIZEOF so               ; size of structure
I see, thanks for the tip. The ability to specify how many bytes/words/.. to account for could come in handy, I guess.
guy lateur is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Structure of CopList object? earok Coders. Blitz Basic 9 29 August 2018 23:19
Resource and Structure.offs copse Coders. General 4 24 December 2013 00:56
Side-scroller, boy in house, big friendly green monster roams around [Found: Mot] Cherno Looking for a game name ? 3 20 October 2013 01:55

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:22.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.08639 seconds with 13 queries