Dwedit's Board

Enjoy the board

You are not logged in.

Announcement

User passwords may have been corrupted, if you can't log in, use the "Forgot Password" feature. If you still can't log in, contact me and I can try to manually reset your password.

#1 2009-04-02 2:38:35 pm

Dwedit
Administrator
From: Chicago
Registered: 2004-12-12
Posts: 1,022
Website

ARM SDT to GCC asm conversion tool

This is the ARM SDT to GCC asm conversion tool I used to port PocketNES and Goomba Color to GCC.
This tool does not do the whole job though.


Attachments:
Attachment Icon asmconv.zip, Size: 104,141 bytes, Downloads: 281

"We are merely sprites that dance at the beck and call of our button pressing overlord."

Offline

#2 2009-04-02 2:50:38 pm

Dwedit
Administrator
From: Chicago
Registered: 2004-12-12
Posts: 1,022
Website

Re: ARM SDT to GCC asm conversion tool

How to use it:
For example, I'll use PocketNES:

Make a "Project" file:  (I named it project3.txt)

6502.s
apack.s
boot.s
cart.s
cf.s
io.s
link.s
mem.s
memory.s
ppu.s
sound.s
visoly.s

mappers/konami.s
mappers/map023771.s
mappers/map1.s
mappers/map105.s
mappers/map1166.s
mappers/map15.s
mappers/map151.s
mappers/map16.s
mappers/map17.s
mappers/map18.s
mappers/map184.s
mappers/map19.s
mappers/map2125.s
mappers/map22.s
mappers/map228.s
mappers/map23.s
mappers/map232.s
mappers/map2426.s
mappers/map32.s
mappers/map33.s
mappers/map34.s
mappers/map4.s
mappers/map40.s
mappers/map42.s
mappers/map5.s
mappers/map64.s
mappers/map65.s
mappers/map67.s
mappers/map68.s
mappers/map69.s
mappers/map70152.s
mappers/map72.s
mappers/map73.s
mappers/map75.s
mappers/map76.s
mappers/map77.s
mappers/map78.s
mappers/map79.s
mappers/map80.s
mappers/map82.s
mappers/map85.s
mappers/map86.s
mappers/map87.s
mappers/map88.s
mappers/map9.s
mappers/map92.s
mappers/map93.s
mappers/map94.s
mappers/map97.s
mappers/map99.s

Make a batch file:  (I named it convert.bat)

cd directory_containing_your_code
..\asmconv.exe ..\project3.txt ..\output_directory
cd ..

Make sure output_directory and any necessary subdirectories exist already.  Maybe copy all the original versions of files there too, files that need modification get overwritten anyway.

