📄 outas68.c
字号:
;/* oc_genlongdouble(val); */
dataofs+=8;
}
int genstring(char *str, int uselong)
/*
* Generate a string literal
*/
{
if (uselong) {
while (*(short *)str) {
genword(*((short *)str));
str += sizeof(short);
}
genword(0);
return pstrlen(str)*2;
}
else {
int size = 0;
while (*str) {
genbyte(*str++);
size++;
}
return size;
}
}
void genbyte(long val)
/*
* Output a byte value
*/
{ if (prm_asmfile)
if( gentype == bytegen && outcol < 60) {
fprintf(outputFile,",$%X",val & 0x00ff);
outcol += 4;
}
else {
nl();
fprintf(outputFile,"\tDC.B\t$%X",val & 0x00ff);
gentype = bytegen;
outcol = 19;
}
else
;/* oc_genbyte(val); */
dataofs+=1;
}
void genword(long val)
/*
* Output a word value
*/
{ if (prm_asmfile)
if( gentype == wordgen && outcol < 58) {
fprintf(outputFile,",$%X",val & 0x0ffff);
outcol += 6;
}
else {
nl();
fprintf(outputFile,"\tDC.W\t$%X",val & 0x0ffff);
gentype = wordgen;
outcol = 21;
}
else
;/* oc_genword(val); */
dataofs+=2;
}
void genlong(long val)
/*
* Output a long value
*/
{ if (prm_asmfile)
if( gentype == longgen && outcol < 56) {
fprintf(outputFile,",$%lX",val);
outcol += 10;
}
else {
nl();
fprintf(outputFile,"\tDC.L\t$%lX",val);
gentype = longgen;
outcol = 25;
}
else
;/* oc_genlong(val); */
dataofs+=4;
}
/*
* Generate a startup or rundown reference
*/
void gensrref(SYM *sp,int val)
{
if (prm_asmfile)
if( gentype == srrefgen && outcol < 56) {
fprintf(outputFile,",%s,%d",sp->name,val);
outcol += strlen(sp->name)+1;
}
else {
nl();
fprintf(outputFile,"\tDC.L\t%s,%d",sp->name,val);
gentype = srrefgen;
outcol = 25;
}
else
;/* oc_gensrref(sp,val); */
}
void genref(SYM *sp,int offset)
/*
* Output a reference to the data area (also gens fixups )
*/
{ char sign;
char buf[40];
if( offset < 0) {
sign = '-';
offset = -offset;
}
else
sign = '+';
sprintf(buf,"%s%c%d",sp->name,sign,offset);
datalink(FALSE);
if (prm_asmfile) {
if( gentype == longgen && outcol < 55 - strlen(sp->name)) {
fprintf(outputFile,",%s",buf);
outcol += (11 + strlen(sp->name));
}
else {
nl();
fprintf(outputFile,"\tDC.L\t%s",buf);
outcol = 26 + strlen(sp->name);
gentype = longgen;
}
}
else
;/* oc_genref(sp,val); */
dataofs+=4;
}
void genpcref(SYM *sp,int offset)
/*
* Output a reference to the code area (also gens fixups )
*/
{ char sign;
char buf[40];
if( offset < 0) {
sign = '-';
offset = -offset;
}
else
sign = '+';
sprintf(buf,"%s%c%d",sp->name,sign,offset);
datalink(TRUE);
if (prm_asmfile) {
if( gentype == longgen && outcol < 55 - strlen(sp->name)) {
fprintf(outputFile,",%s",buf);
outcol += (11 + strlen(sp->name));
}
else {
nl();
fprintf(outputFile,"\tDC.L\t%s",buf);
outcol = 26 + strlen(sp->name);
gentype = longgen;
}
}
else
;/* oc_genpcref(sp,val); */
dataofs+=4;
}
void genstorage(int nbytes)
/*
* Output bytes of storage
*/
{ if (prm_asmfile) {
nl();
fprintf(outputFile,"\tDS.B\t$%X\n",nbytes);
}
else
;/* oc_genstorage(nbytes); */
dataofs+=nbytes;
}
void gen_labref(int n)
/*
* Generate a reference to a label
*/
{ if (prm_asmfile)
if( gentype == longgen && outcol < 58) {
fprintf(outputFile,",L_%d",n);
outcol += 6;
}
else {
nl();
fprintf(outputFile,"\tDC.L\tL_%d",n);
outcol = 22;
gentype = longgen;
}
else
;/* oc_genlabref(n); */
datalink(TRUE);
dataofs+=4;
}
int stringlit(char *s, int uselong)
/*
* make s a string literal and return it's label number.
*/
{ OCODE *ip;
ip = xalloc(sizeof(OCODE));
ip->opcode = op_label;
ip->oper1 = (AMODE *)nextlabel;
ip->back = 0;
if (!peep_head)
peep_head = peep_tail = peep_insert = ip;
else {
if (peep_insert->fwd) {
peep_insert->fwd->back = ip;
}
ip->back = peep_insert;
ip->fwd = peep_insert->fwd;
if (peep_tail == peep_insert)
peep_tail = ip;
peep_insert = peep_insert->fwd = ip;
}
ip = xalloc(sizeof(OCODE));
ip->opcode = op_slit;
if (uselong) {
ip->oper1 = plitlate(s);
ip->oper2 = (AMODE *)1;
}
else {
ip->oper1 = litlate(s);
ip->oper2 = 0;
}
if (peep_insert->fwd)
peep_insert->fwd->back = ip;
ip->back = peep_insert;
ip->fwd = peep_insert->fwd;
if (peep_tail == peep_insert)
peep_tail = ip;
peep_insert = peep_insert->fwd = ip;
return nextlabel++;
}
void dumplits(void)
{
}
/*
* Switch to cseg
*/
void cseg(void)
{ if (prm_asmfile)
if( curseg != codeseg) {
nl();
fprintf(outputFile,"\tSECTION\tcode\n");
curseg = codeseg;
}
}
/*
* Switch to dseg
*/
void dseg(void)
{ if (prm_asmfile)
if( curseg != dataseg) {
nl();
fprintf(outputFile,"\tSECTION\tdata\n");
curseg = dataseg;
}
}
/*
* Switch to bssseg
*/
void bssseg(void)
{ if (prm_asmfile)
if( curseg != bssxseg) {
nl();
fprintf(outputFile,"\tSECTION\tbss\n");
curseg = bssxseg;
}
}
/*
* Switch to startupseg
*/
void startupseg(void)
{ if (prm_asmfile)
if( curseg != startupxseg) {
nl();
fprintf(outputFile,"\tSECTION\tcstartup\n");
curseg = startupxseg;
}
}
/*
* Switch to rundownseg
*/
void rundownseg(void)
{ if (prm_asmfile)
if( curseg != rundownxseg) {
nl();
fprintf(outputFile,"\tSECTION\tcrundown\n");
curseg = rundownxseg;
}
}
/*
* Switch to cppseg
*/
void cppseg(void)
{ if (prm_asmfile)
if( curseg != cppxseg) {
nl();
fprintf(outputFile,"\tSECTION\tcppinit\n");
curseg = cppxseg;
}
}
void gen_virtual(char *name)
/*
* Generate a virtual segment
*/
{
if (prm_asmfile) {
nl();
fprintf(outputFile,"@%s\tVIRTUAL",name);
}
}
void gen_endvirtual(char *name)
/*
* Generate the end of a virtual segment
*/
{
if (prm_asmfile) {
nl();
fprintf(outputFile,"@%s\tENDVIRTUAL",name);
}
}
void genlongref(DATALINK *p)
/*
* Generate a reference reference for fixup tables
*/
{
if (prm_asmfile)
if( gentype == longgen && outcol < 56) {
fprintf(outputFile,",%s+$%X",p->sp->name,p->offset);
outcol += 10;
}
else {
nl();
fprintf(outputFile,"\tDC.L\t%s+$%X",p->sp->name,p->offset);
gentype = longgen;
outcol = 25;
}
else
;/* oc_longen(p->sp,p->offset); */
}
/*
* Assembly file header
*/
void asm_header(void)
{
}
void globaldef(SYM *sp)
/*
* Stick in a global definition
*/
{
if (prm_asmfile) {
char buf[100],*q=buf,*p=sp->name;
nl();
if (curseg == codeseg && sp->pascaldefn) {
if (prm_cmangle)
p++;
while(*p)
*q++=toupper(*p++);
*q++ = 0;
}
else
strcpy(buf,p);
fprintf(outputFile,"\tXDEF\t%s\n",buf);
}
}
void putexterns(void)
/*
* Output the fixup tables and the global/external list
*/
{ SYM *sp;
DATALINK *p;
int i;
int started = FALSE;
p = datahead;
curseg = fixcseg;
while (p) {
if (p->type) {
if (!started && prm_asmfile) {
nl();
fprintf(outputFile,"\tSECTION\tcodefix\n");
started = TRUE;
}
genlongref(p);
}
p = p->next;
}
started = FALSE;
p = datahead;
curseg = fixdseg;
while (p) {
if (!p->type) {
if (!started && prm_asmfile) {
nl();
fprintf(outputFile,"\tSECTION\tdatafix\n");
started = TRUE;
}
genlongref(p);
}
p = p->next;
}
curseg = noseg;
if (prm_asmfile) {
nl();
for (i=0; i < HASHTABLESIZE; i++) {
if ((sp=(SYM *) globalhash[i]) != 0) {
while (sp) {
if( (sp->storage_class == sc_external || sp->storage_class == sc_externalfunc)&& sp->extflag) {
char buf[100],*q=buf,*p=sp->name;
if (curseg == codeseg && sp->pascaldefn) {
if (prm_cmangle)
p++;
while(*p)
*q++=toupper(*p++);
*q++ = 0;
}
else
strcpy(buf,p);
fprintf(outputFile,"\tXREF\t%s\n",buf);
}
sp = sp->next;
}
}
}
}
else
;/* oc_gencode(); */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -