用汇编语言编程

 我来答
gcbjoy
2018-06-22 · TA获得超过1.1万个赞
知道大有可为答主
回答量:1.1万
采纳率:92%
帮助的人:2170万
展开全部
        CODE  SEGMENT
              ASSUME    CS:CODE

         BUF  DB        50 DUP(?)
        BUF1  DB        50 DUP(?)

      START:  PUSH      CS
              POP       DS
              PUSH      CS
              POP       ES
              ; ==============随机生成50个数 
              LEA       DI,BUF
              MOV       CX,50
              CLD
         @1:
              CALL      RAND
              STOSB
              MOV       AX,2
              CALL      DELAY_PROC
              LOOP      @1
              ;===============输出这50个数 
              CALL      LFCR
              LEA       SI,BUF
              MOV       CX,50
              CLD
        @11:
              LODSB
              CALL      DSPAL
              LOOP      @11
            
              ;================转为bcd码保存 
              LEA       SI,BUF
              LEA       DI,BUF1
              MOV       CX,50
              CLD
         @2:
              LODSB
              MOV       AH,0
              MOV       BL,10
              DIV       BL
              SHL       AL,4
              ADD       AL,AH
              STOSB
              LOOP      @2
              ;===============输出bcd数 
              CALL      LFCR
              LEA       SI,BUF1
              MOV       CX,50
              CLD
         @3:
              MOV       AX,CX
              MOV       BL,10
              DIV       BL
              OR        AH,AH
              JNE       @4
              CALL      LFCR
         @4:
              LODSB
              ROR       AL,4
              PUSH      AX
              MOV       DL,AL
              AND       DL,0FH
              OR        DL,30H
              MOV       AH,2
              INT       21H
              POP       AX
              ROR       AL,4
              MOV       DL,AL
              AND       DL,0FH
              OR        DL,30H
              MOV       AH,2
              INT       21H
              MOV       DL,'H'
              INT       21H
              MOV       DL,32
              INT       21H
              LOOP      @3

              MOV       AH,4CH
              INT       21H

;===============================================================              
  DELAY_PROC  PROC      NEAR        ;延迟子程式,  延迟   ax/18秒
              PUSH      ES
              PUSH      DX
              MOV       DX,40H
              MOV       ES,DX
              MOV       DX,ES:[006CH]           ;取系统1/18秒计数
              ADD       DX,AX       ; 延时 x/18
    DELAY10:
              CMP       ES:[006CH],DX           ;时限到了?
              JBE       DELAY10     ;没
              POP       DX
              POP       ES
              RET
  DELAY_PROC  ENDP
;============================================================
        RAND  PROC      NEAR
              ; 利用时钟的低位反转除100的余数作为随机数 
              ; 随机数在ax中带回 
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSHF
              MOV       AH,0
              INT       1AH
              ; MOV       AX,CX     
              MOV       BX,DX
              MOV       CX,16
     @RAND1:
              ROR       BX,1
              RCL       AX,1
              LOOP      @RAND1
              MOV       DX,0
              MOV       BX,100
              DIV       BX
              MOV       AX,DX
              POPF
              POP       DX
              POP       CX
              POP       BX
              RET
        RAND  ENDP
;==================================
       LFCR:  PUSH      AX
              PUSH      DX
              MOV       AH,2
              MOV       DL,13
              INT       21H
              MOV       DL,10
              INT       21H
              POP       DX
              POP       AX
              RET
;=================================
       DSPAL  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSHF
              XOR       AH,AH
              XOR       CX,CX
              MOV       BL,10
    @DSPAL1:
              DIV       BL
              INC       CX
              MOV       DL,AH
              XOR       AH,AH
              OR        DX,30H
              PUSH      DX
              CMP       AL,0
              JNE       @DSPAL1
              MOV       AH,2
   @DISPAL2:
              POP       DX
              INT       21H
              LOOP      @DISPAL2
              MOV       DL,32
              INT       21H
              POPF
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
       DSPAL  ENDP
;================================
        CODE  ENDS
              END       START
追问
这个题的运行结果有吗
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式