初级汇编语言

2021-01-14 21:13

阅读:562

标签:int   style   屏幕   sum   nbsp   jpg   not   store   height   

汇编调试程序DEBUG的常用命令和功能,DEBUG环境下调试程序的方法.

 

  1. 两个无符号数相加,将结果数存入指定地址单元。被加数,加数及和存放地址及数据如下:

             地址             数据

被加数 20000000         9FH

       20000001         6BH

 加数  20000002         5CH

       20000003         42H

     20000004          

     ~ 20000006

 

-e 2000:0000 9f 6b 5c 42
-a 1000:0
mov ax,[0000H]
mov bx,[0002H]
add ax,bx
mov 2000:[0004],ax
-r cs
1000
-r ip
0
-t -t -t -t

 

技术图片

 

 

  2.两个无符号数相减,将差存入指定地址单元。被减数,减数及差的存放地址及数据如下:

             地址             数据

被减数    20000100          8C

          20000101          42

  减数    20000102          92

          20000103          5A

        20000104

          20000105

 

-e 2000:0100 8c 42 92 5a
-a 1000:0
mov ax,2000:[0100H]
mov bx,2000:[0102]
sub ax,bx
mov 2000:[0104],ax
-r cs
1000
-r ip
0
-t -t -t -t

 

技术图片

 

  3.两个无符号数相乘,将积存入指定地址单元。被乘数,乘数及积存放的地址及数据如下:

              地址            数据

被乘数    20001000           56

          20001001           2C

  乘数    20001002           3A

          20001003           1C

        20001004

        ~ 20001007

 

-e 2000:0200 56 2C 3A 1C
-a 1000:0000
mov ax,2000:[1000]
mov bx,2000:[1002]
mul bx
mov 2000:[1004],ax
mov 20000:[1006],dx
-r cs
1000
-r ip
0
-t -t -t -t -t

 

技术图片

 

  4.两个无符号数相除,将商及余数存入指定的地址单元。被除数,除数,商及余数存放的地址及数据如下:

             地址             数据

被除数    20000200          2A

          20000201          3B

          20000202          4C

          20000203          5D

  除数    20000204          7C

          20000205          5D

        20000206

          20000207

  余数    20000208

          20000209

 

-e 2000:0200 2a 3b 4c 5d 7c 5d
-a 1000:0
mov ax,2000:[0200]
mov bx,2000:[0202]
div bx
mov 2000:[0206],ax
mov 2000:[0208],dx
-r cs
1000
-r ip
0
-t -t -t -t -t

 

技术图片

 

屏幕显示计算机提问:

Do you like this book ?

若用户回答N, 计算机回答:

You may go to the next store.

若用户回答Y, 计算机回答:

  I think you will buy it.

 

DATA SEGMENT 
    SEN1 DB 0DH,0AH,"Do you like this book ",0x3fh,0DH,0AH,"$"
    SEN2 db 0DH,0AH,"You may go to the next store.",0DH,0AH,"$"
    SEN3 DB 0DH,0AH,"I think you will buy it",0DH,0AH,"$"
    SEN4 DB 0DH,0AH,"Please input a word(Y or N)",0DH,0AH,"$"
DATA ENDS

CODE SEGMENT
    ASSUME DS:DATA,CS:CODE 
    START:MOV AX,DATA
    MOV DS,AX 
    MOV Ah,2h                 
    MOV BH,0
    MOV DH,5
    MOV DL,12 
    INT 10H
    
   BEAGIN: MOV DX,OFFSET SEN1
    MOV AH,09H
    INT 21H
    
    MOV AH,01H
    INT 21H 
    MOV AH,09H
    CMP AL,N
    JE NOT
    CMP AL,Y
    JE OK
    CMP AL,Q
    JE END
    JMP KEY
    OK: MOV DX,OFFSET SEN2
    INT 21H
    JMP BEAGIN
    
    NOT: MOV DX,OFFSET SEN3
    INT 21H
    JMP BEAGIN
    
    KEY:MOV DX,OFFSET SEN4
    INT 21H
    JMP BEAGIN
    END: NOP 
    MOV AH,4CH
    INT 21H
CODE ENDS
END START

技术图片

屏幕显示计算机提问:

Would you like tea or coffee?

用户用键盘输入回答,并显示出来.

 

DATA SEGMENT 
    SEN DB 0dh,0ah,"Would you like tea or coffee",0x3fh,0dh,0ah,"$"
    SEN2 DB 0dh,0ah,"Your input is:","$"
    SEN3 DB 0DH,0AH,"$"
    STRING DB 20,0,20 DUP(0)
DATA ENDS

CODE SEGMENT
    ASSUME DS:DATA,CS:CODE 
    START:MOV AX,DATA
    MOV DS,AX 
    MOV Ah,2h                 
    MOV BH,0
    MOV DH,5
    MOV DL,12 
    INT 10H
    
    MOV DX,OFFSET SEN
    MOV AH,09H
    INT 21H
    
    MOV DX,OFFSET STRING
    MOV AH,0AH
    INT 21H
    MOV CL,STRING+1
    XOR CH,CH
    ADD DX,CX
    MOV BX,DX
    MOV BYTE PTR[BX+2],$
    MOV AH,09H
    MOV DX,OFFSET SEN3
    INT 21H
    MOV DX,OFFSET STRING
    ADD DX,2
    INT 21H
   
    MOV AH,4CH
    INT 21H
CODE ENDS
END START

 技术图片

 

初级汇编语言

标签:int   style   屏幕   sum   nbsp   jpg   not   store   height   

原文地址:https://www.cnblogs.com/a-runner/p/12939357.html


评论


亲,登录后才可以留言!