-
Notifications
You must be signed in to change notification settings - Fork 29
/
BT.htm
95 lines (77 loc) · 3.16 KB
/
BT.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>80386 Programmer's Reference Manual -- Opcode BT</TITLE>
</HEAD>
<BODY STYLE="width:80ch">
<B>up:</B> <A HREF="c17.htm">
Chapter 17 -- 80386 Instruction Set</A><BR>
<B>prev:</B><A HREF="BSR.htm"> BSR Bit Scan Reverse</A><BR>
<B>next:</B><A HREF="BTC.htm"> BTC Bit Test and Complement</A>
<P>
<HR>
<P>
<H1>BT -- Bit Test</H1>
<PRE>
Opcode Instruction Clocks Description
0F A3 BT r/m16,r16 3/12 Save bit in carry flag
0F A3 BT r/m32,r32 3/12 Save bit in carry flag
0F BA /4 ib BT r/m16,imm8 3/6 Save bit in carry flag
0F BA /4 ib BT r/m32,imm8 3/6 Save bit in carry flag
</PRE>
<H2>Operation</H2>
<PRE>
CF := BIT[LeftSRC, RightSRC];
</PRE>
<H2>Description</H2>
BT saves the value of the bit indicated by the base (first operand) and the
bit offset (second operand) into the carry flag.
<H2>Flags Affected</H2>
CF as described above
<H2>Protected Mode Exceptions</H2>
#GP(0) for an illegal memory operand effective address in the CS, DS, ES,
FS, or GS segments; #SS(0) for an illegal address in the SS segment;
#PF(fault-code) for a page fault
<H2>Real Address Mode Exceptions</H2>
Interrupt 13 if any part of the operand would lie outside of the effective
address space from 0 to 0FFFFH
<H2>Virtual 8086 Mode Exceptions</H2>
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault
<H2>Notes</H2>
The index of the selected bit can be given by the immediate constant in the
instruction or by a value in a general register. Only an 8-bit immediate
value is used in the instruction. This operand is taken modulo 32, so the
range of immediate bit offsets is 0..31. This allows any bit within a
register to be selected. For memory bit strings, this immediate field gives
only the bit offset within a word or doubleword. Immediate bit offsets
larger than 31 are supported by using the immediate bit offset field in
combination with the displacement field of the memory operand. The low-order
3 to 5 bits of the immediate bit offset are stored in the immediate bit
offset field, and the high-order 27 to 29 bits are shifted and combined with
the byte displacement in the addressing mode.
<P>
When accessing a bit in memory, the 80386 may access four bytes starting
from the memory address given by:
<PRE>
Effective Address + (4 * (BitOffset DIV 32))
</PRE>
for a 32-bit operand size, or two bytes starting from the memory address
given by:
<PRE>
Effective Address + (2 * (BitOffset DIV 16))
</PRE>
for a 16-bit operand size. It may do so even when only a single byte needs
to be accessed in order to reach the given bit. You must therefore avoid
referencing areas of memory close to address space holes. In particular,
avoid references to memory-mapped I/O registers. Instead, use the
<A HREF="MOV.htm">MOV</A>
instructions to load from or store to these addresses, and use the register
form of these instructions to manipulate the data.
<P>
<HR>
<P>
<B>up:</B> <A HREF="c17.htm">
Chapter 17 -- 80386 Instruction Set</A><BR>
<B>prev:</B><A HREF="BSR.htm"> BSR Bit Scan Reverse</A><BR>
<B>next:</B><A HREF="BTC.htm"> BTC Bit Test and Complement</A>
</BODY>