If you appreciate the work done within the wiki, please consider supporting The Cutting Room Floor on Patreon. Thanks for all your support!

User:Athena/SuperH

From The Cutting Room Floor
Jump to navigation Jump to search

This is a sub-page of User:Athena.

This page contains notes about the SuperH on the Sega Saturn(SH-2) and Dreamcast(SH-4). You may edit this!

Cacti may speak Japanese, but do they speak it well?
...But does it make sense?
The translations on this page need to be proofread. If you are fluent enough in this language, please make any corrections necessary!
This cactus is UNDER CONSTRUCTION
This article is a work in progress.
...Well, all the articles here are, in a way. But this one moreso, and the article may contain incomplete information and editor's notes.

Disassemble

Sega Satrun

Disassemble ram.bin(high RAM) to disasm.txt.

cat <(strings -td ram.bin | perl -nle '$_=~/\s*([0-9]+)\s*(.+)$/; printf " %x: %s\n",0x06000000+int($1),$2') <(sh4-linux-gnu-objdump -D -b binary -EB -m sh4 --adjust-vma=0x06000000 ram.bin) | sort -b | uniq > disasm.txt

Dreamcast

Disassemble 1ST_READ.BIN to disasm.txt.

cat <(strings -td 1ST_READ.BIN | perl -nle '$_=~/\s*([0-9]+)\s*(.+)$/; printf " %x: %s\n",0x0C010000+int($1),$2') <(sh4-linux-gnu-objdump -D -b binary -EL -m sh4 --adjust-vma=0x0C010000 1ST_READ.BIN) | sort -b | uniq > disasm.txt

Instructions

nop

00 09

Jump Instructions

jmp, jsr

Used for absolute jumping.

Jump range:

PC = register;
Instruction Note
jmp delay slot.
jsr Jump to sub routine. delay slot.

bf, bf/s, bt, bt/s, bra, bsr, bsrf

Used for relative jumping.

Jump range:

PC = PC + (disp * 2); // disp = -128 ~ 127
Instruction Note
bf Branch on False, if( T==0 ) jump;
bf/s Branch on False with delay slot, if( T==0 ) jump;
bt Branch on True, if( T==1 ) jump;
bt/s Branch on True with delay slot, if( T==1 ) jump;
bra delay slot.
bsr Branch to sub routine. delay slot.

braf, bsrf=

Used for relative jumping.

Jump range:

PC = PC + register;
Instruction Note
bra delay slot.
bsr Branch to sub routine. delay slot.

mul.l, muls.w, mulu.w

Used for 32-bit or 16-bit multiplication. Stores result in MACL register.

MACL = register * register
Instruction Note
mul.l multiplies two registers and stores lower 32 bits of result to MACL.
muls.w multiplies two 16-bit signed registers and stores result to MACL.
mulu.w multiplies two 16-bit unsigned registers and stores result to MACL.

dmuls.l, dmulu.l

Used for 64-bit multiplication. Stores result in MAC register. The lower 32-bits are in MACL, and the higher 32-bits are in MACH.

MAC = register * register
Name Notes
dmuls.l multiplies two signed registers and stores 64-bit result in MAC.
dmulu.l multiplies two unsigned registers and stores 64-bit result in MAC.

Registers

Name Notes
R0 index register
R1~R14
R15 (sp) hardware stack pointer
SR Status register
PR Procedure register. like a MIPS's ra
GBR Global base register. to use for array/structure access.
MAC Two registers, consisting of MACH and MACL. for operations that include multiplying.