汇编语言编写一个程序

2025-04-06 02:13:50
推荐回答(1个)
回答1:

        CODE  SEGMENT
              ASSUME    CS: CODE

              ORG       200H        ; 0:200H 为操作系统保护区
                                    ; 所以数据区直接放在代码中 
         BUF  DB        10 DUP(?)

      START:  PUSH      CS
              POP       DS
              PUSH      CS
              POP       ES
              LEA       DI,BUF
              MOV       AL,1
              MOV       CX,10
              MOV       DX,0
              CLD
         @1:
              TEST      AL,1
              JNZ       @2
              STOSB
              INC       DX
         @2:
              INC       AL
              LOOP      @1

              MOV       BX,0
              LEA       SI,BUF
              MOV       CX,DX
         @3:
              LODSB
              CBW
              ADD       BX,AX
              LOOP      @3
              MOV       AX,BX
        
              MOV       AH,4CH
              INT       21H
        CODE  ENDS
              END       START