delphi的控制台语句是
write
和writeln
od反编译一下delphi生成的exe write('hello world');
0040820D ? BA 40824000 mov edx,Project2.00408240 ; hello world
00408212 ? E8 D9BCFFFF call Project2.00403EF0
00408217 ? E8 BCA7FFFF call Project2.004029D8 ;;以上两行输出字符串hello world.
下列四行代码存储 hello world 字符串。
00408240 ? 68 656C6C6F push 6F6C6C65
00408245 ? 2077 6F and byte ptr ds:[edi+6F],dh
00408248 ? 72 6C jb short Project2.004082B6
0040824A ? 64:0000 add byte ptr fs:[eax],al
writeln: wrilteln('hello world');
00408255 . BA 88824000 mov edx,Project2.00408288 ; ASCII "hello world"
0040825A . E8 D9BCFFFF call Project2.00403F38
0040825F . E8 98AAFFFF call Project2.00402CFC
00408264 . E8 C3A3FFFF call Project2.0040262C
00408288 . 68 65 6C 6C 6>ascii "hello world",0 ;该地址是hello world的指针。
VC++的
printf: printf("hello world");
00401028 |. 68 1C204200 push 121.0042201C ; /hello world
0040102D |. E8 3E000000 call 121.printf ; \printf
引用地址:
0042201C 68 656C6C6F push 0x6F6C6C65
00422021 2077 6F and byte ptr ds:[edi+0x6F],dh
00422024 72 6C jb X121.00422092
00422026 64:0000 add byte ptr fs:[eax],al
printf("%d",1);
00401032 |. 83C4 04 add esp,0x4
00401035 |. 6A 01 push 0x1
00401037 |. 68 1C204200 push 121.0042201C ; ASCII "%d"
0040103C |? E8 2F000000 call 121.printf
引用地址:
0042201C 25 64000068 and eax,0x68000064 ;;25 64 即 %d
printf("%s,%s,%s","A","Bc","DEF");
00401028 |. 68 24204200 push 121.00422024 ; /DEF
0040102D |. 68 1C204200 push 121.0042201C ; \Bc
00401032 |. 68 20204200 push 121.00422020 ; A
00401037 |. 68 B42F4200 push 121.00422FB4 ; %s,%s,%s
0040103C |? E8 2F000000 call 121.printf
00422FB4 25 732C2573 and eax,0x73252C73
00422FB9 2C 25 sub al,0x25
00422FBB 73 00 jnb X121.00422FBD ; %s,%s,%s 25 73 c2 25 73 c2 25 73 00 末尾加0
以上是debug版,用release版本的结果是相同的,地址也相同,都是401028