changeset 4:a7bc45dba4aa

*** empty log message ***
author kono
date Fri, 17 Nov 2006 16:54:11 +0900
parents a2f98ca2d764
children 3fc420dc1bec
files s-code-ppc.c
diffstat 1 files changed, 22 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/s-code-ppc.c	Fri Nov 17 16:28:43 2006 +0900
+++ b/s-code-ppc.c	Fri Nov 17 16:54:11 2006 +0900
@@ -16,31 +16,40 @@
 "	.text",
 "	.align 2",
 "	.globl _main",
-"	_main:",
+"_main:",
 "	mflr r0",
+"        stmw r29,-12(r1)",
+"        stw r0,8(r1)",
+"        stwu r1,-80(r1)",
 "	bcl 20,31,\"L00000000001$pb\"",
-"	\"L00000000001$pb\":",
+"\"L00000000001$pb\":",
 "	mflr r31",
-"	mtlr r0",
     NULL
 };
 
+
 static
 char *ending[] = {
+"        addi r1,r1,80",
+"        lwz r0,8(r1)",
+"        mtlr r0",
+"        lmw r29,-12(r1)",
+"        blr",
+"",
 "	.cstring",
 "	.align 2",
-"	LC0:",
+"LC0:",
 "	.ascii \"= %d\\12\\0\"",
 "	.text",
 "	.align 2",
 "	.globl _print",
-"	_print:",
+"_print:",
 "	mflr r0",
 "	stw r31,-4(r1)",
 "	stw r0,8(r1)",
 "	stwu r1,-80(r1)",
 "	bcl 20,31,\"L00000000002$pb\"",
-"	\"L00000000002$pb\":",
+"\"L00000000002$pb\":",
 "	mflr r31",
 "	mr r4,r3",
 "	addis r3,r31,ha16(LC0-\"L00000000002$pb\")",
@@ -57,11 +66,11 @@
     ".comm _variable,192",
 "	.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32",
 "	.align 5",
-"	L_printf$stub:",
+"L_printf$stub:",
 "	.indirect_symbol _printf",
 "	mflr r0",
 "	bcl 20,31,\"L00000000001$spb\"",
-"	\"L00000000001$spb\":",
+"\"L00000000001$spb\":",
 "	mflr r11",
 "	addis r11,r11,ha16(L_printf$lazy_ptr-\"L00000000001$spb\")",
 "	mtlr r0",
@@ -69,7 +78,7 @@
 "	mtctr r12",
 "	bctr",
 "	.lazy_symbol_pointer",
-"	L_printf$lazy_ptr:",
+"L_printf$lazy_ptr:",
 "	.indirect_symbol _printf",
 "	.long   dyld_stub_binding_helper",
 "        .non_lazy_symbol_pointer",
@@ -102,8 +111,8 @@
 emit_store(assign)
 int assign;
 {
-    printf("\taddis r2,r31,ha16(L_variable$non_lazy_ptr-\"L00000000002$pb\")\n");
-    printf("\tlwz r2,lo16(L_variable$non_lazy_ptr-\"L00000000002$pb\")(r2)\n");
+    printf("\taddis r2,r31,ha16(L_variable$non_lazy_ptr-\"L00000000001$pb\")\n");
+    printf("\tlwz r2,lo16(L_variable$non_lazy_ptr-\"L00000000001$pb\")(r2)\n");
     printf("\tstw r3,%d(r2)\n",assign*4);
 }
 
@@ -149,8 +158,8 @@
 emit_load(d)
 int d;
 {
-    printf("\taddis r2,r31,ha16(L_variable$non_lazy_ptr-\"L00000000002$pb\")\n");
-    printf("\tlwz r2,lo16(L_variable$non_lazy_ptr-\"L00000000002$pb\")(r2)\n");
+    printf("\taddis r2,r31,ha16(L_variable$non_lazy_ptr-\"L00000000001$pb\")\n");
+    printf("\tlwz r2,lo16(L_variable$non_lazy_ptr-\"L00000000001$pb\")(r2)\n");
     printf("\tlwz r3,%d(r2)\n",d*4);  //  -1024<d <1024
 }