Skip to content

Commit

Permalink
Make dryrun vector tables more realistic
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanrueger committed Jul 15, 2024
1 parent e4c67c2 commit f3caabf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/dryrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,22 @@ static int flashlayout(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *fl
// Write a vector table to flash addr and return number of bytes written
static int putvectortable(const AVRPART *p, const AVRMEM *flm, int addr) {
int vecsz = flm->size <= 8192? 2: 4, ret = p->n_interrupts * vecsz;
int app = (ret + vecsz - 2)/2; // Distance to application in words

for(int i = 0; i < ret; i += vecsz) { // First store rjmps
flm->buf[addr + i] = 255-i/2;
flm->buf[addr + i + 1] = 0xcf; // rjmp .-2, rjmp .-6, ...
for(int i = 0; i < ret; i += vecsz) { // First store rjmps to after table
flm->buf[addr + i] = app;
flm->buf[addr + i + 1] = 0xc0 + (app>>8); // rjmp app, rjmp app, ...
app -= vecsz/2;
}
for(int i=0; i < vecsz; i++) // Leave one vector gap
flm->buf[addr + ret++] = ' ';

flm->buf[addr + ret++] = 0xff; // Put endless lopp as application
flm->buf[addr + ret++] = 0xcf;

// Then round up to multiples of 32
while(ret%32)
flm->buf[ret++] = ' ';
flm->buf[addr + ret++] = ' ';

return ret;
}
Expand Down

0 comments on commit f3caabf

Please sign in to comment.