forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to I assemble...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Zettablade



Joined: 05 May 2006
Posts: 71

PostPosted: Wed Oct 18, 2006 10:33 pm    Post subject: How to I assemble... Reply with quote

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:
## 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
Back to top
View user's profile Send private message
0okm0000



Joined: 13 Jan 2006
Posts: 116

PostPosted: Wed Oct 18, 2006 11:09 pm    Post subject: Reply with quote

PS2DEV: PS2 Programming - Minifire (Small ASM demo)
http://ps2dev.org/psp/Demos/Minifire_(Small_ASM_demo)
_________________
PSP hardware hack
http://0okm.blogspot.com/


Last edited by 0okm0000 on Sun Oct 22, 2006 2:39 pm; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Oct 19, 2006 3:35 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Zettablade



Joined: 05 May 2006
Posts: 71

PostPosted: Thu Oct 19, 2006 4:16 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Thu Oct 19, 2006 10:34 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Tinnus



Joined: 29 Jul 2006
Posts: 67

PostPosted: Thu Oct 19, 2006 11:38 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Zettablade



Joined: 05 May 2006
Posts: 71

PostPosted: Fri Oct 20, 2006 11:59 am    Post subject: Reply with quote

Tinnus wrote:
BTW, I don't think 0x89 is 3...

lol that was a typo of sorts....
Back to top
View user's profile Send private message
jsharrad



Joined: 20 Oct 2005
Posts: 102

PostPosted: Wed Mar 26, 2008 2:40 pm    Post subject: Reply with quote

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:
  Start of program headers:          52 (bytes into file)
  Start of section headers:          4940 (bytes into file)
  Flags:                             0x10a23001, noreorder, unknown CPU, eabi32, mips2
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         1
  Size of section headers:           40 (bytes)
  Number of section headers:         8
  Section header string table index: 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:
  Start of program headers:          60 (bytes into file)
  Start of section headers:          52 (bytes into file)
  Flags:                             0x10a23001, noreorder, unknown CPU, eabi32, mips2
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         1
  Size of section headers:           40 (bytes)
  Number of section headers:         3
  Section header string table index: 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? :)
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Wed Mar 26, 2008 4:35 pm    Post subject: Reply with quote

I wrote a quick and dirty repacker which removed the segment alignment stuff down to something more sensible :P
Back to top
View user's profile Send private message
jsharrad



Joined: 20 Oct 2005
Posts: 102

PostPosted: Thu Mar 27, 2008 7:38 pm    Post subject: Reply with quote

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 :)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group