Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
20 May, 2013, 19:59:16 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: SH3 op of the day -  (Read 1513 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
z80man
Casio Traitor
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 04 September, 2012, 19:42:33
Date Registered: 26 December, 2010, 10:02:50
Location: City 17
Posts: 966


Topic starter
Total Post Ratings: +83

View Profile
« on: 10 March, 2011, 07:51:35 »
+3

You have probably now seen the new Casio Prizm calc. You might also happen to know that it is powered by a SuperH 3 processor. If so, you might want to start coding for it. The purpose of this lengthy tutorial will be to teach you how to write SH3 asm code day by day. I will not be teaching how to do Prizm specific coding, just SH3 coding. I have also designed these tutorials to show parallel between the SH3 and the z80. It is highly recommended that you previously know a machine compiled language such as z80, arm, C, C++, x86, or axe. Other languages such as Java, python, and BASIC can also be used as prior experience, but you may find coding in SH3 more difficult. I also reccomend to everyone, if you have not done already, is to read Qwerty's previous tutorial on SH3 asm here http://www.omnimaga.org/index.php?topic=6389.0. Once I finish this tutorial I will place all of the lessons into a pdf file. I will here document every single instruction on the SH3 and there will be a lesson every day. I may skip a day or week at a time, but I will make up for the days I missed.
__Day One__
__MOV #imm,Rn  0xEnii__
1 cycle, no privilege required, T bit unchanged


I'm going to start this tutorial off with what one of the simplest instructions available. For a z80 coder, it is the equivalent of the ld a,$xx. Because the SH3 is a RISC processor, it only supports 16 bit fixed-length instructions. Therefore only byte values can be stored as immediate data. The hex for this instruction is 0xEnii. Where n is the register (0-15) and ii is a byte of immediate data to be stored in register n. An important note with this instruction is that a sign extension is preformed on the entire 32 bit register even though the data is only a byte. Basically a sign extension is formating the register that way the register is read the same when it is referred to as a long word. The easiest example are positive numbers. Say you want to load $04 into R15. Because $04 is a positive number, 0's will be placed in front of it in the register to reflect this as $00000004. So if you read R15 as a long word later you will see the value of $4 in there. Negative operations are really just the opposite. Say you now want to load $FE aka -2 into R15. Because $FE is a negative value the register is reflected as such. The result would be $FFFFFFFE in R15. Now if you read R15 as a long word you will get the value of -2. Now lets say the cpu did not do a sign extension for the last instruction. Then R15 would read $000000FE. Now if you try to read this, you will get a value of 254 not -2 which you wanted. That now completes lesson one. I hope you are now onto your way into learning SH3 asm. Tomorrow's lesson will teach you how to load data from memory using a displacement value.








« Last Edit: 11 March, 2011, 08:57:14 by z80man » Logged


List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 17:49:32
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50205


Total Post Ratings: +2611

View Profile WWW
« Reply #1 on: 10 March, 2011, 08:34:22 »
0

Sounds promising. A tutorial for SH3 ASM like ASM in 28 days or Hot Dog's tutorials (the later is more suitable for a greater range of people) would be more than welcome to increase Prizm programming popularity.

Personally I think it should be made suitable for visual people as much as possible, otherwise you're gonna single out a large group of people (like ASM in 28 days did). Calc screenshots of what each relevant example program does (even if camera captures) are more than welcome.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
z80man
Casio Traitor
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 04 September, 2012, 19:42:33
Date Registered: 26 December, 2010, 10:02:50
Location: City 17
Posts: 966


Topic starter
Total Post Ratings: +83

View Profile
« Reply #2 on: 10 March, 2011, 08:40:22 »
0

Sounds promising. A tutorial for SH3 ASM like ASM in 28 days or Hot Dog's tutorials (the later is more suitable for a greater range of people) would be more than welcome to increase Prizm programming popularity.

Personally I think it should be made suitable for visual people as much as possible, otherwise you're gonna single out a large group of people (like ASM in 28 days did). Calc screenshots of what each relevant example program does (even if camera captures) are more than welcome.
I'm going to edit each of the lessons later to include more details including pictures, charts, and screenshots. I am thinking that this might take a bit more than 28 days. I could divide this tutorial in sections with the first one being shorter and for beginners while an advanced one will teach the rest of the instruction in a much longer time period as I want to eventually teach every single instruction available. Even if most coders will never use half of them.
« Last Edit: 10 March, 2011, 08:40:51 by z80man » Logged


List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)
graphmastur
King Graphmastur
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 02 February, 2013, 08:34:45
Date Registered: 03 June, 2010, 21:15:55
Posts: 2262


