一个汇编小程序
实现一个函数功能如下:{ 2x,(x<0时)
Y={ 3x,(0<=x<=10时)
{ 4x,(x>10时)
程序代码如下:
DATAS SEGMENT
X DW 3
Y DW ?
DATAS ENDS
STACKS SEGMENT
DB 10H DUP(?)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
XOR AX,AX
MOV AX,X
CMP AX,0
JG GJE
MOV CX ,2
IMUL CX
MOV Y,AX
JMP EXIT
GJE: CMP AX,10
JA A
MOV CX ,3
MUL CX
MOV Y,AX
JMP EXIT
A: MOV CX,4
MUL CX
MOV Y,AX
EXIT:MOV CX,16
LOP: MOV BX,Y
AND BX,8000H
CMP BX,8000H
JNZ PP
MOV BX,0001H
PP: ADD BX,30H
MOV DX,BX
MOV AH,02H
INT 21H
SAL Y,1
LOOP LOP
MOV AH,4CH
INT 21H
CODES ENDS
END START