1 2 3 下一页 Loop 是反复执行; 从哪反复? 这要用到 "标号"; 反复几次? 把反复的次数告诉 ECX 寄存器即可. 笨办法计算 3 * 8 = 24 ; Test15_1.asm .386 .model flat, stdcall include Windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .data val dd 3 .code main proc xor eax, eax add eax, val add eax, val add eax, val add eax, val add eax, val add eax, val add eax, val add eax, val PrintDec eax ;24 ret main endp end main
使用 LOOP 和标号: ; Test15_2.asm .386 .model flat, stdcall include Windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .data val dd 3 .code main proc xor eax, eax mov ecx, 8 L1: ;命名为 "L1" 的标号 add eax, val loop L1 ;反复到指定标号; 每次反复 ecx 会减 1, 直到 ecx 为 0 才向下执行 PrintDec eax ;24 ret main endp end main (责任编辑:admin)
|