{"id":632,"date":"2010-11-22T21:28:37","date_gmt":"2010-11-22T11:28:37","guid":{"rendered":"http:\/\/brnz.org\/hbr\/?p=632"},"modified":"2010-11-22T21:28:37","modified_gmt":"2010-11-22T11:28:37","slug":"assembly-primer-part-1-system-organization-spu","status":"publish","type":"post","link":"https:\/\/brnz.org\/hbr\/?p=632","title":{"rendered":"Assembly Primer Part 1 &#8212; System Organization &#8212; SPU"},"content":{"rendered":"<p>The platform I&#8217;m using is Debian Sid on a PS3 (3.15 OtherOS) with the spu-gcc toolchain.<\/p>\n<p>These are my notes for where I can see the SPU varying from the ia32, as presented in the video\u00a0<a href=\"http:\/\/www.securitytube.net\/Assembly-Primer-for-Hackers-%28Part-1%29-System-Organization-video.aspx\">Part 1 &#8212; System Organization<\/a>. \u00a0Let me know if I&#8217;ve missed something important, obvious or got something wrong.<\/p>\n<p>For reference, I&#8217;m using the SPU <a href=\"https:\/\/www-01.ibm.com\/chips\/techlib\/techlib.nsf\/techdocs\/02E544E65760B0BF87257060006F8F20\">ABI<\/a> and <a href=\"https:\/\/www-01.ibm.com\/chips\/techlib\/techlib.nsf\/techdocs\/76CA6C7304210F3987257060006F2C44\">ISA<\/a> docs.<\/p>\n<h2>General Purpose Registers<\/h2>\n<ul>\n<li>128 128bit registers, treated as different data types depending on the instruction used.\n<ul>\n<li>r0 (LR) &#8212; Return Address \/ Link Register<\/li>\n<li>r1 (SP) &#8212; Stack pointer information.\n<ul>\n<li>Word 0 &#8212; current stack pointer (always 16-byte aligned, grows down)<\/li>\n<li>Word 1 &#8212; bytes of available stack space<\/li>\n<\/ul>\n<\/li>\n<li>r2 &#8212; Environment pointer (for languages that use one)<\/li>\n<li>r3&#8211;r74 &#8212; First 72 qwords of a function&#8217;s argument list and its return value<\/li>\n<li>r75&#8211;r79 &#8212; Scratch registers<\/li>\n<li>r80&#8211;r127 &#8212; Local variable registers. \u00a0Preserved across function calls.<\/li>\n<\/ul>\n<\/li>\n<li>FPSCR &#8212; Floating-Point Status and Control Register<\/li>\n<li>Channels &#8212; Used for various DMA operations, access to the decrementer, mailboxes and signalling.<\/li>\n<li>SRR0 &#8212; Used to store the address of next instruction upon interrupt<\/li>\n<li>LSLR &#8212; Local Store Limit Register. \u00a00x0003ffff == 2<sup>18<\/sup>-1 == 262143<\/li>\n<\/ul>\n<h2>Memory model<\/h2>\n<ul>\n<li>.text at address 0<\/li>\n<li>Bottom of stack at 0x3ffff, effectively earlier if using -mstdmain. \u00a0(at least, afaict &#8212; could look more closely at how -mstdmain actually works&#8230;)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The platform I&#8217;m using is Debian Sid on a PS3 (3.15 OtherOS) with the spu-gcc toolchain. These are my notes for where I can see the SPU varying from the ia32, as presented in the video\u00a0Part 1 &#8212; System Organization. \u00a0Let me know if I&#8217;ve missed something important, obvious or got something wrong. For reference, &hellip; <a href=\"https:\/\/brnz.org\/hbr\/?p=632\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Assembly Primer Part 1 &#8212; System Organization &#8212; SPU&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,26],"tags":[38,40],"_links":{"self":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts\/632"}],"collection":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=632"}],"version-history":[{"count":8,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts\/632\/revisions"}],"predecessor-version":[{"id":704,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts\/632\/revisions\/704"}],"wp:attachment":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}