汇编串操作程序设计 计算X+(Y-Z)=W

2021-09-24 15:07:11 浏览数 (1)

串操作程序设计 HLJU 设X、Y、Z均为双精度数,它们分别存放在X、X 2、Y、Y 2、Z、Z 2存储单元中,存放时高位存高地址,低位存低地址,编写程序实现下面表达式的计算:X (Y-Z)=W

代码语言:javascript复制
 DATA      SEGMENT
               STRING1 DB 'The 1th string:','$'
               STRING2 DB 'The 1th string:','$'
               OLDS DB 10 DUP(?)
               NEWS DB 10 DUP(?)
               LEN DW 5 ;
               STR1 DB 'YES','$'
               STR2 DB 'NO','$'
DATA ENDS

CODE      SEGMENT
               ASSUME CS:CODE,DS:DATA
START:
               MOV  AX,DATA
               MOV  DS,AX
               MOV  ES,AX
               LEA     DX,STRING1
               MOV  AH,9
               INT    21H

               MOV  CX,LEN
               MOV  SI,0

AGAIN1:  MOV  AH,01H
               INT     21H
               MOV  OLDS[SI],AL
               INC     SI
               LOOP  AGAIN1
               MOV   AH,2
               MOV   DL,0AH
               INT      21H
               MOV   AH,2
               MOV   DL,0AH
               INT      21H
               LEA     DX,STRING2
               MOV  AH,9
               INT     21H

               MOV  CX,LEN
               MOV  DI,0

AGAIN2:  MOV   AH,01H
               INT     21H
               MOV   NEWS[DI],AL
               INC     DI
               LOOP  AGAIN2
               MOV   AH,2
               MOV   DL,0AH
               INT      21H
               MOV   AH,2
               MOV   DL,0DH
               INT      21H
               MOV   CX,LEN
               LEA      SI,OLDS
               LEA      DI,NEWS
               CLD
               REPZ    CMPSB
               JNE      NO

YES:         LEA      DX,STR1
               MOV    AH,09H
               int        21H
               JMP     FINAL

NO:         LEA      DX,STR2
               MOV    AH,09H
               INT      21H
               JMP      FINAL

FINAL:
               MOV AH,4CH
               INT 21H
CODE    ENDS
END      START

0 人点赞