English Amiga Board


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

 
 
Thread Tools
Old 15 January 2015, 13:38   #1
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 744
Devpac - CNOP in a BSS Section

Trying to assemble the PT315 source in Devpac but the BSS Sections have CNOP 0,4 for aligning the file info blocks. It fails saying..

BSS or OFFSET section cannot contain data

I can't seem to find the correct directive to get it to assemble?

Any ideas?
h0ffman is online now  
Old 15 January 2015, 15:20   #2
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Just use EVEN instead cant you?
Galahad/FLT is offline  
Old 15 January 2015, 16:13   #3
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Galahad/FLT View Post
Just use EVEN instead cant you?
EVEN is not the same as CNOP 0,4!


Quote:
I can't seem to find the correct directive to get it to assemble?
Easiest "fix": Change the BSS to DATA sections and the CNOP should work.
StingRay is offline  
Old 15 January 2015, 16:44   #4
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by h0ffman View Post
Trying to assemble the PT315 source in Devpac but the BSS Sections have CNOP 0,4 for aligning the file info blocks. It fails saying..

BSS or OFFSET section cannot contain data

I can't seem to find the correct directive to get it to assemble?

Any ideas?
You could try vasm with or without -devpac mode. Vasm is mostly compatible with Devpac either way. I believe Frank recently changed vasm from always generating '0' with CNOP to generating NOP with CNOP in code sections. I don't know if this applies to -devpac mode though.

A fairly new version of vasm can be found in vbcc 0.9d.

http://sun.hasenbraten.de/vbcc/