More stuff:
The generated code may depend on macros, here's a portion of them you'll need:

	.macro adrl2 reg,label
	mov \reg,#\label&0x0FF00000
	add \reg,\reg,#\label&0x000FFFFF
	.endm

	.macro start_map base, register
	@GBLA _map_address_
 _map_address_ = \base
	.endm

	.macro _m_ label=0,size
	.if \label != 0
 \label = _map_address_
	.endif
 _map_address_ = _map_address_ + \size
	.endm

	.macro ldr_ reg,label
	ldr \reg,[globalptr,#\label]
	.endm
	
	.macro ldrb_ reg,label
	ldrb \reg,[globalptr,#\label]
	.endm
	
	.macro ldrh_ reg,label
	ldrh \reg,[globalptr,#\label]
	.endm
	
	.macro str_ reg,label
	str \reg,[globalptr,#\label]
	.endm
	
	.macro strb_ reg,label
	strb \reg,[globalptr,#\label]
	.endm
	
	.macro strh_ reg,label
	strh \reg,[globalptr,#\label]
	.endm



	.macro ldreq_ reg,label
	ldreq \reg,[globalptr,#\label]
	.endm
	
	.macro ldreqb_ reg,label
	ldreqb \reg,[globalptr,#\label]
	.endm
	
	.macro streq_ reg,label
	streq \reg,[globalptr,#\label]
	.endm
	
	.macro streqb_ reg,label
	streqb \reg,[globalptr,#\label]
	.endm
	



	.macro ldrne_ reg,label
	ldrne \reg,[globalptr,#\label]
	.endm
	
	.macro ldrneb_ reg,label
	ldrneb \reg,[globalptr,#\label]
	.endm
	
	.macro strne_ reg,label
	strne \reg,[globalptr,#\label]
	.endm
	
	.macro strneb_ reg,label
	strneb \reg,[globalptr,#\label]
	.endm
	


	.macro ldrhi_ reg,label
	ldrhi \reg,[globalptr,#\label]
	.endm
	
	.macro ldrhib_ reg,label
	ldrhib \reg,[globalptr,#\label]
	.endm
	
	.macro strhi_ reg,label
	strhi \reg,[globalptr,#\label]
	.endm
	
	.macro strhib_ reg,label
	strhib \reg,[globalptr,#\label]
	.endm


	.macro ldrmi_ reg,label
	ldrmi \reg,[globalptr,#\label]
	.endm
	
	.macro ldrmib_ reg,label
	ldrmib \reg,[globalptr,#\label]
	.endm
	
	.macro strmi_ reg,label
	strmi \reg,[globalptr,#\label]
	.endm
	
	.macro strmib_ reg,label
	strmib \reg,[globalptr,#\label]
	.endm

	.macro ldrpl_ reg,label
	ldrpl \reg,[globalptr,#\label]
	.endm
	
	.macro ldrplb_ reg,label
	ldrplb \reg,[globalptr,#\label]
	.endm
	
	.macro strpl_ reg,label
	strpl \reg,[globalptr,#\label]
	.endm
	
	.macro strplb_ reg,label
	strplb \reg,[globalptr,#\label]
	.endm


	.macro ldrgt_ reg,label
	ldrgt \reg,[globalptr,#\label]
	.endm
	
	.macro ldrgtb_ reg,label
	ldrgtb \reg,[globalptr,#\label]
	.endm
	
	.macro strgt_ reg,label
	strgt \reg,[globalptr,#\label]
	.endm
	
	.macro strgtb_ reg,label
	strgtb \reg,[globalptr,#\label]
	.endm


	.macro ldrge_ reg,label
	ldrge \reg,[globalptr,#\label]
	.endm
	
	.macro ldrgeb_ reg,label
	ldrgeb \reg,[globalptr,#\label]
	.endm
	
	.macro strge_ reg,label
	strge \reg,[globalptr,#\label]
	.endm
	
	.macro strgeb_ reg,label
	strgeb \reg,[globalptr,#\label]
	.endm


	.macro ldrlt_ reg,label
	ldrlt \reg,[globalptr,#\label]
	.endm
	
	.macro ldrltb_ reg,label
	ldrltb \reg,[globalptr,#\label]
	.endm
	
	.macro strlt_ reg,label
	strlt \reg,[globalptr,#\label]
	.endm
	
	.macro strltb_ reg,label
	strltb \reg,[globalptr,#\label]
	.endm


	.macro ldrle_ reg,label
	ldrle \reg,[globalptr,#\label]
	.endm
	
	.macro ldrleb_ reg,label
	ldrleb \reg,[globalptr,#\label]
	.endm
	
	.macro strle_ reg,label
	strle \reg,[globalptr,#\label]
	.endm
	
	.macro strleb_ reg,label
	strleb \reg,[globalptr,#\label]
	.endm


	.macro ldrlo_ reg,label
	ldrlo \reg,[globalptr,#\label]
	.endm
	
	.macro ldrlob_ reg,label
	ldrlob \reg,[globalptr,#\label]
	.endm
	
	.macro strlo_ reg,label
	strlo \reg,[globalptr,#\label]
	.endm
	
	.macro strlob_ reg,label
	strlob \reg,[globalptr,#\label]
	.endm
	

	.macro adr_ reg,label
	add \reg,globalptr,#\label
	.endm
	
	.macro adrl_ reg,label
@	.if \label&0x80000000
@	sub \reg,globalptr,#((-(\label)) & 0xFF00FF00)
@	sub \reg,\reg,#((-(\label)) & 0x000000FF)
@	.else
	add \reg,globalptr,#((\label) & 0xFF00FF00)
	add \reg,\reg,#((\label) & 0x000000FF)
@	.endif
	.endm

	.macro adrnel_ reg,label
@	.if \label&0x80000000
@	subne \reg,globalptr,#((-(\label)) & 0xFF00FF00)
@	subne \reg,\reg,#((-(\label)) & 0x000000FF)
@	.else
	addne \reg,globalptr,#((\label) & 0xFF00FF00)
	addne \reg,\reg,#((\label) & 0x000000FF)
@	.endif
	.endm

Afterwards, you may need to change some stuff:
* Replace .include with #include so that devkitarm's makefile works better
* Get rid of any excess MAPs, the tools only support one MAP.
* Change any incbins to be relative to the "Build" folder of a devkitpro project
* Some complex math expressions may not work on Gnu assembler, maybe equate them before you use them
* If you use register names, .unreq them at the end of a source file
* Because ADR can not cross source files, you may need to make a master asm file that #includes all other asm code
* AREA directives probably need to be rewritten:

example: change this
	AREA wram_code0, CODE, READWRITE
to this
 .align
 .pool
 .section .iwram, "ax", %progbits
 .subsection 0
 .align
 .pool

* Get rid of 2_ prefix for binary numbers, replace with 0b
* Maybe remove any unnecessary .includes if you move your project to the 'master source file that includes everything' model


"We are merely sprites that dance at the beck and call of our button pressing overlord."

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman