26 December 2018, 22:16 | #1 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
vasm/mot: data structures
I've been using RS to define some data structures, like this:
Code:
EVEN rsReset ; start struct scrTxtMem scrTxtMem_PtrTopBlank rs.l 1 ; pointer to top blank scrTxtMem_PtrTopOpen rs.l 1 ; pointer to top open/visible area scrTxtMem_PtrBottomBlank rs.l 1 ; pointer to bottom blank scrTxtMem_SizeOf rs.w ; end/size of struct scrTxtMem I was doing this from memory recently, and assumed that I did not need to specify the number of parameters if I only wanted 1. So I assumed writing just rs.lwas equivalent to writing rs.l 1. This is clearly not the case. I think it defaults to rs.l 0, but I'm not sure. I've been looking in the manual for info on the syntax of the rs.b|w|l'directive' (?), but I can't seem to find much. I can info on the set/reset/clr directives for so/fo, and how rs is very similar, but nothing specific on defining the fields/properties of the rs/so/fo structure. Am I missing something? And shouldn't it default to 1, instead of 0? |
27 December 2018, 00:55 | #2 | ||
Registered User
Join Date: Dec 2017
Location: Austin, TX
Age: 41
Posts: 405
|
I think this covers what the directive is actually doing:
Quote:
Quote:
You're right that it doesn't clarify what happens when <expression> is omitted. It rather looks like the syntax should be rejected. |
||
27 December 2018, 11:03 | #3 | ||
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
Quote:
Anyway, thanks a lot for your help; I'm glad we've got this sorted out now. This had me bug hunting for a couple of hours yesterday.. |
||
27 December 2018, 19:26 | #4 | |||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,546
|
Quote:
Quote:
Quote:
For a better understanding of what RS was designed to to, take a look at the structure macros it replaces. Here are some examples from exec/types.i:- Code:
STRUCTURE MACRO ; structure name, initial offset \1 EQU 0 SOFFSET SET \2 ENDM ULONG MACRO ; unsigned long (32 bits) \1 EQU SOFFSET SOFFSET SET SOFFSET+4 ENDM APTR MACRO ; untyped pointer (32 bits - all bits valid) \1 EQU SOFFSET SOFFSET SET SOFFSET+4 ENDM STRUCT MACRO ; Define a sub-structure \1 EQU SOFFSET SOFFSET SET SOFFSET+\2 ENDM LABEL MACRO ; Define a label without bumping the offset \1 EQU SOFFSET ENDM RS is more efficient than macros because the assembler has less to do, but I don't use it because:- 1. My standard header files are preassembled so there's no efficiency improvement. 2. Structure macros put more type information into the source, so you can see at a glance whether eg. your 4 byte entry is supposed to be an unsigned long or an address pointer. 3. Structure macros are closer in style to C structures, making it easier to port code from C to assembler. |
|||
27 December 2018, 20:00 | #5 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
scrTxtMem_SizeOf rs.wat the end of my structures, but I usually have a lot more scrTxtMem_x rs.w 1in there, which still makes 0 the wrong default to pick, in my opinion/cases. Btw, another reason for having 0 instances could be to have multiple names for the same field. Maybe to help some kind of memory usage optimisation or something? Just thinking out loud, here.. Thanks for the example and reasoning, I'll look into that. |
|
28 December 2018, 20:11 | #6 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
It's always good when such a topic comes up here, because it makes me think about my decisions from the past again. In fact, there should be an error! At least in Devpac-compatibility mode. Leaving the expression away was a shortcut, which I introduced in the PhxAss assembler many decades ago. And with vasm 1.7c I probably decided to make vasm behave the same, because some of my own sources depend on it. But it never worked like this in any other assembler. Neither in Devpac, nor AsmOne, AsmPro, Barfly, SNMA, etc... So I guess I will make it a vasm feature, which is disabled with -devpac compatibility option. Too bad I just tagged the V1.8e release for tomorrow. Exactly! It was needed for every structure I defined, so I decided at some point that I would like to leave the '0' away. |
|
28 December 2018, 21:06 | #7 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
Btw, my source still compiles with -devpac compatibility (phew!), but it throws quite a few warnings about data auto-alignment -- which are probably suppressable, though.. Don't worry about this not getting into 1.8e release. We're lucky enough to have you consider these kinds of questions, about decisions made tens of years ago (!), and update vasm where appropriate. Not a lot of dev environments come with this kind of support, I think.. |
|
28 December 2018, 22:47 | #8 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Quote:
Code:
even dc.b 1 label: dc.w 2 Devpac has auto-alignment enabled. But unlike the real Devpac vasm warns about all those auto-alignments, so you can check and fix them. |
|||
29 December 2018, 20:43 | #9 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
So I guess I should probably have devpac compatibility turned on at all times? It feels a bit weird, though, because it says in the manual that 'Only directives known to Devpac are recognized', which feels like a step back with respect to the more modern developments of vasm. Or will I just be getting the best of both worlds in that case? |
|
29 December 2018, 21:47 | #10 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Quote:
Most (all?) Devpac features can be enabled in standard vasm mode with options or directives. Automatic data alignments just need the -align option. |
||
29 December 2018, 22:15 | #11 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
Alright, got it, thanks! |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
vasm/mot: structure | guy lateur | Coders. Asm / Hardware | 20 | 05 January 2020 00:01 |
vasm/mot: include failed error message | guy lateur | Coders. Asm / Hardware | 6 | 23 December 2018 20:29 |
some starglider 2 data structures | ara | Coders. General | 11 | 11 March 2011 19:56 |
Memory Data Structures | Zetr0 | support.Hardware | 7 | 30 September 2007 17:38 |
IFF/ILBM structures .... | freddix | Coders. General | 7 | 18 September 2006 09:54 |
|
|