Mercurial > hg > CbC > old > device
changeset 479:51c1b795b4f3
fix broken $gp in jal in code segement
author | kono |
---|---|
date | Sat, 26 Nov 2005 09:50:55 +0900 |
parents | 5e1acbe82483 |
children | 5c497d547c0b |
files | mc-code-mips.c test/float.c |
diffstat | 2 files changed, 67 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-mips.c Thu Nov 10 18:51:17 2005 +0900 +++ b/mc-code-mips.c Sat Nov 26 09:50:55 2005 +0900 @@ -3076,7 +3076,12 @@ void code_label_call(int l) { - printf("\tjal L_%d\n",l); + if (fnptr->sc==CODE) { + printf("\tla\t$25,L_%d\n",l); + printf("\tjalr\t$25\n"); + printf("\tlw\t$gp,$L_%d($sp)\n",cprestore_label); + } else + printf("\tjal L_%d\n",l); } void @@ -3467,7 +3472,12 @@ code_save_stacks(); clear_ptr_cache(); extern_define(conv,0,FUNCTION,1); - printf("\tjal %s\n",conv); + if (fnptr->sc==CODE) { + printf("\tla\t$25,%s\n",conv); + printf("\tjalr\t$25\n"); + printf("\tlw\t$gp,$L_%d($sp)\n",cprestore_label); + } else + printf("\tjal %s\n",conv); lib_args(16); } #endif
--- a/test/float.c Thu Nov 10 18:51:17 2005 +0900 +++ b/test/float.c Sat Nov 26 09:50:55 2005 +0900 @@ -6,6 +6,7 @@ extern double sin(double); // extern float fsin(float); double test9(double f,int i); +int test7(); float f = 0.3; double d = 0.3; @@ -95,6 +96,7 @@ test3(1,2,3,10,11,4); test4(1,2,3,10,11,4); test5(1,2,3,10,11,4); + test7(); g = 1.0; g = -g; @@ -388,4 +390,57 @@ return h/3-(3.0-(g+3)*test9(f*0.5,i-1)/(h-1)); } +struct huga0 { + char c; + short s; + int i; + long l; + float f; +}; +struct huga { + char c; + short s; + int i; + long l; + float f; + struct huga0 hh; +}; + +struct enemy{ + int charno; // image number + float x; // x location + float y; // y location + int ap; // armor point +}; + +void +print_param(struct enemy *e) +{ + printf("charno:%d x,y:%f,%f hp:%d\n", + e->charno,e->x,e->y,e->ap); +} + + +int test7() +{ + struct huga h; + struct enemy e; + + h.c = 10; + h.s = 20; + h.i = 30; + h.l = 40; + h.f = 50; + h.hh.c = 10; + h.hh.s = 20; + h.hh.i = 30; + h.hh.l = 40; + h.hh.f = 50; + + + e.charno=5; e.x=50.0; e.y=30.0; e.ap=100; + print_param(&e); + return (0); +} +