编程判断DAT单元存放的带符号数的正负。

题目

编程判断DAT单元存放的带符号数的正负。
如该数为负数,则显示“DAT is a negative number!”;否则显示“DAT is a nonnegative number!”。

程序

DATA  SEGMENT               ;数据段定义
  N  DB  'DAT is a negative number!','$'
  NN  DB 'DAT is a nonnegative number! $'
DATA  ENDS
CODE  SEGMENT               ;代码段定义
   ASSUME CS:CODE,DS:DATA
START: 
        MOV  AX,DATA
        MOV  DS,AX          ;设置DS
            MOV  AX,-3
            CMP  AX,0
            JGE  ISNN
        LEA  DX,N
             MOV  AH,9
             INT  21H
            JMP  FINISH

ISNN:   LEA  DX,NN
            MOV  AH,9
            INT  21H
FINISH:
            MOV  AH,4CH
            INT  21H
CODE   ENDS
        END  START

0

Leave a Reply

Your email address will not be published.