In a
computer
A computer is a machine that can be Computer programming, programmed to automatically Execution (computing), carry out sequences of arithmetic or logical operations (''computation''). Modern digital electronic computers can perform generic set ...
processor the negative flag or sign flag is a single bit in a system status (flag) register used to indicate whether the result of the last mathematical operation produced a value in which the most significant bit (the left most bit) was set. In a
two's complement
Two's complement is the most common method of representing signed (positive, negative, and zero) integers on computers, and more generally, fixed point binary values. Two's complement uses the binary digit with the ''greatest'' value as the ''s ...
interpretation of the result, the negative flag is set if the result was negative.
For example, in an 8-bit signed number system, -37 will be represented as 1101 1011 in binary (the most significant bit, or
sign bit, is 1), while +37 will be represented as 0010 0101 (the most significant bit is 0).
The negative flag is set according to the result in the
x86
x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
series processors by the following instructions (referring to the
Intel 80386
The Intel 386, originally released as the 80386 and later renamed i386, is the third-generation x86 architecture microprocessor from Intel. It was the first 32-bit computing, 32-bit processor in the line, making it a significant evolution in ...
manual
INTEL 80386. Programmer's Reference Manual 1986
/ref>):
* All arithmetic operations except multiplication and division;
* compare instructions (equivalent to subtract instructions without storing the result);
* Logical instructions – XOR, AND, OR;
* TEST
Test(s), testing, or TEST may refer to:
* Test (assessment), an educational assessment intended to measure the respondents' knowledge or other abilities
Arts and entertainment
* ''Test'' (2013 film), an American film
* ''Test'' (2014 film) ...
instructions (equivalent to AND instructions without storing the result).
References
{{DEFAULTSORT:Negative Flag
Computer arithmetic