54 lines
1.8 KiB
Markdown
54 lines
1.8 KiB
Markdown
#README
|
||
Try below command
|
||
```
|
||
gcc -g -m32 lab0_ex3.c 2>&1|tee make.log
|
||
```
|
||
If you get gcc's error, try to read make.log and fix the bugs.
|
||
|
||
If gcc successed, then you will get a.out.
|
||
|
||
Try to answer below question.
|
||
|
||
对于如下的代码段,
|
||
```
|
||
...
|
||
#define STS_CG32 0xC // 32-bit Call Gate
|
||
#define STS_IG32 0xE // 32-bit Interrupt Gate
|
||
|
||
#define SETGATE(gate, istrap, sel, off, dpl) { \
|
||
(gate).gd_off_15_0 = (uint32_t)(off) & 0xffff; \
|
||
(gate).gd_ss = (sel); \
|
||
(gate).gd_args = 0; \
|
||
(gate).gd_rsv1 = 0; \
|
||
(gate).gd_type = (istrap) ? STS_TG32 : STS_IG32; \
|
||
(gate).gd_s = 0; \
|
||
(gate).gd_dpl = (dpl); \
|
||
(gate).gd_p = 1; \
|
||
(gate).gd_off_31_16 = (uint32_t)(off) >> 16; \
|
||
}
|
||
|
||
/* Gate descriptors for interrupts and traps */
|
||
struct gatedesc {
|
||
unsigned gd_off_15_0 : 16; // low 16 bits of offset in segment
|
||
unsigned gd_ss : 16; // segment selector
|
||
unsigned gd_args : 5; // # args, 0 for interrupt/trap gates
|
||
unsigned gd_rsv1 : 3; // reserved(should be zero I guess)
|
||
unsigned gd_type : 4; // type(STS_{TG,IG32,TG32})
|
||
unsigned gd_s : 1; // must be 0 (system)
|
||
unsigned gd_dpl : 2; // descriptor(meaning new) privilege level
|
||
unsigned gd_p : 1; // Present
|
||
unsigned gd_off_31_16 : 16; // high bits of offset in segment
|
||
};
|
||
|
||
...
|
||
|
||
```
|
||
如果在其他代码段中有如下语句,
|
||
```
|
||
unsigned intr;
|
||
intr=8;
|
||
SETGATE(intr, 0,1,2,3);
|
||
```
|
||
请问执行上述指令后, intr的值是多少?
|
||
|