Total Post Ratings: +60

View Profile
« Reply #3 on: 10 March, 2011, 14:39:40 »
0

This looks interesting.  But what if you wanted to load a word into memory?
Logged

JosJuice
LV9 Veteran (Next: 1337)
*********
Online Online

Last Login: Today at 19:39:32
Date Registered: 24 September, 2010, 16:46:12
Location: Sweden
Posts: 1300


Total Post Ratings: +51

View Profile
« Reply #4 on: 10 March, 2011, 17:21:12 »
0

This looks interesting.  But what if you wanted to load a word into memory?
Then you have to use MOV.W. It doesn't have any immediate data - a relative address is stored in the instruction, and the value at that address is read as a word. I'm sure z80man is going to include it soon.
Logged

DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 17:49:32
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50205


Total Post Ratings: +2611

View Profile WWW
« Reply #5 on: 11 March, 2011, 07:46:36 »
0

Sounds promising. A tutorial for SH3 ASM like ASM in 28 days or Hot Dog's tutorials (the later is more suitable for a greater range of people) would be more than welcome to increase Prizm programming popularity.

Personally I think it should be made suitable for visual people as much as possible, otherwise you're gonna single out a large group of people (like ASM in 28 days did). Calc screenshots of what each relevant example program does (even if camera captures) are more than welcome.
I'm going to edit each of the lessons later to include more details including pictures, charts, and screenshots. I am thinking that this might take a bit more than 28 days. I could divide this tutorial in sections with the first one being shorter and for beginners while an advanced one will teach the rest of the instruction in a much longer time period as I want to eventually teach every single instruction available. Even if most coders will never use half of them.
Cool to hear. Smiley

Also for now I'll create a link to this topic in the Casio Prizm section since some Casio Prizm hackers might find this useful.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
graphmastur
King Graphmastur
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 02 February, 2013, 08:34:45
Date Registered: 03 June, 2010, 21:15:55
Posts: 2262


Total Post Ratings: +60

View Profile
« Reply #6 on: 21 March, 2011, 19:14:36 »
0

So, is this dead, or do you just have to make up 12 days?
Logged

Rokem
LV0 Newcomer (Next: 5)

Offline Offline

Last Login: 04 December, 2011, 05:03:58
Date Registered: 13 April, 2011, 09:43:01
Posts: 4

Total Post Ratings: 0

View Profile
« Reply #7 on: 08 July, 2011, 10:35:38 »
0

So, is this dead, or do you just have to make up 12 days?
4 months now Tongue
Logged
JosJuice
LV9 Veteran (Next: 1337)
*********
Online Online

Last Login: Today at 19:39:32
Date Registered: 24 September, 2010, 16:46:12
Location: Sweden
Posts: 1300


Total Post Ratings: +51

View Profile
« Reply #8 on: 08 July, 2011, 11:23:23 »
0

So, is this dead, or do you just have to make up 12 days?
4 months now Tongue
Hmm, I wonder if there are that many instructions...
Logged

seana11
LV1 Newcomer (Next: 20)
*
Offline Offline

Gender: Male
Last Login: 02 March, 2013, 16:16:44
Date Registered: 06 September, 2011, 00:47:22
Location: Well, the sign says: "You are here"...
Posts: 15


Total Post Ratings: +4

View Profile
« Reply #9 on: 17 July, 2012, 22:13:10 »
0

Can I crosspost some of this to UCF?
Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 17:49:32
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50205


Total Post Ratings: +2611

View Profile WWW
« Reply #10 on: 18 July, 2012, 07:26:46 »
0

I guess there would be no problem since the author has left over 6 months ago. It wouldn't hurt to make sure it's present in WikiPrizm (and the older PrizmWiki if it's still maintained) too, so all the info is at one place.
« Last Edit: 18 July, 2012, 07:27:04 by DJ_O » Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
chickendude
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Female
Last Login: 12 May, 2013, 18:15:03
Date Registered: 06 September, 2008, 11:27:30
Posts: 435

Total Post Ratings: +66

View Profile
« Reply #11 on: 21 October, 2012, 11:44:49 »
0

Again a bit of a bump, but (in the picture) how do you get 126 from (sign-extended) $FE? I believe it should be 254 (like mentioned in the post body).

And i'd be interested in discussing SH3 assembly with anyone else interested Wink
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.295 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.