S= 2*x x<0
3*x 0<=x<=10
4*x X>10
DATA1 SEGMENT
S DB ?
X DB 3
DATA1 ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA1
START:
MOV AX,DATA1
MOV DS,AX
MOV AL,X
TEST AL,80H
JZ LL0 ;结果为0,ZF为1跳 ,否则最高位为1,负数直接乘以2
SHL AL,1
JMP LL10 ;无条件跳,送结果
LL0:
CMP AL,10
JG LL1 ;al大于10,跳 否则顺序执行,
MOV BL,AL
SHL AL,1
ADD AL,BL ;AL*3
LL1: SHL AL,1;AL*2
SHL AL,1;AL*2已经乘过2了再乘一次2就行
LL10:
MOV S,AL
MOV AH,4CH
INT 21H
CODE ENDS
END START