Go to bottomPage: 1
ZNEO Compiller Question About Dynamic frames call 1 Year, 8 Months ago Karma: 0
I have a routine call that returns a structure. Upon call to "return *val;"
where val is a pointer to structure the return value was wrong. upon examining
the assembly. inside the functions body the R1 register which hold the frame
pointer was modified by the compiler without saving its value so when the
function exit it return a wrong value(maybe its because of the modified R1 value).

#include "string.h"

typedef struct{
int (*setval) (void * _this);

typedef struct base_cls_s{
base_cls__vptr0 * vptr0;
char base_cls__ghost_var ;
#define THIS_base_cls ((base_cls*)_this)

int base_cls__setval(void * _this);
base_cls base_cls__constructor(void * _this);

typedef struct{
int (*setval) (void * _this);
typedef struct mcls_s{
mcls__vptr0 * vptr0;
char base_cls__ghost_var ;
unsigned char mcls___data [4];
#define THIS_mcls ((mcls*)_this)
mcls mcls__constructor(void * _this,int v);

base_cls__vptr0 base_cls__vptr0init={base_cls__setval};
int base_cls__setval(void * _this){
return 1;
base_cls base_cls__constructor(void * _this){
THIS_base_cls->vptr0 = &base_cls__vptr0init;
return *THIS_base_cls;

mcls__vptr0 mcls__vptr0init={base_cls__setval};

mcls mcls__constructor(void * _this,int v){
THIS_mcls->vptr0 = &mcls__vptr0init;
f_f_memcpy(THIS_mcls->mcls___data,&v,4); // structure value is correct
return *THIS_mcls; // this part is the problem

mcls test ;
void class_init(void){
void setup(){
// put your setup code here, to run once:
void main(void){
// put your main code here, to run repeatedly:
rakschiptron (User)
Fresh Boarder
Posts: 7
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
Go to topPage: 1
The Sample Center is managed separately
from Zilog's Customer Support services,
and therefore requires a separate login.
Acknowledged! Take me to the Sample Center.
Disable this pop-up in the future.