.MODEL SMALL
.CODE
…代码段…
.DATA
…初始化数据段…
.DATA?
…非初始化数据段…
PUBLIC C min
min PROC C NEAR
…
min ENDP
PUBLIC C min
min PROC C NEAR
PUSH BP ;保存BP
MOV BP,SP ;将SP拷贝到BP中
MOV AX,[BP+4] ;将V1送到AX中
CMP AX,[BP+6] ;与V2比较
JLE EXIT ;如果V1>V2
MOV AX,[BP+6] ;将V2送AX中
EXIT: POP BP ;恢复BP
RET ;返回C
min ENDP
PUBLIC PASCAL min
min PROC PASCAL NEAR
PUSH BP ;保存BP
MOV BP,SP ;将SP拷贝到BP中
MOV AX,[BP+6] ;将V1送到AX中
CMP AX,[BP+4] ;与V2比较
JLE EXIT ;如果V1>V2
MOV AX,[BP+6] ;将V2送AX中
EXIT: POP BP ;恢复BP
RET 4 ;清栈并返回
min ENDP
// 程序名:ASMTEST.CPP
#include "stdio.h"
extern "C" //声明在外部模块中定义的函数
{
int addnum( int , int );
}
main()
{
int x,y; //定义变量
printf("Please input x,y,the space key to compart:=>");
scanf("%d %d",&x,&y);
printf("x+y=%d\n",addnum(x,y));
return (0);
}