1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML 2.0//EN">
4 <TITLE>80386 Programmer's Reference Manual -- Opcode BTS
</TITLE>
7 <B>up:
</B> <A HREF=
"c17.htm">
8 Chapter
17 --
80386 Instruction Set
</A><BR>
9 <B>prev:
</B><A HREF=
"BTR.htm"> BTR Bit Test and Reset
</A><BR>
10 <B>next:
</B><A HREF=
"CALL.htm"> CALL Call Procedure
</A>
14 <H1>BTS -- Bit Test and Set
</H1>
17 Opcode Instruction Clocks Description
19 0F AB BTS r/m16,r16
6/
13 Save bit in carry flag and set
20 0F AB BTS r/m32,r32
6/
13 Save bit in carry flag and set
21 0F BA /
5 ib BTS r/m16,imm8
6/
8 Save bit in carry flag and set
22 0F BA /
5 ib BTS r/m32,imm8
6/
8 Save bit in carry flag and set
28 CF := BIT[LeftSRC, RightSRC];
29 BIT[LeftSRC, RightSRC] :=
1;
34 BTS saves the value of the bit indicated by the base (first operand) and the
35 bit offset (second operand) into the carry flag and then stores
1 in the
38 <H2>Flags Affected
</H2>
42 <H2>Protected Mode Exceptions
</H2>
44 #GP(
0) if the result is in a nonwritable segment; #GP(
0) for an illegal
45 memory operand effective address in the CS, DS, ES, FS, or GS segments;
46 #SS(
0) for an illegal address in the SS segment; #PF(fault-code) for a page
49 <H2>Real Address Mode Exceptions
</H2>
51 Interrupt
13 if any part of the operand would lie outside of the effective
52 address space from
0 to
0FFFFH
54 <H2>Virtual
8086 Mode Exceptions
</H2>
56 Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault
60 The index of the selected bit can be given by the immediate constant in the
61 instruction or by a value in a general register. Only an
8-bit immediate
62 value is used in the instruction. This operand is taken modulo
32, so the
63 range of immediate bit offsets is
0.
.31. This allows any bit within a
64 register to be selected. For memory bit strings, this immediate field gives
65 only the bit offset within a word or doubleword. Immediate bit offsets
66 larger than
31 are supported by using the immediate bit offset field in
67 combination with the displacement field of the memory operand. The
68 low-order
3 to
5 bits of the immediate bit offset are stored in the
69 immediate bit offset field, and the high order
27 to
29 bits are shifted and
70 combined with the byte displacement in the addressing mode.
72 When accessing a bit in memory, the processor may access four bytes starting
73 from the memory address given by:
75 Effective Address + (
4 * (BitOffset DIV
32))
77 for a
32-bit operand size, or two bytes starting from the memory address
80 Effective Address + (
2 * (BitOffset DIV
16))
82 for a
16-bit operand size. It may do this even when only a single byte needs
83 to be accessed in order to get at the given bit. Thus the programmer must be
84 careful to avoid referencing areas of memory close to address space holes.
85 In particular, avoid references to memory-mapped I/O registers. Instead, use
86 the
<A HREF=
"MOV.htm">MOV
</A>
87 instructions to load from or store to these addresses, and use the
88 register form of these instructions to manipulate the data.
94 <B>up:
</B> <A HREF=
"c17.htm">
95 Chapter
17 --
80386 Instruction Set
</A><BR>
96 <B>prev:
</B><A HREF=
"BTR.htm"> BTR Bit Test and Reset
</A><BR>
97 <B>next:
</B><A HREF=
"CALL.htm"> CALL Call Procedure
</A>