![]() |
![]() |
#1 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
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 (?) 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 |
![]() |
![]() |
#2 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
STRUCTURE is a macro that is defined in exec/types.i, did you include that very file? The 0 means the initial offset.
|
![]() |
![]() |
#3 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
![]() 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 |
|
![]() |
![]() |
#4 |
Registered User
Join Date: Sep 2008
Location: Gainesville U.S.A.
Posts: 771
|
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.
|
![]() |
![]() |
#5 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
![]() 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? |
|
![]() |
![]() |
#6 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
Quote:
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 |
|
![]() |
![]() |
#7 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
|
|
![]() |
![]() |
#8 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
I tried to create my own structure, similar as above, but how can I create a statically initialized structure object?
I have a structure like this: Code:
STRUCTURE CopperInfo,0 UWORD CI_ListSize APTR CI_Player UWORD CI_CurPos LABEL sizeof_CopperInfo When I reserve space in my module like this, it would create just a single byte with the size, right? Code:
CopperInfo1: dc.b sizeof_CopperInfo Code:
CopperInfo1: ds.b sizeof_CopperInfo Code:
CopperInfo1: struct CopperInfo CI_ListSize = MyCopperListSize CI_Player = MyCopperListHandler ; CI_CurPos is reserved but not initialized yet. Code:
static CopperInfo ci = { MyCopperListSize, &MyCopperListAnimation }; |
![]() |
![]() |
#9 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,642
|
Yeah, no assemblers I know of, support that.
The macros only "declare" the struct (actually just offsets to labels); you can't use them to instantiate it, because they are not really types which the assembler can reason about like a compiler does. |
![]() |
![]() |
#10 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,545
|
Quote:
Code:
myCopperInfo: dc.w listsize dc.l player dc.w curpos Quote:
Quote:
A similar directive would be possible in mot-syntax. But I decided against it, because it is unusual and would be incompatible to any other 68k assembler. |
|||
![]() |
![]() |
#11 | |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
WOW! Just checked again and suddenly I found it. LOL. Using the PDF search it doesn't seem to find it. Quote:
Does this mean, that I can switch between syntax modules in the source? Or is the respective syntax module statically linked in the assembler binary, so when I use the mk68vasm it uses the "mot" module? I tried different variations but I always get an error "unknown mnemonic struct" or "unknown mnemonic endstruct", so I assume that the Old Style Syntax module is not enabled. So when I use a different vasm with the Old Style Syntax I probably can not assemble the standard includes, right? So if I understand you correctly, with the mot module, I have to initialize a structure only at runtime, which is a bit limiting. Is the source from vasm somewhere available in a repository? I only have the source as a download. I was thinking of maybe extending the documentation with a bit of examples, to make it easier to understand. Or how can one contribute? Last edited by sparhawk; 03 January 2020 at 12:36. |
|
![]() |
![]() |
#12 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,642
|
You can switch syntax using command line flags - no need for a different binary.
Edit: This is wrong, of course - don't know what I was thinking :-D Last edited by hooverphonique; 03 January 2020 at 15:23. |
![]() |
![]() |
#13 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
You can always initialize your structures with dc directives in macros...
|
![]() |
![]() |
#14 | ||||||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,545
|
Quote:
Quote:
![]() Quote:
make CPU=m68k SYNTAX=oldstyle But "oldstyle" is, as the name implies, intended for 8-bit CPUs. So I cannot recommend it. Quote:
Quote:
Quote:
Quote:
Quote:
![]() You can switch the output module with -F. But neither the CPU- nor the syntax-module. |
||||||||
![]() |
![]() |
#15 | ||||
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Quote:
![]() Quote:
Quote:
![]() Quote:
|
||||
![]() |
![]() |
#16 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,642
|
|
![]() |
![]() |
#17 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
|
![]() |
![]() |
#18 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
Quote:
Code:
init_copinfo macro dc.w \1 dc.l \2 dc.w \3 endm CopperInfo1: init_copinfo MyCopperListSize,MyCopperListHandler,0 |
|
![]() |
![]() |
#19 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
What is the 'dr.x' directive used for? Is there some example for this?
More general: Are there any sample sources where one could look how the various directives are used? |
![]() |
![]() |
#20 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,545
|
I think that DR stands for Data Relative and writes the difference between the given value (usually a label) and the current address into memory.
Quote:
Code:
label: dr.w label,label dc.w 0,-2 Quote:
Many recent projects were written with vasm. You can for example check the source from my game projects. The latest is here: https://server.owl.de/~frank/BlkStberries.lha |
||
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Structure of CopList object? | earok | Coders. Blitz Basic | 10 | 22 June 2019 05:37 |
Resource and Structure.offs | copse | Coders. General | 4 | 23 December 2013 23:56 |
Side-scroller, boy in house, big friendly green monster roams around [Found: Mot] | Cherno | Looking for a game name ? | 3 | 20 October 2013 00:55 |
|
|