How to I assemble...

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

How to I assemble...

Post by Zettablade »

How do I assemble a raw .asm file into an eboot? What's would be a good makefile for my code?
Here's my code:
(add.s)

Code: Select all

## Program to add two plus three
	.text
	.globl main

main:
	ori	$8,$0,0x2	# put two's comp. two into register 8
	ori	$9,$0,0x3	# put two's comp. three into register 9
	addu	$10,$8,$9	# add register 8 and 9, put result in 10

## End of file
BTW: I don't wanna use any c in this. I want it to be complete asm.
Last edited by Zettablade on Fri Oct 20, 2006 7:23 am, edited 1 time in total.
User avatar
0okm0000
Posts: 116
Joined: Fri Jan 13, 2006 9:51 am
Contact:

Post by 0okm0000 »

PS2DEV: PS2 Programming - Minifire (Small ASM demo)
http://ps2dev.org/psp/Demos/Minifire_(Small_ASM_demo)
Last edited by 0okm0000 on Sun Oct 22, 2006 2:39 pm, edited 3 times in total.
PSP hardware hack
http://0okm.blogspot.com/
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Yah minifire does go the whole hog, no C what so ever, if you use main at all then you are including C in the crt0 (which is the entry point) and newlib, not that that perhaps worries you :) If you are just interested in your code being asm then just put your code into a main.s file, then in the standard Makefile add main.o as an object and the build system worries about doing the rest.

Of course you _may_ want to add a jr $ra; nop; to that bit of asm else it is, not will crash in an unexpected way depending what code is after that bit of asm :P
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

TyRaNiD wrote:Yah minifire does go the whole hog, no C what so ever, if you use main at all then you are including C in the crt0 (which is the entry point) and newlib, not that that perhaps worries you :) If you are just interested in your code being asm then just put your code into a main.s file, then in the standard Makefile add main.o as an object and the build system worries about doing the rest.

Of course you _may_ want to add a jr $ra; nop; to that bit of asm else it is, not will crash in an unexpected way depending what code is after that bit of asm :P
Well, I'm still learning asm, but thx anyways. I can't checkout mini fighter now, but I'll be sure to check it out once I get home.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

I said Tyranid will know how it works :) Well, thanks for the info, always good to learn something new
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Tinnus
Posts: 67
Joined: Sat Jul 29, 2006 1:12 am

Post by Tinnus »

BTW, I don't think 0x89 is 3...
Let's see what the PSP reserves... well, I'd say anything is better than Palm OS.
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

Tinnus wrote:BTW, I don't think 0x89 is 3...
lol that was a typo of sorts....
jsharrad
Posts: 100
Joined: Thu Oct 20, 2005 3:06 am

Post by jsharrad »

TyRaNiD wrote:Yah minifire does go the whole hog, no C what so ever, if you use main at all then you are including C in the crt0 (which is the entry point) and newlib, not that that perhaps worries you :) If you are just interested in your code being asm then just put your code into a main.s file, then in the standard Makefile add main.o as an object and the build system worries about doing the rest.

Of course you _may_ want to add a jr $ra; nop; to that bit of asm else it is, not will crash in an unexpected way depending what code is after that bit of asm :P
I know I'm grave-digging a REALLY old post here, but Tyranid, is what you have in the minifire archive what your compiler actually gave you after compiling that source or did you edit the ELF files to compact them?

When I compile that source, I get this:

Code: Select all

  Start of program headers&#58;          52 &#40;bytes into file&#41;
  Start of section headers&#58;          4940 &#40;bytes into file&#41;
  Flags&#58;                             0x10a23001, noreorder, unknown CPU, eabi32, mips2
  Size of this header&#58;               52 &#40;bytes&#41;
  Size of program headers&#58;           32 &#40;bytes&#41;
  Number of program headers&#58;         1
  Size of section headers&#58;           40 &#40;bytes&#41;
  Number of section headers&#58;         8
  Section header string table index&#58; 7
Notice the offset of the section headers, almost 5k in the file (the majority of the file is filled with 00's before it actually gets to the program data)

Whereas yours is:

Code: Select all

  Start of program headers&#58;          60 &#40;bytes into file&#41;
  Start of section headers&#58;          52 &#40;bytes into file&#41;
  Flags&#58;                             0x10a23001, noreorder, unknown CPU, eabi32, mips2
  Size of this header&#58;               52 &#40;bytes&#41;
  Size of program headers&#58;           32 &#40;bytes&#41;
  Number of program headers&#58;         1
  Size of section headers&#58;           40 &#40;bytes&#41;
  Number of section headers&#58;         3
  Section header string table index&#58; 2

With a total filesize of 671 bytes.

Is there something I'm missing to compile it like this? or did you edit the file contents and offsets manually? :)
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

I wrote a quick and dirty repacker which removed the segment alignment stuff down to something more sensible :P
jsharrad
Posts: 100
Joined: Thu Oct 20, 2005 3:06 am

Post by jsharrad »

TyRaNiD wrote:I wrote a quick and dirty repacker which removed the segment alignment stuff down to something more sensible :P
That's what I thought ;)

Neat trick with the embedding one table inside another, would have never thought to do that myself. Gave me the idea of doing the same with some of the .data segment with the repacker I wrote. Managed to get the filesize down to 644 bytes and still have a working binary on the PSP :)
Post Reply