int ch = '1';
00291838 mov dword ptr [ch],31h
if('a' <= ch <= 'z') printf("hello\n");
0029183F cmp dword ptr [ch],61h
00291843 jl main+41h (0291851h)
00291845 mov dword ptr [ebp-0D0h],1
0029184F jmp main+4Bh (029185Bh)
00291851 mov dword ptr [ebp-0D0h],0
0029185B cmp dword ptr [ebp-0D0h],7Ah
00291862 jg main+61h (0291871h)
00291864 push offset string "hello\n" (0297B30h)
00291869 call _printf (0291046h)
0029186E add esp,4
在gcc中直接优化掉了这个判断,因为永远为真,没有判断的必要 .file "main.c"
.text
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "hello\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
call ___main
movl $49, 28(%esp)
movl $LC0, (%esp)
call _puts
movl $0, %eax
leave
ret
.ident "GCC: (GNU) 7.4.0"
.def _puts; .scl 2; .type 32; .endef
#include <stdio.h>
#include <string.h>
int main(void)
{
int ch = '1';
if('a' <= ch <= 'z') printf("hello\n");
return 0;
}
|