jal wrote:darkstart wrote:Code: Select all
mov DWORD PTR [%esp+12], %eax
or DWORD PTR [%esp+12], -2147483648
mov %eax, DWORD PTR [%esp+12]
What I find rather weird, other than you seemingly not having heard of two's complement, is that the disassembled code shows no sign of cr0 (using eax instead), where your inline assembly code implies there should be. I'm not to sure about inline assembly AT&T-style, but surely something goes wrong there.
JAL
I've heard of it, just never actually used it before. I think the DWORD PTR [%esp+12] is a pointer to the cr0 register.
As for the object dump, here's the cross-compiler's code:
Code: Select all
0000036e <switch_page_dir>:
36e: 83 ec 10 sub $0x10,%esp
371: 8b 44 24 14 mov 0x14(%esp),%eax
375: a3 00 00 00 00 mov %eax,0x0
37a: 8b 44 24 14 mov 0x14(%esp),%eax
37e: 05 00 10 00 00 add $0x1000,%eax
383: 0f 22 d8 mov %eax,%cr3
386: 0f 20 c0 mov %cr0,%eax
389: 89 44 24 0c mov %eax,0xc(%esp)
38d: 81 4c 24 0c 00 00 00 orl $0x80000000,0xc(%esp)
394: 80
395: 8b 44 24 0c mov 0xc(%esp),%eax
399: 0f 22 c0 mov %eax,%cr0
39c: 83 c4 10 add $0x10,%esp
39f: c3 ret
And here is the generic compiler's:
Code: Select all
00000383 <switch_page_dir>:
383: 83 ec 10 sub $0x10,%esp
386: 8b 44 24 14 mov 0x14(%esp),%eax
38a: a3 00 00 00 00 mov %eax,0x0
38f: 8b 44 24 14 mov 0x14(%esp),%eax
393: 05 00 10 00 00 add $0x1000,%eax
398: 0f 22 d8 mov %eax,%cr3
39b: 0f 20 c0 mov %cr0,%eax
39e: 89 44 24 0c mov %eax,0xc(%esp)
3a2: 81 4c 24 0c 00 00 00 orl $0x80000000,0xc(%esp)
3a9: 80
3aa: 8b 44 24 0c mov 0xc(%esp),%eax
3ae: 0f 22 c0 mov %eax,%cr0
3b1: 83 c4 10 add $0x10,%esp
3b4: c3 ret
I used the generic objdump on both. If I used the wrong flag on objdump(-S), tell me and I apologize in advance. I haven't used it but a few times before.