64,639
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main()
{
char* p = NULL;
char& q = *p;
p = new char;
*p = 'c';
printf("%c\n", q);
//char r = *p;
return 0;
}
_TEXT SEGMENT
_p$ = -4
_q$ = -8
$T587 = -12
_main PROC NEAR ; COMDAT
; 4 : {
push ebp
mov ebp, esp
sub esp, 76 ; 0000004cH
push ebx
push esi
push edi
lea edi, DWORD PTR [ebp-76]
mov ecx, 19 ; 00000013H
mov eax, -858993460 ; ccccccccH
rep stosd
; 5 : char* p = NULL;
mov DWORD PTR _p$[ebp], 0
; 6 : char& q = *p;
mov eax, DWORD PTR _p$[ebp]
mov DWORD PTR _q$[ebp], eax
; 7 :
; 8 : p = new char;
push 1
call ??2@YAPAXI@Z ; operator new
add esp, 4
mov DWORD PTR $T587[ebp], eax
mov ecx, DWORD PTR $T587[ebp]
mov DWORD PTR _p$[ebp], ecx
; 9 : *p = 'c';
mov edx, DWORD PTR _p$[ebp]
mov BYTE PTR [edx], 99 ; 00000063H
; 10 :
; 11 : printf("%c\n", q);
mov eax, DWORD PTR _q$[ebp]
movsx ecx, BYTE PTR [eax]
push ecx
push OFFSET FLAT:??_C@_03BNAH@?$CFc?6?$AA@ ; `string'
call _printf
add esp, 8
; 12 :
; 13 :
; 14 : //char r = *p;
; 15 :
; 16 : return 0;
xor eax, eax
; 17 : }
pop edi
pop esi
pop ebx
add esp, 76 ; 0000004cH
cmp ebp, esp
call __chkesp
mov esp, ebp
pop ebp
ret 0
_main ENDP
#include <stdio.h>
int main()
{
char* p = NULL;
p = new char;
*p = 'c';
char& q = *p;
printf("%c\n", q);
//char r = *p;
return 0;
}
_TEXT SEGMENT
_p$ = -4
_q$ = -8
$T587 = -12
_main PROC NEAR ; COMDAT
; 4 : {
push ebp
mov ebp, esp
sub esp, 76 ; 0000004cH
push ebx
push esi
push edi
lea edi, DWORD PTR [ebp-76]
mov ecx, 19 ; 00000013H
mov eax, -858993460 ; ccccccccH
rep stosd
; 5 : char* p = NULL;
mov DWORD PTR _p$[ebp], 0
; 6 :
; 7 : p = new char;
push 1
call ??2@YAPAXI@Z ; operator new
add esp, 4
mov DWORD PTR $T587[ebp], eax
mov eax, DWORD PTR $T587[ebp]
mov DWORD PTR _p$[ebp], eax
; 8 : *p = 'c';
mov ecx, DWORD PTR _p$[ebp]
mov BYTE PTR [ecx], 99 ; 00000063H
; 9 :
; 10 : char& q = *p;
mov edx, DWORD PTR _p$[ebp]
mov DWORD PTR _q$[ebp], edx
; 11 : printf("%c\n", q);
mov eax, DWORD PTR _q$[ebp]
movsx ecx, BYTE PTR [eax]
push ecx
push OFFSET FLAT:??_C@_03BNAH@?$CFc?6?$AA@ ; `string'
call _printf
add esp, 8
; 12 :
; 13 :
; 14 : //char r = *p;
; 15 :
; 16 : return 0;
xor eax, eax
; 17 : }
pop edi
pop esi
pop ebx
add esp, 76 ; 0000004cH
cmp ebp, esp
call __chkesp
mov esp, ebp
pop ebp
ret 0
_main ENDP