* remove "\r" nonsense
[mascara-docs.git] / i386 / i386.reference / PUSH.htm
blob69f45afe9c8765d56e4a8665318dc622605fb528
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Opcode PUSH</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="POPF.htm"> POPF/POPFD Pop Stack into FLAGS or EFLAGS Register</A><BR>
10 <B>next:</B><A HREF="PUSHA.htm"> PUSHA/PUSHAD Push all General Registers</A>
11 <P>
12 <HR>
13 <P>
14 <H1>PUSH -- Push Operand onto the Stack</H1>
16 <PRE>
17 Opcode Instruction Clocks Description
19 FF /6 PUSH m16 5 Push memory word
20 FF /6 PUSH m32 5 Push memory dword
21 50 + /r PUSH r16 2 Push register word
22 50 + /r PUSH r32 2 Push register dword
23 6A PUSH imm8 2 Push immediate byte
24 68 PUSH imm16 2 Push immediate word
25 68 PUSH imm32 2 Push immediate dword
26 0E PUSH CS 2 Push CS
27 16 PUSH SS 2 Push SS
28 1E PUSH DS 2 Push DS
29 06 PUSH ES 2 Push ES
30 0F A0 PUSH FS 2 Push FS
31 OF A8 PUSH GS 2 Push GS
32 </PRE>
35 <H2>Operation</H2>
37 <PRE>
38 IF StackAddrSize = 16
39 THEN
40 IF OperandSize = 16 THEN
41 SP := SP - 2;
42 (SS:SP) := (SOURCE); (* word assignment *)
43 ELSE
44 SP := SP - 4;
45 (SS:SP) := (SOURCE); (* dword assignment *)
46 FI;
47 ELSE (* StackAddrSize = 32 *)
48 IF OperandSize = 16
49 THEN
50 ESP := ESP - 2;
51 (SS:ESP) := (SOURCE); (* word assignment *)
52 ELSE
53 ESP := ESP - 4;
54 (SS:ESP) := (SOURCE); (* dword assignment *)
55 FI;
56 FI;
57 </PRE>
59 <H2>Description</H2>
61 PUSH decrements the stack pointer by 2 if the operand-size attribute of
62 the instruction is 16 bits; otherwise, it decrements the stack pointer by
63 4. PUSH then places the operand on the new top of stack, which is
64 pointed to by the stack pointer.
65 <P>
66 The 80386 PUSH eSP instruction pushes the value of eSP as it existed
67 before the instruction. This differs from the 8086, where PUSH SP
68 pushes the new value (decremented by 2).
70 <H2>Flags Affected</H2>
72 None
74 <H2>Protected Mode Exceptions</H2>
76 #SS(0) if the new value of SP or ESP is outside the stack segment limit;
77 #GP(0) for an illegal memory operand effective address in the CS, DS,
78 ES, FS, or GS segments; #SS(0) for an illegal address in the SS segment;
79 #PF(fault-code) for a page fault
81 <H2>Real Address Mode Exceptions</H2>
83 None; if SP or ESP is 1, the 80386 shuts down due to a lack of stack
84 space
86 <H2>Virtual 8086 Mode Exceptions</H2>
88 Same exceptions as in real-address mode; #PF(fault-code) for a page
89 fault
92 <P>
93 <HR>
94 <P>
95 <B>up:</B> <A HREF="c17.htm">
96 Chapter 17 -- 80386 Instruction Set</A><BR>
97 <B>prev:</B><A HREF="POPF.htm"> POPF/POPFD Pop Stack into FLAGS or EFLAGS Register</A><BR>
98 <B>next:</B><A HREF="PUSHA.htm"> PUSHA/PUSHAD Push all General Registers</A>
99 </BODY>