创建数组重置我标志? C ++ / asm

时间:2015-08-19 19:09:00

标签: c++ windows assembly x86 16-bit

我遇到了重置中断标志的问题。 使用asm cli将中断标志设置为0后,它会进入一行代码char* c = new char[size],当它完成初始化该数组时,它会将I标志重置为1.如何使其成为标志我一直保持当前值,因为在new []运算符之后写另一个asm cli不是解决方案,因为我在那两个启用中断的指令之间有差距吗?

Thread::Thread(StackSize stackSize, Time timeSlice) {
#ifndef BCC_BLOCK_IGNORE
    DIS_INT // a macro: #define DIS_INT asm cli
#endif

    myPCB = new PCB(stackSize,timeSlice,this);

#ifndef BCC_BLOCK_IGNORE
    ENB_INT
#endif
}

这是我将I标志设置为0并调用PCB构造函数

的地方
PCB::PCB(StackSize stackSize, Time timeSlice, Thread* thread){
    time = timeSlice;
    myThread = thread;
    stack = createStack(stackSize);
    ...

char* PCB::createStack(StackSize stackSize){
    char* stek = new char[stackSize];         // after this line, IF = 1
#ifndef BCC_BLOCK_IGNORE                      // which is not desired
    newSS = FP_SEG(stek+stackSize);
    newSP = FP_OFF(stek+stackSize);
    asm{
        mov oldSS, ss
        mov oldSP, sp
        mov ss, newSS
        mov sp, newSP

        push ax
        push bx
        push cx
        push dx
        push es
        push ds
        push si
        push di
        push bp

        mov newSS, ss
        mov newSP, sp
        mov ss, oldSS
        mov sp, oldSP
    }
    this->stekp = MK_FP(newSS,newSP);
#endif
    return stek;
}

0 个答案:

没有答案