68k assemblers...

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

68k assemblers...

Post by tomaitheous » Sun Nov 21, 2010 1:29 am

Snasm68k isn't doing what I need it to do. So, I'm looking for some other suggestions for an 68k assembler.

Here is the specifics that I'm looking for. I need to redefine code/data over existing address defines. Snasm68k does some really funky stuff, and besides the warnings which I didn't care about initially, it basically won't work for what I need.

Any ideas?

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Nov 21, 2010 1:50 am

Well, your three major choices are

ASL: http://john.ccac.rwth-aachen.de:8000/as/
ASMX: http://xi6.com/projects/asmx/
AS: part of binutils with gcc

Note that asmx has some bugs in it (reported in the BEX thread over at devster). Also note that gas uses it's own format for things like labels and directives. I suggest reading the docs: http://sourceware.org/binutils/docs/as/index.html

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Sun Nov 21, 2010 4:45 pm

Link to ASL seems to be down.

Does AS from GCC support what I need though? I see what snasm68k is doing. It's taking the overlapping address conflicting data/code, and just sticking it at the top of the binary (starting at $00000000) and shifting down everything else. Completely useless.

Seems I have a problem in my setup for mingw. I can't install asmx because I'm missing libgmp-10.dll.

I have a pre-release version of Sekas. It's a port a Xkas for 68k. But I'm reluctant to use it since it's not fully tested and I haven't gotten permission to distribute it (which is pretty important for this project).

Edit: Ok, I got ASMX compiled (I really hate how mingw is maintained). Had to modify the header file too.

What were the bugs in ASMX? I couldn't get the forum to load (from the site you mentioned). If ASMX doesn't get the job done, I'm just gonna modify my existing compiler app for 68k instructions and be done with it. Man...

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sun Nov 21, 2010 7:07 pm

The link for asl works fine for me. :?

With gcc, you may need to make a special linker map that defines a segment for each unique address, then in the code specify that segment instead of .text or .data.

Another thing you can try is similar to how I put stuff on particular addresses in the Neo Myth menu. Look at the end of the first asm file...

Code: Select all

| pad space out for BC menu

        .text

        .org    0x00B000

| EOT marker for empty menu list

        .byte   0xFF

        .org    0x00FFF0

| card type of NeoFlash card

        .word   0x0000                  /* 0x0000 = type C(7), 0x0101 = type B(5), 0x0202 = type A(5) */

| pad space out to extended code space

        .org    0x030000

And I have no idea what the bugs were in asmx... you might want to hop over to devster and ask about that. Maybe have him post the changes he made.

http://devster.proboards22.com/

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Sun Nov 21, 2010 8:31 pm

Heh. I guess I don't need to worry about the bugs in ASMX. It almost works, but clips part of the main/initial incbin. The DNS server for my ISP connection can't resolve the IP for ASL, but I got the IP directly (thanks MooZ). I'll try this out.

Edit: I think ASL will do the job. Took me a bit to get the P file from the assembler to output in the correct size (poor wording for the documentation for P2BIN and the lame default size window set even though I'm using 68k type cpu).

Edit2: Also, learned my lesson today. Even though you have a user/pass on your router, make sure it isn't the 'default' one. Some malware app hacked it and changed the DNS settings (on the router, not the LAN card settings - hah!). Now I can actually visit ASL site normally :)

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Mon Nov 22, 2010 6:02 am

:D

Which is why I changed my router first thing. Leaving the default is a good way to get hacked, but most people never think to change it.

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Mon Dec 20, 2010 1:48 pm

still looking for a new assembler. I'm evaluating ASL but i'm stuck with a problem. ASL support "segment" directive. But with predefined name there's code,data,...

but in 68k mode, i can only use "code" segment. I'd like to have some kind of ram section.. a bit like this :

Code: Select all

		.cpu 68000
		segment RAM
		org $ff0000
foo	ds.b    10
tutu	ds.w    10
		segment code
                            org $0
		move.b	#$1,toto
anyone know how to achieve this in asl ?

In snasm68k, i use "Section" , but in ASL , symbols are only available in the section in which they are declare. which is not what i want.

thanks in advance

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Mon Dec 20, 2010 4:38 pm

I never used 'section' in snasm68k before. At least, I don't remember using it ;>_>

This is the only thing I've done with ASL so far: http://pastebin.com/7vRGQ7Nm (my ram variable defines are at the end of the file).

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Tue Dec 21, 2010 8:06 am

tomaitheous wrote:I never used 'section' in snasm68k before. At least, I don't remember using it ;>_>

This is the only thing I've done with ASL so far: http://pastebin.com/7vRGQ7Nm (my ram variable defines are at the end of the file).
thanks for your reply :) org , is not a good alternative to me as i'd like to define variables in any files of my code. Snasm68k was the perfect option for that , but not working on 64bits :<

I wonder how Nemesis was able to hack it for long path name. Does he got the sources ?

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Tue Dec 21, 2010 8:07 pm

is not a good alternative to me as i'd like to define variables in any files of my code.
Yeah, I like that feature as well. I use that in PCEAS with .BSS (user define .RS works too). Is that what SECTION was for in snasm68k? I.e. each 'section' had it's own internal counter for address assigning? ASL has to have something similar...

Edit: I think it's possible to redefined a symbols value. If so, that would be one way to simulate an RS counter (which SECTION already does, but section is private in ASL. Not sure of PUBLIC or GLOBAL can override this for the use of variable defines).

Edit: Also, the document says all DATA is a valid argument for all processors, yet it doesn't assemble in 68k mode for some reason.

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Tue Dec 21, 2010 9:38 pm

Yeah, seems to be a bug that DATA argument of SECTION can't be used with it, under 68k (it specifically says it's for defining variables in different includes files and such).

One work around is to use the SET directive. It's just like EQU, except you can redefine the value.

Like:
test1 set $ff0000

test1 set test1+4

I haven't tested it yet, but as long as other files can read the label from the main file, this should work fine. You should be able to automate the process by using a local label in the variable define section of separate files. Local_end-local_start to add to the BSS (or whatever you name it) label.

Edit: Ok I tested it out in my source.


At the beginning of the main asm file, declare BSS and PC, like so:

Code: Select all

	CPU     68000
	SUPMODE ON
BSS set $ff0000
PC	set $0
I put my main variable defines at the end of the file, but it doesn't matter (but you don't, you'll have to save/restore the current address pointer).

In my gamepad.asm, I define my variables as such:

Code: Select all

	rts     ;<- the end of the CODE section of this include.

.end

PC set .end

	.org BSS

;//	internal

P1CTRL:	ds.w	1
P2CTRL:	ds.w	1

 ; and more variables here, etc.

.end_bss
BSS set .end_bss
	.org PC
RTS was the last part of the 'code' part of my include. So, I saved the address counter into PC. Redefined ORG with the current BSS address, defined some variables, capture the end of the current address with .end_bss and set BSS to this. Voila. It replicates using SEGMENT DATA.

You could probably make a nice macro for this. Make it look clean just like SEGMENT ;)

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Wed Dec 22, 2010 11:30 am

thanks !!! i was so blind folded by looking for the right feature proposed by the assembler that i forgot that i can surely do a "hack".

So simple :)

Apprently named segment with counter is in the ASL todo list
"Named segments, i.e. multiple program counters and instructions to switch among them. Currently, there is only one program counter per physical segment, and one has to use macro contructs to get virtual PC's"

thanks again :-)

Post Reply