汇编 测试AL寄存器中的数,如果是负数转到标号NEXT去执行
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了汇编 测试AL寄存器中的数,如果是负数转到标号NEXT去执行相关的知识,希望对你有一定的参考价值。
如AL=86H
TEST AL,86H
JS NEXT
执行的结果AL=86H(不变),我们只要注意到FLAGS标志寄存器的SF=1,所以程序转到标号NEXT去执行
求解 为什么AL的值不变,具体分析一下
查一下TEST指令的相关说明就能清楚了。 参考技术A 以下是芯片产生的具体到机器码的分析(简单的分析是TEST指令不影响两操作数原来内容前提下,将两数相与运算,根据结果设置标志位。为什么ADD表示加法?这是芯片产生和编译器厂商合谋产物)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TEST Logical Compare
See also
Easy Assembler Shell v3.99 Copyright(C) 1999 Roman Novgorodov
============================================================
OpcodeInstructionDescription
A8牋ibTEST AL,imm8AND imm8 with AL; set SF, ZF, PF according to result
A9 iwTEST AX,imm16AND imm16 with AX; set SF, ZF, PF according to result
A9 idTEST EAX,imm32AND imm32 with EAX; set SF, ZF, PF according to result
F6 /0 ibTEST r/m8,imm8AND imm8 with r/m8; set SF, ZF, PF according to result
F7 /0 iwTEST r/m16,imm16AND imm16 with r/m16; set SF, ZF, PF according to result
F7 /0 idTEST r/m32,imm32AND imm32 with r/m32; set SF, ZF, PF according to result
84 /rTEST r/m8,r8AND r8 with r/m8; set SF, ZF, PF according to result
85 /rTEST r/m16,r16AND r16 with r/m16; set SF, ZF, PF according to result
85 /rTEST r/m32,r32AND r32 with r/m32; set SF, ZF, PF according to result
Easy Assembler Shell v3.99 Copyright(C) 1999 Roman Novgorodov
================================================================
Description
Computes the bit-wise logical AND of first operand (source 1 operand) and the second operand (source 2 operand) and sets the SF, ZF, and PF status flags according to the result. The result is then discarded.
Operation
TEMP ?SRC1 AND SRC2;
SF ?MSB(TEMP);
IF TEMP = 0
THEN ZF ?0;
ELSE ZF ?1;
FI:
PF ?BitwiseXNOR(TEMP[0:7]);
CF ?0;
OF ?0;
(*AF is Undefined*)
Flags Affected
The OF and CF flags are cleared to 0. The SF, ZF, and PF flags are set according to the result (see the 揙peration?section above). The state of the AF flag is undefined.
Protected Mode Exceptions
#GP(0)If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
If the DS, ES, FS, or GS register contains a null segment selector.
#SS(0)If a memory operand effective address is outside the SS segment limit.
#PF(fault-code)If a page fault occurs.
#AC(0)If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.
Real-Address Mode Exceptions
#GPIf a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
#SSIf a memory operand effective address is outside the SS segment limit.
Virtual-8086 Mode Exceptions
#GP(0)If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
#SS(0)If a memory operand effective address is outside the SS segment limit.
#PF(fault-code)If a page fault occurs.
#AC(0)If alignment checking is enabled and an unaligned memory reference is made.
Easy Assembler Shell v3.99 Copyright(C) 1999 Roman Novgorodov追问
下面的好复杂,没有看懂。。。我想知道那个“测试AL寄存器中的数,如果是负数则转到NEXT执行”,,,这个负数是指AL的值,还是TEST将两数相与运算后的值????
追答难道我没有说明白么?
请读十遍下面这句话:
“简单的分析是TEST指令不影响两操作数原来内容前提下,将两数相与运算,根据结果设置标志位。”
如果还看不明白话,我不介意将关键字翻译成英文的:
SET THE BITS OF FLAG-REG ACCORDING TO THE RESULT
好吧 眼拙了我
谢了
以上是关于汇编 测试AL寄存器中的数,如果是负数转到标号NEXT去执行的主要内容,如果未能解决你的问题,请参考以下文章