这是一个与您的类似的 C 示例:
#include <stdio.h>
int i = 5;
int
main (int argc, char *argv[])
{
while (--i >= 0)
;
return 0;
}
这是 Visual Studio 汇编程序输出 (cl /Fa):
.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
_BSS SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS ENDS
_TLS SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS ENDS
FLAT GROUP _DATA, CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC _i
_DATA SEGMENT
_i DD 05H
_DATA ENDS
PUBLIC _main
_TEXT SEGMENT
_main PROC NEAR
; File x.c
; Line 7
push ebp
mov ebp, esp
$L342:
; Line 8
mov eax, DWORD PTR _i
sub eax, 1
mov DWORD PTR _i, eax
cmp DWORD PTR _i, 0
jl SHORT $L343
; Line 9
jmp SHORT $L342
$L343:
; Line 10
xor eax, eax
; Line 11
pop ebp
ret 0
_main ENDP
_TEXT ENDS
END