PDA

View Full Version : SH4 Assembly



mrclean
July 31st, 2005, 04:44
Hi,

I remember a while back Mekanaizer was working on a SH4 assembly tutorial. Did he ever finish it? If not, could anyone direct me to a good resource for learning SH4 assembly? I can't find any books on the subject in the bookstore or library. Thank you

flaming_carrot
July 31st, 2005, 08:51
You should read the SH4 programming manual. I couldn't find a copy on Hitachi's homepage anymore, but here's a cached copy:

http://mc.pp.se/dc/files/h14tp003d2.pdf

quzar
July 31st, 2005, 11:38
The best way to learn is to write some simple piece of code in C that highlights the majority of things you would do, then just pass it though gcc to get the asm equivilant and study it.

bender
August 1st, 2005, 05:17
EDITED


I disagree, it wouldn't be a good asm code. The idea of using asm should be to learn how to be better than the compiler so what you really need to know it's a lot of the hardware you are using so you can write optimized code. I think the good way could be to familiarize with very simple examples and easy architectures to learn, like the PICs 16FXXX, M+ (plus machine), M++, just to get a basic idea, then try to move to the architecture of your interest or a similar one

A very simple example in x86 asm (linux) to show the differences between an asm code and the asm you get from the C compiler it could be this:

C code


/* hello.c */
#include

main()
{
printf("hello\n")
}


asm code,i think this is the good one but my x86 asm level sucks so...




section .text
global _start
msg db 'Hello, world!', 0Ah
len equ $ - msg
_start:
mov edx,len
mov ecx,msg
mov ebx,1
mov eax,4
int 80h
mov eax,1
int 80h


asm code, reverted using gdb
Edit: I realized the gdb code i pasted was wrong. Anyway here's the good one (with a tutorial explaining how to use gdb, so nice site to visit :-D ): http://lab46.corning-cc.edu/Documentation-Assembly_GDB_Debugger.php



As you can see even in something so simple like this you'll find differences: no something important for this but imagine the so much differences you'll find in big programs ;-)

mrclean
August 1st, 2005, 21:16
Thanks guys, very useful advice. I guess I'll start learning, I have the rest of the summer

quzar
August 1st, 2005, 23:16
bender: i meant mostly for syntax and a general grasp of what opcodes do what. For the second thing, you would want to read the hitachi programmers manual that was already linked. It describes the features of the processor, cache, and how the pipelining system works with the different opcode sets.

bender
August 3rd, 2005, 07:15
oh, sorry. I wish my english was better so i can understand always ok. Anyway, i've seen speaking you in spanish at dciberia and it's ... , just kidding :p
your spanish it's pretty nice and it surprised me a lot, better than my english, man ;-)

quzar
August 3rd, 2005, 10:36
pude hablarlo mejor antes, pero pase un año sin hablar o escribirlo. tambien no sepo como añadir los accentos (`).

your english is very good, I did not notice you were not a native speaker, I simply wasn't clear in what I meant.

bender
August 3rd, 2005, 11:33
hehe, your spanish it's pretty nice.
For accents first push the accent key, then a vocal and you will have your accented vocal ;-) á é í ó ú

@mrclean, back on topic, you probably know about the guys who started reversing the DC. Dan Potter, AndrewK (have a look at burritro's perhaps) and Marcus Comstedt probably have some useful info about sh asm in their respective sites. There's also fame, the main cpu core of superfamicast/dreamspec, bor and now Holly3D for some sh asm code ;-)