void doinit(SYM *sp) { char lbl[200]; lbl[0] = 0; if (sp->storage_class == sc_thread) { seg(tlsseg); nl(); } else if (sp->storage_class == sc_static || lastst==assign) { seg(dataseg); /* initialize into data segment */ nl(); /* start a new line in object */ } else { seg(bssseg); /* initialize into data segment */ nl(); /* start a new line in object */ } if(sp->storage_class == sc_static || sp->storage_class == sc_thread) { put_label(sp->value.i, sp->name); } else { if (sp->storage_class == sc_global) strcpy(lbl, "public "); strcat(lbl, sp->name); gen_strlab(lbl); } if( lastst != assign) { genstorage(sp->tp->size); } else { NextToken(); InitializeType(sp->tp); } endinit(); }
int InitializePointer() { SYM *sp; if(lastst == and) { /* address of a variable */ NextToken(); if( lastst != id) error(ERR_IDEXPECT); else if( (sp = gsearch(lastid)) == NULL) error(ERR_UNDEFINED); else { NextToken(); if( lastst == plus || lastst == minus) GenerateReference(sp,GetIntegerExpression()); else GenerateReference(sp,0); if( sp->storage_class == sc_auto) error(ERR_NOINIT); } } else if(lastst == sconst) { GenerateLabelReference(stringlit(laststr)); NextToken(); } else GenerateLong(GetIntegerExpression()); endinit(); return 8; /* pointers are 4 bytes long */ }
int tricore_module_disable(tricore_mod_t *m) { int res = 0; int ps; ps = disable_interrupts(); endinit(0); m->clc |= CLC_DISR; if ( (m->clc & CLC_DISS) == 0 ) /* flush pipeline by reading */ { res = -1; /* module is still enabled */ } endinit(1); restore_interrupts(ps); return(res); }
int tricore_module_init(tricore_mod_t *m, int sleep, uint32_t rmc) { int res = 0; int ps; ps = disable_interrupts(); endinit(0); m->clc = (sleep ? CLC_EDIS : 0) | CLC_RMCval(rmc); if ( m->clc & CLC_DISS ) /* flush pipeline by reading */ { res = -1; /* module is still disabled */ } endinit(1); restore_interrupts(ps); return(res); }
int InitializePointer() { SYM *sp; ENODE *n; long lng; if(lastst == bitandd) { /* address of a variable */ NextToken(); if( lastst != id) error(ERR_IDEXPECT); else if( (sp = gsearch(lastid)) == NULL) error(ERR_UNDEFINED); else { NextToken(); if( lastst == plus || lastst == minus) GenerateReference(sp,GetIntegerExpression((ENODE **)NULL)); else GenerateReference(sp,0); if( sp->storage_class == sc_auto) error(ERR_NOINIT); } } else if(lastst == sconst) { GenerateLabelReference(stringlit(laststr)); NextToken(); } else if (lastst == rconst) { GenerateLabelReference(quadlit(&rval128)); NextToken(); } //else if (lastst == id) { // sp = gsearch(lastid); // if (sp->tp->type == bt_func || sp->tp->type == bt_ifunc) { // NextToken(); // GenerateReference(sp,0); // } // else // GenerateLong(GetIntegerExpression(NULL)); //} else { lng = GetIntegerExpression(&n); if (n && n->nodetype == en_cnacon) { if (n->sp->length()) { sp = gsearch(*n->sp); GenerateReference(sp,0); } else GenerateLong(lng); } else { GenerateLong(lng); } } endinit(); return 2; /* pointers are 2 bytes long */ }
void doinit(SYM *sp) { char lbl[200]; lbl[0] = 0; if (sp->storage_class == sc_thread) { seg(tlsseg); nl(); } else if (sp->storage_class == sc_static || lastst==assign) { seg(dataseg); /* initialize into data segment */ nl(); /* start a new line in object */ } else { seg(bssseg); /* initialize into data segment */ nl(); /* start a new line in object */ } if(sp->storage_class == sc_static || sp->storage_class == sc_thread) { put_label(sp->value.i, sp->name, GetNamespace(), 'D'); } else { if (sp->storage_class == sc_global) { strcpy(lbl, "public "); if (curseg==dataseg) strcat(lbl, "data "); else if (curseg==bssseg) strcat(lbl, "bss "); else if (curseg==tlsseg) strcat(lbl, "tls "); } strcat(lbl, sp->name); gen_strlab(lbl); } if( lastst != assign) { genstorage(sp->tp->size); } else { NextToken(); InitializeType(sp->tp); } endinit(); if (sp->storage_class == sc_global) fprintf(output,"\nendpublic\n"); }
void doinit(SYM *sp) { char lbl[200]; int algn; enum e_sg oseg; oseg = noseg; lbl[0] = 0; // Initialize constants into read-only data segment. Constants may be placed // in ROM along with code. if (sp->isConst) { oseg = rodataseg; } if (sp->storage_class == sc_thread) { if (sp->tp->type==bt_struct || sp->tp->type==bt_union) algn = imax(sp->tp->alignment,2); else if (sp->tp->type==bt_pointer && sp->tp->val_flag) algn = imax(sp->tp->GetBtp()->alignment,2); else algn = 2; seg(oseg==noseg ? tlsseg : oseg,algn); nl(); } else if (sp->storage_class == sc_static || lastst==assign) { if (sp->tp->type==bt_struct || sp->tp->type==bt_union) algn = imax(sp->tp->alignment,2); else if (sp->tp->type==bt_pointer && sp->tp->val_flag) algn = imax(sp->tp->GetBtp()->alignment,2); else algn = 2; seg(oseg==noseg ? dataseg : oseg,algn); /* initialize into data segment */ nl(); /* start a new line in object */ } else { if (sp->tp->type==bt_struct || sp->tp->type==bt_union) algn = imax(sp->tp->alignment,2); else if (sp->tp->type==bt_pointer && sp->tp->val_flag) algn = imax(sp->tp->GetBtp()->alignment,2); else algn = 2; seg(oseg==noseg ? bssseg : oseg,algn); /* initialize into data segment */ nl(); /* start a new line in object */ } if(sp->storage_class == sc_static || sp->storage_class == sc_thread) { sp->realname = my_strdup(put_label(sp->value.i, (char *)sp->name->c_str(), GetNamespace(), 'D')); } else { if (sp->storage_class == sc_global) { strcpy_s(lbl, sizeof(lbl), "public "); if (curseg==dataseg) strcat_s(lbl, sizeof(lbl), "data "); else if (curseg==bssseg) strcat_s(lbl, sizeof(lbl), "bss "); else if (curseg==tlsseg) strcat_s(lbl, sizeof(lbl), "tls "); } strcat_s(lbl, sizeof(lbl), sp->name->c_str()); gen_strlab(lbl); } if (lastst == kw_firstcall) { GenerateByte(1); return; } else if( lastst != assign) { genstorage(sp->tp->size); } else { NextToken(); InitializeType(sp->tp); } endinit(); if (sp->storage_class == sc_global) ofs.printf("\nendpublic\n"); }