All pastes #270159 Raw Edit

Mine

public text v1 · immutable
·published 2006-12-07 03:47 UTC
rendered paste body
void append_reloc(ALL_TABLES* tfinal, ALL_TABLES *t1, ALL_TABLES* t2){
    /* appends t2->reloc[] to tfinal->reloc[],
       updating the code addresses of the reloc items to the
       value required in tfinal->reloc[], and editing
       tfinal->code[] as necessary,
       */

        // Local variable declarations
                int i=0;
                int tix=0;
                reloc_fields r;

        // Do some book-keeping before the loop begins
                int t2_coffset = t1->last_code+1 - t2->first_code;
                int t2_doffset = t1->last_dseg+1 - t2->first_dseg;

        // Now we need to enter the loop

                for(i=0; i<=t2->last_reloc; i++){
                        // Assign local r
                           r = t2->reloc[i];

                        // Check for different conditions
                           if(r.r.ref==CODEREF){
                                r.r.adr += t2_coffset;
                                tfinal->code[r.r.adr].u.y += t2_coffset; } // end CODEREF check
                           if(r.r.ref==EXTDSEGREF){
                                r.r.adr += t2_coffset;
                                if(tfinal->code[r.r.adr].u.y != 0xffff)
                                   tfinal->code[r.r.adr].u.y += t2_doffset;  } // end EXTDSEGREF check
                           if(r.r.ref==DSEGREF){
                                if(r.r.tabix == NO_MOD)
                                   r.r.tabix = 0x00;
                                else{
                                  r.r.adr += t2_coffset;
                                  tfinal->code[r.r.adr].u.y += t2_doffset; } } // end else and DSEGREF check
                           if(r.r.ref==MARKSTACKREF){
                                tix=t2->code[r.r.adr].u.y;
                                tix=search_tab(tfinal, t2->tab[tix].name);
                                r.r.adr += t2_coffset;
                                tfinal->code[r.r.adr].u.y = tix; } // end MARKSTACKREF check
        // Append to tfinal

                tfinal->last_reloc++;
                tfinal->reloc[tfinal->last_reloc]=r;

        } // end for
}  /* end append_reloc */