IM0 / 1在z80.info解码中意味着什么?

时间:2016-09-11 12:59:40

标签: simulator z80

我正在写作(又是另一个)Z80 simulator。 我正在使用the decoding page on the z80.info site

在包含查找/解除表的部分中,它表示对于索引1和5,中断模式为IM0 / 1。该表参考IM指令(ED)X = 1,Z = 6。

IM0 / 1到底意味着什么?

我知道这不是官方指示,但我也在努力支持无证指示。

2 个答案:

答案 0 :(得分:2)

如找到here,引自Gerton Lunter:

  

指令ED 4E和ED 6E是IM 0当量:当FF被放在总线上时   (物理上)在中断时,频谱继续正常执行,而   当EF(RST 28h)被放在总线上时,它会崩溃,就像在那种情况下那样   Z80处于官方中断模式0.在IM 1中,Z80只执行RST 38h   (操作码FF)无论公交车上有什么。

所以它几乎意味着IM 0,我不确定常见/1的来源。

答案 1 :(得分:0)

IM0/1/2是设置Z80 CPU int中断模式0/1/2的指令。每种模式对可屏蔽中断的处理方式不同。我使用那些年份,但使用IIRC:

  1. IM0

    执行由外部硬件放置在数据总线上的opc

  2. IM1

    调用38h上的固定ISR

  3. IM2

    从位于i注册点的ISR入口点表中调用ISR

以下是从我的模拟器中提取的相关中断C ++代码:

//---------------------------------------------------------------------------
void Z80::_reset()
    {
    im=0;
    iff1=0;
    iff2=0;
    reg.r16.pc =0x0000;
    reg.r16.af =0xFFFF;
    reg.r16.bc =0xFFFF;
    reg.r16.de =0xFFFF;
    reg.r16.hl =0xFFFF;
    reg.r16.ix =0xFFFF;
    reg.r16.iy =0xFFFF;
    reg.r16.ir =0xFFFF;
    reg.r16.sp =0xFFFF;
    reg.r16._af=0xFFFF;
    reg.r16._bc=0xFFFF;
    reg.r16._de=0xFFFF;
    reg.r16._hl=0xFFFF;
    reg.r16.alu=0xFFFF;
    reg.r16.mem=0xFFFF;
    reg.r16.io =0xFFFF;
    reg.r16.nn =0xFFFF;
    time=0; time0=0; dtime=0;
    busrq=false;
    busack=false;
    }
//---------------------------------------------------------------------------
void Z80::_int()
    {
    if (!_enable_int) return;
    if (!iff1) return;
    if (actual->ins==_z80_ins_HALT) reg.r16.pc+=actual->size;
    if ((actual->ins==_z80_ins_EI)||(actual->ins==_z80_ins_DI)) execute();

    iff1=0;
    iff2=0;

    if (im==0)
        {
        // execute instruction on databus db from peripherials
        mc=0;
        actual=&ins_int0;
        time+=actual->mc[mc]; mc++;     // fetch INT
        BYTE db[4];
        db[0]=db8;
        db[1]=db8;
        db[2]=db8;
        db[3]=db8;
        execute(db);
        }
    else if (im==1)
        {
        mc=0;
        actual=&ins_int1;
        time+=actual->mc[mc]; mc++;     // fetch INT
        _push(reg.r16.pc);
        reg.r16.pc=0x0038;              // fixed vector 38h
        }
    else if (im==2)
        {
        mc=0;
        actual=&ins_int2;
        time+=actual->mc[mc]; mc++;     // fetch INT
        _push(reg.r16.pc);

        union { BYTE db[2]; WORD dw; } ubw;
        ubw.db[1]=reg.r8.i;             // H
        ubw.db[0]=db8;                  // L
        reg.r16.pc=_readw(ubw.dw);      // vector from mem[i+db8]
        }
    }
//---------------------------------------------------------------------------
void Z80::_nmi()
    {
    if (actual->ins==_z80_ins_HALT) reg.r16.pc+=actual->size;
    if ((actual->ins==_z80_ins_EI)||(actual->ins==_z80_ins_DI)) execute();

    iff2=iff1;      // iff2 ide do flagov po ld a,i alebo ld a,r
    iff1=0;

    mc=0;
    actual=&ins_nmi;
    time+=actual->mc[mc]; mc++;     // fetch NMI
    _push(reg.r16.pc);
    reg.r16.pc=0x0066;              // fixed vector 66h
    }
//---------------------------------------------------------------------------

按以下顺序提取所有IM指令:What's the proper implementation for hardware emulation?

opc      T0 T1 MC1   MC2   MC3   MC4   MC5   MC6   MC7   mnemonic
ED46     08 00 M1R 4 M1R 4 ... 0 ... 0 ... 0 ... 0 ... 0 IM0
ED4E     08 00 M1R 4 M1R 4 ... 0 ... 0 ... 0 ... 0 ... 0 IM0
ED56     08 00 M1R 4 M1R 4 ... 0 ... 0 ... 0 ... 0 ... 0 IM1
ED5E     08 00 M1R 4 M1R 4 ... 0 ... 0 ... 0 ... 0 ... 0 IM2
ED66     08 00 M1R 4 M1R 4 ... 0 ... 0 ... 0 ... 0 ... 0 IM0
ED6E     08 00 M1R 4 M1R 4 ... 0 ... 0 ... 0 ... 0 ... 0 IM0
ED76     08 00 M1R 4 M1R 4 ... 0 ... 0 ... 0 ... 0 ... 0 IM1
ED7E     08 00 M1R 4 M1R 4 ... 0 ... 0 ... 0 ... 0 ... 0 IM2

如您所见:

IM value: 0  0  1 2 0  0  1 2

以及您的链接页面:

IM value: 0 0/1 1 2 0 0/1 1 2

所以我希望它只是表示opc的编码方式,但是您对那里的表不是很清楚。

IM0 / 1 IM0 的重复,所以我猜它们不在原始文档中,只是在后来的文档中才发现的……而没有确切的行为知识创建表的时间...有很多原本没有记录的(秘密)说明,因此,如果您的信息源未正确包含它们,则也许不应该使用它,而转向更好的文档,以避免将来出现问题和不兼容性。