forked from ttmo-O/x86-manpages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbsf.x86
More file actions
155 lines (141 loc) · 4.1 KB
/
bsf.x86
File metadata and controls
155 lines (141 loc) · 4.1 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
'\" t
.nh
.TH "X86-BSF" "7" "May 2019" "TTMO" "Intel x86-64 ISA Manual"
.SH NAME
BSF - BIT SCAN FORWARD
.TS
allbox;
l l l l l l
l l l l l l .
\fBOpcode\fP \fBInstruction\fP \fBOp/En\fP \fB64-bit Mode\fP \fBCompat/Leg Mode\fP \fBDescription\fP
0F BC /r BSF r16, r/m16 RM Valid Valid Bit scan forward on r/m16.
0F BC /r BSF r32, r/m32 RM Valid Valid Bit scan forward on r/m32.
REX.W + 0F BC /r BSF r64, r/m64 RM Valid N.E. Bit scan forward on r/m64.
.TE
.SH INSTRUCTION OPERAND ENCODING
.TS
allbox;
l l l l l
l l l l l .
\fBOp/En\fP \fBOperand 1\fP \fBOperand 2\fP \fBOperand 3\fP \fBOperand 4\fP
RM ModRM:reg (w) ModRM:r/m (r) N/A N/A
.TE
.SH DESCRIPTION
Searches the source operand (second operand) for the least significant
set bit (1 bit). If a least significant 1 bit is found, its bit index is
stored in the destination operand (first operand). The source operand
can be a register or a memory location; the destination operand is a
register. The bit index is an unsigned offset from bit 0 of the source
operand. If the content of the source operand is 0, the content of the
destination operand is undefined.
.PP
In 64-bit mode, the instruction’s default operation size is 32 bits.
Using a REX prefix in the form of REX.R permits access to additional
registers (R8-R15). Using a REX prefix in the form of REX.W promotes
operation to 64 bits. See the summary chart at the beginning of this
section for encoding data and limits.
.SH OPERATION
.EX
IF SRC = 0
THEN
ZF := 1;
DEST is undefined;
ELSE
ZF := 0;
temp := 0;
WHILE Bit(SRC, temp) = 0
DO
temp := temp + 1;
OD;
DEST := temp;
FI;
.EE
.SH FLAGS AFFECTED
The ZF flag is set to 1 if the source operand is 0; otherwise, the ZF
flag is cleared. The CF, OF, SF, AF, and PF flags are undefined.
.SH PROTECTED MODE EXCEPTIONS
.TS
allbox;
l l
l l .
\fB\fP \fB\fP
#GP(0) T{
If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
T}
T{
If the DS, ES, FS, or GS register contains a NULL segment selector.
T}
#SS(0) T{
If a memory operand effective address is outside the SS segment limit.
T}
#PF(fault-code) If a page fault occurs.
#AC(0) T{
If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.
T}
#UD If the LOCK prefix is used.
.TE
.SH REAL-ADDRESS MODE EXCEPTIONS
.TS
allbox;
l l
l l .
\fB\fP \fB\fP
#GP T{
If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
T}
#SS T{
If a memory operand effective address is outside the SS segment limit.
T}
#UD If the LOCK prefix is used.
.TE
.SH VIRTUAL-8086 MODE EXCEPTIONS
.TS
allbox;
l l
l l .
\fB\fP \fB\fP
#GP(0) T{
If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
T}
#SS(0) T{
If a memory operand effective address is outside the SS segment limit.
T}
#PF(fault-code) If a page fault occurs.
#AC(0) T{
If alignment checking is enabled and an unaligned memory reference is made.
T}
#UD If the LOCK prefix is used.
.TE
.SH COMPATIBILITY MODE EXCEPTIONS
Same exceptions as in protected mode.
.SH 64-BIT MODE EXCEPTIONS
.TS
allbox;
l l
l l .
\fB\fP \fB\fP
#SS(0) T{
If a memory address referencing the SS segment is in a non-canonical form.
T}
#GP(0) T{
If the memory address is in a non-canonical form.
T}
#PF(fault-code) If a page fault occurs.
#AC(0) T{
If alignment checking is enabled and an unaligned memory reference is made while the current privilege level is 3.
T}
#UD If the LOCK prefix is used.
.TE
.SH SEE ALSO
x86-manpages(7) for a list of other x86-64 man pages.
.SH COLOPHON
This UNOFFICIAL, mechanically-separated, non-verified reference is
provided for convenience, but it may be
incomplete or
broken in various obvious or non-obvious ways.
Refer to Intel® 64 and IA-32 Architectures Software Developer’s Manual
for anything serious.
.br
This page is generated by scripts; therefore may contain visual or semantical bugs. Please report them (or better, fix them) on https://github.com/ttmo-O/x86-manpages.
.br
MIT licensed by TTMO 2025 (Turkish Unofficial Chamber of Reverse Engineers - https://ttmo.re).