ASM Multiplication Table
Multiplication Table
使用汇编打印99乘法表
这是一个综合性很强的程序,它很好的演示了80386的常用寄存器和常用指令,实现了简单的循环程序设计。
This is a comprehensive program , It well demonstrates CPU 80386 of the commonly used registers and commonly used instructions.
IDE: MASMPlus
OS : Windows 7
Lang: ASM x86 EXE
用C/CPP实现 :
int n;
cin>>n;
int i = 1,j=0;
while(i<=n){
j=1;
while(j<=i){
cout<<j<<"*"<<i<<"="<<j*i<<" ";
j++;
}
hhf();
i++;
}
This is the source code of the program :
;#Mode=CON
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include masm32.inc
includelib user32.lib
includelib kernel32.lib
includelib masm32.lib
includelib msvcrt.lib
include macro.asm
printf proto c:DWORD ,:vararg
scanf proto c:DWORD ,:vararg
gets proto c:DWORD
.data
n DWORD ?
sum DWORD ?
arr dword 100 dup(?)
i DWORD ?
j DWORD ?
com DWORD ?
buffer db 100 dup(?)
.code
start:
invoke scanf,CTXT("%d"),addr n
mov i,1
mov eax,n
.while i<=eax
push eax
mov j,1
mov ebx,i
.while j<=ebx
mov eax,j
imul eax,i
mov com,eax
invoke printf,CTXT("%d*%d=%d "),j,i,com
inc j
.endw
invoke printf,CTXT(0dh,0ah)
inc i
pop eax
.endw
Done:
invoke StdIn,addr buffer,sizeof buffer
invoke ExitProcess, 0
end start