forked from NJU-ProjectN/i386-manual
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSHRD.htm
105 lines (89 loc) · 3.52 KB
/
SHRD.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
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>80386 Programmer's Reference Manual -- Opcode SHRD</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="SHLD.htm"> SHLD Double Precision Shift Left</A><BR>
<B>next:</B><A HREF="SLDT.htm"> SLDT Store Local Descriptor Table Register</A>
<P>
<HR>
<P>
<H1>SHRD -- Double Precision Shift Right</H1>
<PRE>
Opcode Instruction Clocks Description
0F AC SHRD r/m16,r16,imm8 3/7 r/m16 gets SHR of r/m16 concatenated
with r16
0F AC SHRD r/m32,r32,imm8 3/7 r/m32 gets SHR of r/m32 concatenated
with r32
0F AD SHRD r/m16,r16,CL 3/7 r/m16 gets SHR of r/m16 concatenated
with r16
0F AD SHRD r/m32,r32,CL 3/7 r/m32 gets SHR of r/m32 concatenated
with r32
</PRE>
<H2>Operation</H2>
<PRE>
(* count is an unsigned integer corresponding to the last operand of the
instruction, either an immediate byte or the byte in register CL *)
ShiftAmt := count MOD 32;
inBits := register; (* Allow overlapped operands *)
IF ShiftAmt = 0
THEN no operation
ELSE
IF ShiftAmt >= OperandSize
THEN (* Bad parameters *)
r/m := UNDEFINED;
CF, OF, SF, ZF, AF, PF := UNDEFINED;
ELSE (* Perform the shift *)
CF := BIT[r/m, ShiftAmt - 1]; (* last bit shifted out on exit *)
FOR i := 0 TO OperandSize - 1 - ShiftAmt
DO
BIT[r/m, i] := BIT[r/m, i - ShiftAmt];
OD;
FOR i := OperandSize - ShiftAmt TO OperandSize - 1
DO
BIT[r/m,i] := BIT[inBits,i+ShiftAmt - OperandSize];
OD;
Set SF, ZF, PF (r/m);
(* SF, ZF, PF are set according to the value of the result *)
Set SF, ZF, PF (r/m);
AF := UNDEFINED;
FI;
FI;
</PRE>
<H2>Description</H2>
SHRD shifts the first operand provided by the r/m field to the right as many
bits as specified by the count operand. The second operand (r16 or r32)
provides the bits to shift in from the left (starting with bit 31). The
result is stored back into the r/m operand. The register remains unaltered.
<P>
The count operand is provided by either an immediate byte or the contents
of the CL register. These operands are taken MODULO 32 to provide a number
between 0 and 31 by which to shift. Because the bits to shift are provided
by the specified register, the operation is useful for multi-precision
shifts (64 bits or more). The SF, ZF and PF flags are set according to the
value of the result. CF is set to the value of the last bit shifted out. OF
and AF are left undefined.
<H2>Flags Affected</H2>
SF, ZF, PF, and CF as described above; AF and OF are undefined
<H2>Protected Mode Exceptions</H2>
#GP(0) if the result is in a nonwritable segment; #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
<P>
<HR>
<P>
<B>up:</B> <A HREF="c17.htm">
Chapter 17 -- 80386 Instruction Set</A><BR>
<B>prev:</B><A HREF="SHLD.htm"> SHLD Double Precision Shift Left</A><BR>
<B>next:</B><A HREF="SLDT.htm"> SLDT Store Local Descriptor Table Register</A>
</BODY>