#include <stdio.h>
int main()
{
const char* p = "feng123";
puts(p);
const char* s[] = { "有男朋友吗?","多喝热水","吃饭了没?" };
for (int i = 0; i < 3; i++) {
printf("%s\n", s[i]);
}
return 0;
}
debug下
#include <stdio.h>
int main()
{
00007FF67C2D3FB0 40 55 push rbp
00007FF67C2D3FB2 57 push rdi
00007FF67C2D3FB3 48 81 EC 58 01 00 00 sub rsp,158h
00007FF67C2D3FBA 48 8D 6C 24 20 lea rbp,[rsp+20h]
00007FF67C2D3FBF 48 8D 7C 24 20 lea rdi,[rsp+20h]
00007FF67C2D3FC4 B9 1E 00 00 00 mov ecx,1Eh
00007FF67C2D3FC9 B8 CC CC CC CC mov eax,0CCCCCCCCh
00007FF67C2D3FCE F3 AB rep stos dword ptr [rdi]
00007FF67C2D3FD0 48 8D 0D 2C D0 00 00 lea rcx,[__6663462F_ConsoleApplication2@cpp (07FF67C2E1003h)]
00007FF67C2D3FD7 E8 67 D3 FF FF call __CheckForDebuggerJustMyCode (07FF67C2D1343h)
const char* p = "feng123";
00007FF67C2D3FDC 48 8D 05 CD 5B 00 00 lea rax,[string "feng123" (07FF67C2D9BB0h)]
00007FF67C2D3FE3 48 89 45 08 mov qword ptr [p],rax
puts(p);
00007FF67C2D3FE7 48 8B 4D 08 mov rcx,qword ptr [p]
00007FF67C2D3FEB FF 15 07 C3 00 00 call qword ptr [__imp_puts (07FF67C2E02F8h)]
const char* s[] = { "有男朋友吗?","多喝热水","吃饭了没?" };
00007FF67C2D3FF1 48 8D 05 90 5D 00 00 lea rax,[string "\xd3\xd0\xc4\xd0\xc5\xf3\xd3\xd1\xc2\xf0?" (07FF67C2D9D88h)]
00007FF67C2D3FF8 48 89 45 28 mov qword ptr [s],rax
00007FF67C2D3FFC 48 8D 05 95 5D 00 00 lea rax,[string "\xb6\xe0\xba\xc8\xc8\xc8\xcb\xae" (07FF67C2D9D98h)]
00007FF67C2D4003 48 89 45 30 mov qword ptr [rbp+30h],rax
00007FF67C2D4007 48 8D 05 82 5E 00 00 lea rax,[string "\xb3\xd4\xb7\xb9\xc1\xcb\xc3\xbb?" (07FF67C2D9E90h)]
00007FF67C2D400E 48 89 45 38 mov qword ptr [rbp+38h],rax
for (int i = 0; i < 3; i++) {
00007FF67C2D4012 C7 45 54 00 00 00 00 mov dword ptr [rbp+54h],0
00007FF67C2D4019 EB 08 jmp __$EncStackInitStart+64h (07FF67C2D4023h)
00007FF67C2D401B 8B 45 54 mov eax,dword ptr [rbp+54h]
00007FF67C2D401E FF C0 inc eax
00007FF67C2D4020 89 45 54 mov dword ptr [rbp+54h],eax
00007FF67C2D4023 83 7D 54 03 cmp dword ptr [rbp+54h],3
00007FF67C2D4027 7D 17 jge __$EncStackInitStart+81h (07FF67C2D4040h)
printf("%s\n", s[i]);
00007FF67C2D4029 48 63 45 54 movsxd rax,dword ptr [rbp+54h]
00007FF67C2D402D 48 8B 54 C5 28 mov rdx,qword ptr s[rax*8]
00007FF67C2D4032 48 8D 0D 7F 5B 00 00 lea rcx,[string "%s\n" (07FF67C2D9BB8h)]
00007FF67C2D4039 E8 69 D3 FF FF call printf (07FF67C2D13A7h)
}
00007FF67C2D403E EB DB jmp __$EncStackInitStart+5Ch (07FF67C2D401Bh)
return 0;
00007FF67C2D4040 33 C0 xor eax,eax
}
realease 版本
#include <stdio.h>
int main()
{
00007FF753F81070 40 53 push rbx
00007FF753F81072 48 83 EC 40 sub rsp,40h
const char* p = "feng123";
puts(p);
00007FF753F81076 48 8D 0D C3 11 00 00 lea rcx,[string "feng123" (07FF753F82240h)]
00007FF753F8107D FF 15 F5 10 00 00 call qword ptr [__imp_puts (07FF753F82178h)]
const char* s[] = { "有男朋友吗?","多喝热水","吃饭了没?" };
00007FF753F81083 48 8D 05 BE 11 00 00 lea rax,[string "\xd3\xd0\xc4\xd0\xc5\xf3\xd3\xd1\xc2\xf0?" (07FF753F82248h)]
00007FF753F8108A 33 DB xor ebx,ebx
00007FF753F8108C 48 89 44 24 20 mov qword ptr [s],rax
00007FF753F81091 48 8D 05 C0 11 00 00 lea rax,[string "\xb6\xe0\xba\xc8\xc8\xc8\xcb\xae" (07FF753F82258h)]
00007FF753F81098 48 89 44 24 28 mov qword ptr [rsp+28h],rax
00007FF753F8109D 48 8D 05 C4 11 00 00 lea rax,[string "\xb3\xd4\xb7\xb9\xc1\xcb\xc3\xbb?" (07FF753F82268h)]
00007FF753F810A4 48 89 44 24 30 mov qword ptr [rsp+30h],rax
00007FF753F810A9 0F 1F 80 00 00 00 00 nop dword ptr [rax]
for (int i = 0; i < 3; i++) {
printf("%s\n", s[i]);
00007FF753F810B0 48 8B 54 DC 20 mov rdx,qword ptr s[rbx*8]
00007FF753F810B5 48 8D 0D B8 11 00 00 lea rcx,[string "%s\n" (07FF753F82274h)]
00007FF753F810BC E8 4F FF FF FF call printf (07FF753F81010h)
00007FF753F810C1 48 FF C3 inc rbx
00007FF753F810C4 48 83 FB 03 cmp rbx,3
00007FF753F810C8 7C E6 jl main+40h (07FF753F810B0h)
}
return 0;
00007FF753F810CA 33 C0 xor eax,eax
}
00007FF753F810CC 48 83 C4 40 add rsp,40h
00007FF753F810D0 5B pop rbx
在wsl下 ubuntu中
gcc -S -masm=intel points1.c
.file "points1.c"
.intel_syntax noprefix
.text
.section .rodata
.LC0:
.string "feng123"
.LC1:
.string "\346\234\211\347\224\267\346\234\213\345\217\213\345\220\227?"
.LC2:
.string "\345\244\232\345\226\235\347\203\255\346\260\264"
.LC3:
.string "\345\220\203\351\245\255\344\272\206\346\262\241?"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
endbr64
push rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
mov rbp, rsp
.cfi_def_cfa_register 6
sub rsp, 48
mov rax, QWORD PTR fs:40
mov QWORD PTR -8[rbp], rax
xor eax, eax
lea rax, .LC0[rip]
mov QWORD PTR -40[rbp], rax
mov rax, QWORD PTR -40[rbp]
mov rdi, rax
call puts@PLT
lea rax, .LC1[rip]
mov QWORD PTR -32[rbp], rax
lea rax, .LC2[rip]
mov QWORD PTR -24[rbp], rax
lea rax, .LC3[rip]
mov QWORD PTR -16[rbp], rax
mov DWORD PTR -44[rbp], 0
jmp .L2
.L3:
mov eax, DWORD PTR -44[rbp]
cdqe
mov rax, QWORD PTR -32[rbp+rax*8]
mov rdi, rax
call puts@PLT
add DWORD PTR -44[rbp], 1
.L2:
cmp DWORD PTR -44[rbp], 2
jle .L3
mov eax, 0
mov rdx, QWORD PTR -8[rbp]
xor rdx, QWORD PTR fs:40
je .L5
call __stack_chk_fail@PLT
.L5:
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu 9.3.0-10ubuntu2) 9.3.0"
.section .note.GNU-stack,"",@progbits
.section .note.gnu.property,"a"
.align 8
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.align 8
.long 0xc0000002
.long 3f - 2f
2:
.long 0x3
3:
.align 8
4:
网友评论