汇编程序41:检测点11.4(分析一个奇怪的程序)
1 assume cs:code 2 //奇怪之处ax的值为47h?使用指令pushf,popf 3 code segment 4 start: 5 mov ax,0 6 push ax 7 popf //从栈中弹出数据,送入标志寄存器,易知PSW将会被置为0 8 mov ax,0fff0h 9 add ax,0010h //结果为0000h,并发生进位,不溢出,此时寄存器的状态为NV UP DI PL ZR NA PE CY(即PSW:00000000 01000111,如果默认第01位为0则是01000101结果为45) 10 pushf //将psw=47h值压入栈 11 pop ax //将之前压入的值赋给al=47h(01000111)ah=0h(00000000) 12 and al,11000101b //异与后al=45h(01000101)ah不变 13 and ah,00001000b //异与后ah=0h(00000000)al不变 14 mov ax,4c00h 15 int 21h 16 code ends //所以ax最后值为45h 17 18 end start