* better
[mascara-docs.git] / hw / i386.reference / BTS.htm
blob51474ffa10725a65616f2ab6dcb1b33d3f9d1d32
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Opcode BTS</TITLE>
5 </HEAD>
6 <BODY>
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>
11 <P>
12 <HR>
13 <P>
14 <H1>BTS -- Bit Test and Set</H1>
16 <PRE>
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
23 </PRE>
25 <H2>Operation</H2>
27 <PRE>
28 CF := BIT[LeftSRC, RightSRC];
29 BIT[LeftSRC, RightSRC] := 1;
30 </PRE>
32 <H2>Description</H2>
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
36 bit.
38 <H2>Flags Affected</H2>
40 CF as described above
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
47 fault
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
58 <H2>Notes</H2>
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.
71 <P>
72 When accessing a bit in memory, the processor may access four bytes starting
73 from the memory address given by:
74 <PRE>
75 Effective Address + (4 * (BitOffset DIV 32))
76 </PRE>
77 for a 32-bit operand size, or two bytes starting from the memory address
78 given by:
79 <PRE>
80 Effective Address + (2 * (BitOffset DIV 16))
81 </PRE>
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.
91 <P>
92 <HR>
93 <P>
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>
98 </BODY>