Mail Archives: djgpp/2001/05/07/12:35:47
From: | Michiel de Bondt <michielb AT sci DOT kun DOT nl>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | how to use inline push and pop
|
Date: | Mon, 07 May 2001 16:25:52 +0200
|
Organization: | University of Nijmegen
|
Lines: | 210
|
Message-ID: | <3AF6B070.D006EAC1@sci.kun.nl>
|
NNTP-Posting-Host: | fanth.sci.kun.nl
|
Mime-Version: | 1.0
|
X-Trace: | wnnews.sci.kun.nl 989245552 12873 131.174.132.54 (7 May 2001 14:25:52 GMT)
|
X-Complaints-To: | usenet AT sci DOT kun DOT nl
|
NNTP-Posting-Date: | Mon, 7 May 2001 14:25:52 +0000 (UTC)
|
X-Mailer: | Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u)
|
X-Accept-Language: | en
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
This is a multi-part message in MIME format.
--------------96A10C171147CEFCA9A7BBD0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello DJGPP-users,
I made some macro's to push and pop registers, but it did not work when
I optimized the code. So I used __volatile__ and the compile option
-fno-defer-pop. But in the program below, the pop after a call to printf
is still deferred. How to solve this problem? It is quite convenient to
use push and pop macros in your code, e.g. to make replacements of call
and ret with computed gotos.
Best regards,
Michiel de Bondt
--------------96A10C171147CEFCA9A7BBD0
Content-Type: text/plain; charset=us-ascii;
name="defer.lst"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="defer.lst"
GAS LISTING c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s page 1
1 .file "defer.cpp"
2 gcc2_compiled.:
3 ___gnu_compiled_cplusplus:
4 .text
19 LC0:
20 0000 48656C6C .ascii "Hello world!\12\0"
20 6F20776F
20 726C6421
20 0A00
21 000e 89F6 .p2align 2
23 .globl _main
24 _main:
25 LFB1:
1:defer.cpp **** #include <stdio.h>
2:defer.cpp ****
3:defer.cpp **** int main ()
4:defer.cpp **** {
5:defer.cpp **** register int a = 0, b = 1, c = 2, d = 3, S = 4, D = 5;
34 0010 55 pushl %ebp
35 LCFI0:
36 0011 89E5 movl %esp,%ebp
37 LCFI1:
38 0013 83EC0C subl $12,%esp
39 LCFI2:
40 0016 57 pushl %edi
41 LCFI3:
42 0017 56 pushl %esi
43 LCFI4:
44 0018 53 pushl %ebx
45 LCFI5:
46 0019 31C0 xorl %eax,%eax
47 001b BB010000 movl $1,%ebx
47 00
48 0020 B9020000 movl $2,%ecx
48 00
49 0025 BA030000 movl $3,%edx
49 00
50 002a BE040000 movl $4,%esi
50 00
51 002f BF050000 movl $5,%edi
51 00
6:defer.cpp **** asm volatile ("pushal" : : "a" (a), "b" (b), "c" (c),
7:defer.cpp **** "d" (d), "S" (S), "D" (D));
53 /APP
54 0034 60 pushal
55 /NO_APP
8:defer.cpp **** printf ("Hello world!\n");
57 0035 83C4F4 addl $-12,%esp
58 0038 68000000 pushl $LC0
58 00
59 LCFI6:
60 003d E8BEFFFF call _printf
60 FF
9:defer.cpp **** // "addl $16, %esp" deferred
10:defer.cpp **** asm volatile ("popal" : "=a" (a), "=b" (b), "=c" (c),
11:defer.cpp **** "=d" (d), "=S" (S), "=D" (D));
62 /APP
GAS LISTING c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s page 2
63 0042 61 popal
64 /NO_APP
12:defer.cpp **** // wrong value of "%ebp" results in an error
13:defer.cpp **** return (a);
66 0043 8D65E8 leal -24(%ebp),%esp
67 0046 5B popl %ebx
68 0047 5E popl %esi
69 0048 5F popl %edi
70 0049 89EC movl %ebp,%esp
71 004b 5D popl %ebp
72 004c C3 ret
14:defer.cpp **** }
76 LFE1:
77
78 004d 8D7600 .section .eh_frame
79 ___FRAME_BEGIN__:
80 0000 10000000 .long LLCIE1
81
82 LSCIE1:
83 0004 00000000 .long 0
84
85 0008 01 .byte 0x1
86 0009 00 .byte 0x0
87 000a 01 .byte 0x1
88 000b 7C .byte 0x7c
89 000c 08 .byte 0x8
90 000d 0C .byte 0xc
91 000e 05 .byte 0x5
92 000f 04 .byte 0x4
93 0010 88 .byte 0x88
94 0011 01 .byte 0x1
95 0012 0000 .p2align 2,0
96 LECIE1:
97 .set LLCIE1,LECIE1-LSCIE1
98 0014 38000000 .long LLFDE1
99
100 LSFDE1:
101 0018 18000000 .long LSFDE1-___FRAME_BEGIN__
102
103 001c 10000000 .long LFB1
104
105 0020 3D000000 .long LFE1-LFB1
106
107 0024 04 .byte 0x4
108 0025 01000000 .long LCFI0-LFB1
109
110 0029 0E .byte 0xe
111 002a 08 .byte 0x8
112 002b 84 .byte 0x84
113 002c 02 .byte 0x2
114 002d 04 .byte 0x4
115 002e 02000000 .long LCFI1-LCFI0
116
117 0032 0D .byte 0xd
118 0033 04 .byte 0x4
119 0034 04 .byte 0x4
120 0035 04000000 .long LCFI3-LCFI1
GAS LISTING c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s page 3
121
122 0039 87 .byte 0x87
123 003a 06 .byte 0x6
124 003b 04 .byte 0x4
125 003c 01000000 .long LCFI4-LCFI3
126
127 0040 86 .byte 0x86
128 0041 07 .byte 0x7
129 0042 04 .byte 0x4
130 0043 01000000 .long LCFI5-LCFI4
131
132 0047 83 .byte 0x83
133 0048 08 .byte 0x8
134 0049 04 .byte 0x4
135 004a 24000000 .long LCFI6-LCFI5
136
137 004e 2E .byte 0x2e
138 004f 10 .byte 0x10
139 .p2align 2,0
140 LEFDE1:
141 .set LLFDE1,LEFDE1-LSFDE1
GAS LISTING c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s page 4
DEFINED SYMBOLS
c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s:2 e0:00000000 gcc2_compiled.
c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s:3 e0:00000000 ___gnu_compiled_cplusplus
absolute:00000000 __cnt
absolute:00000004 __ptr
absolute:00000008 __base
absolute:0000000c __bufsiz
absolute:00000010 __flag
absolute:00000014 __file
absolute:00000018 __name_to_remove
absolute:0000001c __fillsize
absolute:00000020 .eos
c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s:24 e0:00000010 _main
c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s:26 e0:00000010 .bf
absolute:00000000 _a
absolute:00000003 _b
absolute:00000001 _c
absolute:00000002 _d
absolute:00000006 _S
absolute:00000007 _D
c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s:74 e0:0000004d .ef
c:/diversen/progtaal/djgpp/tmp/RH2eaaaa\cc4oHynQ.s:79 e3:00000050 ___FRAME_BEGIN__
e0:00000000 .text
e1:00000050 .data
e2:00000050 .bss
e3:00000050 .eh_frame
UNDEFINED SYMBOLS
_printf
--------------96A10C171147CEFCA9A7BBD0--
- Raw text -