int instruction)div.c on xv6Makefile: change -O2 to -O0; add _div to UPROGSpid 4 div: trap 0 err 0 on cpu 0 eip 0x62 addr 0x0--kill proctrap()?struct trapframe from?
alltraps in trapasm.Svector0, …, vector255 in vectors.Strap.c for setting up the idt#include "types.h"
#include "user.h"
int
main(int argc, char **argv)
{
int x, y, z;
if (argc < 3){
printf(2, "usage: div x y\n");
exit();
}
x = atoi(argv[1]);
y = atoi(argv[2]);
z = x / y;
printf(1, "%d / %d = %d\n", x, y, z);
exit();
}traps.h%idtr register: base address of IDTcs:offset: entry pointtype
%eflags%eflagstrap.c: tvinit() - SETGATE, idtinit() - lidtvectors.Sdiv.asm and find the idivl instruction (e.g., at 0x62)idivl (e.g., b *0x62)info registers: esp. cs & esp
cssix/6x $esptrap(): who set tf->trapnocase T_DIVIDE: return; and single-step until iretidivl