Not only does vasm optimize better than devpac (vasm optimizes branches in both directions for example), but it should be faster. Leffmann timed vasm as being faster than devpac but still 20x slower than PhxAss. My recent tests on the 68060 showed 13x-18x slower than PhxAss so there may be some improvement due to vbcc compiler improvements (Leffmann's tests were done on a 68030 though). I tried a 68060 specific build of vasm with direct FPU use and didn't see any difference in speed. The IEEE fp library using version of vasm in the new vbcc is not so slow for a compiled assembler.
matthey is offline  
Old 15 January 2015, 19:54   #5
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
You can use something similar, it works for ASM-One:

Code:
 Section Test, BSS

StartBSS
 ds.b 1
 ds.b 2
 ds.b 3
FixBSS
 ds.b (FixBSS-StartBSS+3)/4
AlignedLabel
 ds.b 1000
Don_Adan is offline  
Old 15 January 2015, 20:28   #6
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
This will work too:

Code:
PAD4		MACRO
.\@size		= *-\1
.\@size2	= ((.\@size+4)/4)*4
		ds.b	.\@size2-.\@size
		ENDM

data	ds.b	3

	PAD4	data

aligned_data
(quickly adapted my macro to align data to a 512 byte boundary)
StingRay is offline  
Old 15 January 2015, 21:51   #7
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
I am surprised that there is no easy way to align data in a bss section with DevPac. I didn't realize that before.

StingRays solution works with most assemblers.

Another solution would be to start a new section for data objects which need 32-bit or 64-bit alignment. LoadSeg() allocates a new memory block for every section, so 64-bit alignment is guaranteed.
Code:
        section fileinfoblock,bss
myfib:
phx is offline  
Old 15 January 2015, 22:13   #8
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by phx View Post
I am surprised that there is no easy way to align data in a bss section with DevPac. I didn't realize that before.

StingRays solution works with most assemblers.

Another solution would be to start a new section for data objects which need 32-bit or 64-bit alignment. LoadSeg() allocates a new memory block for every section, so 64-bit alignment is guaranteed.
Code:
        section fileinfoblock,bss
myfib:
Would it be possible to make vasm align offsets in a BSS section using CNOP? Obviously it would not be possible to insert any data but maybe it could do the offset calculation? It might be a nice feature if it's possible.
matthey is offline  
Old 15 January 2015, 22:23   #9
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by matthey View Post
Would it be possible to make vasm align offsets in a BSS section using CNOP?
Did you try it? It always worked, as CNOP pads with zeros in non-code sections.
And as far I can see most assembler behave the same. Except Devpac.
phx is offline  
Old 16 January 2015, 01:01   #10
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by StingRay View Post
EVEN is not the same as CNOP 0,4!




Easiest "fix": Change the BSS to DATA sections and the CNOP should work.
Hmmm, i'm sure I read somewhere in a Hisoft document that if you use an EVEN statement in Devpac as the first line of a data/BSS/whatever section it performs the same.

I've never had to use it, so i've never had to check it.

You however could check your Facebook messages, that would be a good start
Galahad/FLT is offline  
Old 16 January 2015, 01:44   #11
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by phx View Post
Did you try it? It always worked, as CNOP pads with zeros in non-code sections.
And as far I can see most assembler behave the same. Except Devpac.
I tested vasm in normal and devpac mode and CNOP aligned how I would expect. That means that vasm in devpac mode is not compatible with Devpac but perhaps we could ignore? I didn't find anything in the Devpac 3.0 manual about how to change the CNOP padding data (nothing about what data padding is used either). It would be possible to have an optional 3rd argument with the padding data although I don't know if it would be worth the trouble. I wonder if any other assemblers accept a 3rd argument for CNOP? Vasm does seem to be an option for h0ffman because of the lack of Devpac compatibility at least .
matthey is offline  
Old 16 January 2015, 07:13   #12
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Galahad/FLT View Post
Hmmm, i'm sure I read somewhere in a Hisoft document that if you use an EVEN statement in Devpac as the first line of a data/BSS/whatever section it performs the same.
I pretty much doubt that as EVEN = CNOP 0,2!
StingRay is offline  
Old 16 January 2015, 10:49   #13
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by matthey View Post
CNOP aligned how I would expect. That means that vasm in devpac mode is not compatible with Devpac but perhaps we could ignore?
Yes, I think so. It makes no sense to support that.
While developing vasm I always saw Devpac as the reference assembler. But now I'm a bit disappointed.

Quote:
I wonder if any other assemblers accept a 3rd argument for CNOP?
No. Some assemblers have CNUL (e.g. snma), which pads with zeros, while CNOP pads with NOP instructions when possible.


Besides CNOP it also makes sense to pad code hunks with NOP, when their length is not a multiple of four. Unfortunately Amiga assemblers show a very different behaviour:
Code:
Assembler   | CNOP NOP padding | code hunk NOP padding
------------------------------------------------------
A68k        | yes              | yes
AsmOne      | no               | no
Barfly      | no               | yes
Devpac      | no               | no
PhxAss      | yes              | yes
vasm        | yes (since 1.7c) | yes (since 1.7c)
Strange that Devpac doesn't pad CNOP 0,4 with NOP, although it has problems with it in a BSS section. Make no sense at all...
phx is offline  
Old 16 January 2015, 12:01   #14
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by StingRay View Post
I pretty much doubt that as EVEN = CNOP 0,2!
Probably wasnt an official Hisoft document then.

CAN YOU RESPOND TO YOUR MESSAGES ON FACEBOOK THAT YOUVR READ AND NOT RESPONDED TO.....CAN YOU DO THAT MATE? THIS YEAR IS PREFERABLE, THIS WEEK WOULD BE BETTER......T O D A Y WOULD BE POLITE.


CAN YOU DO THAT MATE??????????????????????????????????????????????????
Galahad/FLT is offline  
Old 16 January 2015, 12:06   #15
IFW
Moderator
 
IFW's Avatar
 
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
It's been a very long time since I did this, but... the original system uses BCPL pointers and convert between them by shifting left and right by 2 when accessing sections.
Therefore, each section is guaranteed to start at an address that is an integral multiple of 4.
IFW is offline  
Old 16 January 2015, 12:11   #16
IFW
Moderator
 
IFW's Avatar
 
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
Also I am positive we used alignment in our games, which were all compiled using DevPac, but would have to dig up the sources to find out what the syntax exactly was. I might try if anything else fails...
IFW is offline  
Old 16 January 2015, 13:36   #17
IFW
Moderator
 
IFW's Avatar
 
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
As far as I can see from some random source is that I used a section where 4 byte alignment was needed, the first data there is certainly starting at a 4 byte alignment. Then ds.b could be added with modulo 4 of the difference between known reference points to make sure that the next label starts at an integral multiple of 4.
Since the expression evaluator is particularly dumb by today's standards, you have to write something like this:

section bss
start ds.b 0
junk ds.b <your data>
pad ds.b ((pad-start+3)/4*4)-(pad-start)
align4 ds.b <your 4 byte aligned data>


You can probably make this a macro with a local label in place of "pad" to make the code actually readable
IFW is offline  
Old 16 January 2015, 13:42   #18
IFW
Moderator
 
IFW's Avatar
 
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
And CNOP works just as well in 3.18

section bss
junk ds.b <your data>
align cnop 0,4


data at the label "align" is 4 byte aligned.
IFW is offline  
Old 16 January 2015, 17:41   #19
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
would a section not always start on an 8-byte boundary? or do some linkers combine sections, so this could be voided?
hooverphonique is offline  
Old 17 January 2015, 14:24   #20
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by IFW View Post
And CNOP works just as well in 3.18

section bss
junk ds.b <your data>
align cnop 0,4
No. It doesn't. "section bss" is a code section, named "bss". Watch the $3e9 hunk type in your output. "section name,bss" or just "bss" would be a real bss section. Omitting the section type lets it default to code.

Quote:
Originally Posted by hooverphonique View Post
would a section not always start on an 8-byte boundary? or do some linkers combine sections, so this could be voided?
Correct. The first data in a section is always guaranteed to start on a 8-byte boundary. When a linker combines sections, the following data is still guaranteed to start on a 4-byte boundary, as a hunk size is always a multiple of 4.
phx 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
cnop phx Coders. Asm / Hardware 13 19 February 2015 21:33
newest ami/x and cnet bss GreenMeanie request.Apps 1 16 September 2011 20:12
Off-topic section BippyM project.EAB 3 29 January 2007 17:08
Section 8 ??? plasmatron Nostalgia & memories 4 04 June 2004 20:40
Federation of the Free Traders + BSS Jane Seymour haynor666 MarketPlace 0 06 June 2003 15:19

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 18:09.

Top

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