汇编题目

计算123*236

 1 assume cs:code
 2 
 3 code segment
 4 ;计算123*236
 5 
 6             mov ax,0
 7             mov cx,236
 8 
 9 addNumber:    add ax,123
10             mov dx,1000H
11             mov dx,2000H
12             loop addNumber
13         
14             mov ax,4C00H
15             int 21H
16         
17 code ends
18 
19 end 
View Code

 

计算FFFF:0~FFFF:F中的字节型数据的和,存放在dx中

 1 assume cs:code
 2 
 3 code segment
 4 ;计算FFFF:0~FFFF:F中的字节型数据的和,存放在dx中
 5             
 6             mov ax,0FFFFH
 7             mov ds,ax
 8             mov bx,0
 9             
10             mov dx,0
11             mov ax,0
12             
13             mov cx,16
14             
15 addNumber:    mov al,ds:[bx]
16             add dx,ax
17             inc bx
18             loop addNumber
19         
20             mov ax,4C00H
21             int 21H
22         
23 code ends
24 
25 end 
View Code

 

计算FFFF:0~FFFF:F中的字节型数据,复制到0:200- 0:20F中

 1 assume cs:code
 2 
 3 code segment
 4 ;计算FFFF:0~FFFF:F中的字节型数据,复制到0:200- 0:20F中
 5 ;0:200  和  20:0一样的
 6 ;ds
 7 ;es
 8             
 9             mov bx,0
10             mov cx,16
11             
12             
13 copyData:    mov ax,0FFFFH
14             mov ds,ax
15             mov dl,ds:[bx]
16             
17             mov ax,0020H
18             mov ds,ax
19             mov ds:[bx],dl
20             
21             inc bx
22             loop copyData
23         
24             mov ax,4C00H
25             int 21H
26         
27 code ends
28 
29 end 
View Code
 1 assume cs:code
 2 
 3 code segment
 4 ;计算FFFF:0~FFFF:F中的字节型数据,复制到0:200- 0:20F中
 5 ;0:200  和  20:0一样的
 6 ;ds    数据从哪里来
 7 ;es        数据放哪里去
 8             
 9             mov bx,0
10             mov cx,16
11             
12             mov ax,0FFFFH
13             mov ds,ax
14             mov ax,0020H
15             mov es,ax
16             
17             
18 copyData:    mov dl,ds:[bx]
19             mov es:[bx],dl
20             inc bx
21             loop copyData
22         
23             mov ax,4C00H
24             int 21H
25         
26 code ends
27 
28 end 
View Code

 

编程,向内存0:200H-0:23F  传递数据0~63(3FH)

 1 assume cs:code
 2 
 3 code segment
 4 ;编程,向内存0:200H-0:23F  传递数据0~63(3FH)
 5 
 6             mov ax,0020H
 7             mov ds,ax
 8             mov bx,0
 9             mov cx,64
10             
11 copyData:    
12             mov ds:[bx], bl
13             add bl,1
14             loop copyData
15         
16             mov ax,4C00H
17             int 21H
18         
19 code ends
20 
21 end 
View Code

 

将mov ax,4C00H 之前的指令复制到内存0:200

 1 assume cs:code
 2 
 3 code segment
 4 ; 下面的程序功能是将mov ax,4C00H 之前的指令复制到内存0:200        
 5         
 6             mov ax,cs
 7             mov ds,ax
 8             mov ax,0020H
 9             mov es,ax
10             mov bx,0
11             mov cx,17H
12             
13 copyData:    mov al,ds:[bx]
14             mov es:[bx],al
15             inc bx
16             loop copyData
17             
18             
19             mov ax,4C00H
20             int 21H
21         
22 code ends
23 
24 end 
View Code

 

将数据之和存放在ax中

 1 assume cs:code
 2 
 3 code segment
 4 ; 将数据之和存放在ax中
 5 dw        0123H,0456H,0789H,0ABCH,0DEFH,0FEDH,0CBAH,0987H
 6 
 7 start:
 8             mov ax,cs
 9             mov ds,ax
10 
11             mov bx,0
12             mov ax,0
13             
14             mov cx,8
15             
16 addNumber:    add ax,ds:[bx]
17             add bx,2
18             loop addNumber
19         
20             mov ax,4C00H
21             int 21H
22         
23 code ends
24 
25 end start
View Code

 

通过栈空间将数据逆序排放

 1 assume cs:code
 2 
 3 code segment
 4 ; 通过栈空间将数据逆序排放
 5 dw        0123H,0456H,0789H,0ABCH,0DEFH,0FEDH,0CBAH,0987H
 6 dw        0,0,0,0,0,0,0,0
 7 dw        0,0,0,0,0,0,0,0
 8 
 9 start:
10             mov ax,cs
11             mov ss,ax
12             mov sp,30H
13             
14             mov ax,cs
15             mov ds,ax
16             mov bx,0
17             
18             mov cx,8
19             
20 pushData:    push ds:[bx]
21             add bx, 2
22             loop pushData
23         
24         
25             mov cx,8
26             mov bx,0
27             
28 popData:    pop ds:[bx]
29             add bx,2
30             loop popData
31             
32             mov ax,4C00H
33             int 21H
34         
35 code ends
36 
37 end start
View Code

 

将0:0~0;F 内存中的字型数据改写到代码段中的数据

 1 assume cs:code
 2 
 3 code segment
 4 ; 将0:0~0;F 内存中的字型数据改写到代码段中的数据
 5 dw        0123H,0456H,0789H,0ABCH,0DEFH,0FEDH,0CBAH,0987H
 6 
 7 start:
 8             mov ax,0
 9             mov ds,ax
10             
11             mov bx,0
12             
13             mov cx,8
14             
15 copyData:    mov ax,ds:[bx]
16             mov cs:[bx],ax
17             add bx,2
18             loop copyData
19             
20             mov ax,4C00H
21             int 21H
22         
23 code ends
24 
25 end start
View Code

 

将0:0~0;F 内存中的字型数据改写到代码段中的数据,但是通过栈实现

 1 assume cs:code
 2 
 3 code segment
 4 ; 将0:0~0;F 内存中的字型数据改写到代码段中的数据,但是通过栈实现
 5 dw        0123H,0456H,0789H,0ABCH,0DEFH,0FEDH,0CBAH,0987H
 6 dw        0,0,0,0,0,0,0,0
 7 
 8 start:
 9             mov ax,cs
10             mov ss,ax
11             mov sp,32
12             
13             mov ax,0
14             mov ds,ax
15             
16             mov bx,0
17             
18             mov cx,8
19             
20 copyData:    
21             push ds:[bx]
22             pop cs:[bx]
23             add bx,2
24             loop copyData
25             
26             mov ax,4C00H
27             int 21H
28         
29 code ends
30 
31 end start
View Code

 

将大写转换成小写,小写转换成大写

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     db    'ABcDEF'
 5     db    'abCdef'
 6 data ends
 7 
 8 stack segment stack
 9     dw    0,0,0,0,0,0,0,0
10 stack ends
11 
12 
13 code segment
14     ;将大写转换成小写,小写转换成大写    
15 start:
16             mov ax,data
17             mov ds,ax
18             mov bx,0
19             
20             mov ax,data
21             mov es,ax
22             
23             mov cx,6
24             
25 downLetter:    mov dl,ds:[bx]
26             or dl,00100000B
27             mov es:[bx],dl
28             inc bx
29             loop downLetter
30             
31             mov cx,6
32             mov bx,6
33             
34 upLetter:    mov dl,ds:[bx]
35             and dl,11011111B
36             mov es:[bx],dl
37             inc bx
38             loop upLetter
39             
40             mov ax,4C00H
41             int 21H
42         
43 code ends
44 
45 end start
View Code
 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     db    'ABcDEF'
 5     db    'abCdef'
 6 data ends
 7 
 8 stack segment stack
 9     dw    0,0,0,0,0,0,0,0
10 stack ends
11 
12 
13 code segment
14     ;将大写转换成小写,小写转换成大写    
15 start:
16             mov ax,data
17             mov ds,ax
18             mov bx,0
19             
20             mov ax,data
21             mov es,ax
22             
23             mov cx,6
24             
25 setLetter:    mov dl,ds:[bx]
26             or dl,00100000B
27             mov es:[bx],dl
28             mov dl,ds:[bx+6]
29             and dl,11011111B
30             mov es:[bx+6],dl
31             inc bx
32             loop setLetter
33             
34             mov ax,4C00H
35             int 21H
36         
37 code ends
38 
39 end start
View Code

 

将数据段上面的数据复制到下面来

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     db    'welcome to mams!'
 5     db    '----------------'
 6 data ends
 7 
 8 stack segment stack
 9     dw 0,0,0,0,0,0,0,0
10     dw 0,0,0,0,0,0,0,0
11 stack ends
12 
13 
14 code segment
15     ;将数据段上面的数据复制到下面来
16 start:
17             mov ax,stack
18             mov ss,ax
19             mov sp,32
20             
21             mov ax,data
22             mov ds,ax
23             mov es,ax
24             
25             mov si,0
26             mov di,16
27             
28             mov cx,8
29             
30 copyData:    
31             ;mov dx,ds:[si]
32             ;mov es:[di],dx
33             push ds:[si]
34             pop es:[di]
35             add si,2
36             add di,2
37             loop copyData
38             
39             
40             mov ax,4C00H
41             int 21H
42         
43 code ends
44 
45 end start
View Code

 

将单词的首字母大写

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4         ;0123456789ABCDEF
 5     db    '1. file         '
 6     db    '2. edit         '
 7     db    '3. search       '
 8     db    '4. view         '
 9     db    '5. options      '
10     db    '6. help         '
11 data ends
12 
13 stack segment stack
14     dw 0,0,0,0,0,0,0,0
15     dw 0,0,0,0,0,0,0,0
16 stack ends
17 
18 
19 code segment
20     ;将单词的首字母大写
21 start:
22             mov ax,data
23             mov ds,ax
24             mov es,ax
25             
26             mov bx,0
27             mov si,3
28             
29             mov cx,6
30             
31 upLetter:    mov dl,ds:[bx+si]
32             and dl,11011111B
33             mov es:[bx+si],dl
34             add bx,16
35             loop upLetter
36             
37             mov ax,4C00H
38             int 21H
39         
40 code ends
41 
42 end start
View Code

 

将单词全变成大写  可以用栈临时保存cx的值

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4         ;0123456789ABCDEF
 5     db    '1. inm          '
 6     db    '2. dec          '
 7     db    '3. dos          '
 8     db    '4. vax          '
 9 data ends
10 
11 stack segment stack
12     dw 0,0,0,0,0,0,0,0
13     dw 0,0,0,0,0,0,0,0
14 stack ends
15 
16 
17 code segment
18     ;将单词全变成大写  可以用栈临时保存cx的值
19 start:
20             mov ax,stack
21             mov ss,ax
22             mov sp,32
23             
24             mov ax,data
25             mov ds,ax
26             mov es,ax
27             
28             mov bx,0
29             mov si,3
30             mov cx,4
31             
32 upLetter:    push cx
33             push si
34             mov cx,3
35             
36 upRow:        mov dl,ds:[bx+si]
37             and dl,11011111B
38             mov es:[bx+si],dl
39             inc si
40             loop upRow
41             
42             pop si
43             pop cx
44             add bx,16
45             loop upLetter
46             
47             mov ax,4C00H
48             int 21H
49         
50 code ends
51 
52 end start
View Code

 

改数据

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     db    'DEC'
 5     db    'Ken Olsen'
 6     dw    137        ;38
 7     dw    40        ;70
 8     db    'PDP'    ;'VAX'
 9 data ends
10 
11 stack segment stack
12     db 128 dup(0)
13 stack ends
14 
15 
16 code segment
17         
18 start:
19             mov ax,data
20             mov ds,ax
21             mov bx,0
22             
23             mov ax,stack
24             mov ss,ax
25             mov sp,128
26             
27             mov word ptr ds:[bx+12],38
28             mov word ptr ds:[bx+14],70
29             
30             mov si,0
31             mov byte ptr ds:[bx+16+si],'V'
32             inc si
33             mov byte ptr ds:[bx+16+si],'A'
34             inc si
35             mov byte ptr ds:[bx+16+si],'X'
36             inc si
37             
38             mov ax,4C00H
39             int 21H
40         
41 code ends
42 
43 end start
View Code

 

计算100001/100

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     dd 100001
 5 data ends
 6 
 7 stack segment stack
 8     db 128 dup(0)
 9 stack ends
10 
11 
12 code segment
13     ;计算100001/100    
14 start:
15             mov ax,data
16             mov ds,ax
17             mov bx,0
18             
19             mov ax,stack
20             mov ss,ax
21             mov sp,128
22             
23             mov ax,ds:[0]
24             mov dx,ds:[2]
25             mov bx,100
26             div bx
27             
28             mov ax,4C00H
29             int 21H
30         
31 code ends
32 
33 end start
View Code

 

看代码

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     db    '1975','1976','1977','1978','1979','1980','1981','1982','1983'
 5     db    '1984','1985','1986','1987','1988','1989','1990','1991','1992'
 6     db    '1993','1994','1995'
 7     ;year
 8     dd    16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
 9     dd    345980,590827,803530,1183000,184300,2759000,3753000,4649000,5937000
10     ;summ
11     dw    3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635
12     dw    8226,11542,14430,15257,17800
13 data ends
14 
15 table segment
16               ;0123456789ABCDEF
17     db 21 dup('year summ ne ?? ')
18 table ends
19 
20 stack segment stack
21     db 21 dup(0)
22 stack ends
23 
24 
25 code segment
26     
27 start:
28             mov ax,stack
29             mov ss,ax
30             mov sp,128
31             
32             mov ax,data
33             mov ds,ax
34             mov si,0
35             mov bx,0
36             
37             mov ax,table
38             mov es,ax
39             mov di,0
40             
41             mov cx,21
42             mov bx,168
43             
44 inputData: 
45             push ds:[si+0]
46             pop es:[di+0]
47             push ds:[si+2]
48             pop es:[di+2]
49             
50             mov ax,ds:[si+84]
51             mov dx,ds:[si+86]
52             mov es:[di+5],ax
53             mov es:[di+7],dx
54             
55             push ds:[bx]
56             pop es:[di+10]
57             
58             div word ptr es:[di+10]
59             
60             mov es:[di+13],ax
61             
62             add si,4
63             add bx,2
64             add di,16
65             loop inputData
66             
67             mov ax,4C00H
68             int 21H
69         
70 code ends
71 
72 end start
View Code

 

将指令复制到另一区域

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     
 5 data ends
 6 
 7 stack segment stack
 8     db 128 dup(0)
 9 stack ends
10 
11 
12 code segment
13         
14     start:    mov ax,stack
15             mov ss,ax
16             mov sp,128
17             
18             call cpy_Tetris
19     
20             mov ax,4C00H
21             int 21H
22 ;===============================
23 Tetris:        call clear_screen
24 
25             mov ax,4C00H
26             int 21H
27 clear_screen:
28             mov bx,1000H
29             mov bx,1000H
30             mov bx,1000H
31             mov bx,1000H
32             mov bx,1000H
33             
34             ret
35             
36 Tetris_end:    nop
37 
38 ;===============================
39 cpy_Tetris:    mov bx,cs
40             mov ds,bx
41             mov si,offset Tetris
42             
43             mov bx,0
44             mov es,bx
45             mov di,7E00H
46             mov cx,offset Tetris_end-Tetris
47             cld
48             rep movsb
49             
50             ret
51             
52 code ends
53 
54 end start
View Code

 

跳转到第一条指令

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     db    0,0,0,0,0
 5 data ends
 6 
 7 stack segment stack
 8     db 128 dup(0)
 9 stack ends
10 
11 
12 code segment
13     ;跳转到第一条指令
14     start:    mov ax,stack
15             mov ss,ax
16             mov sp,128
17             
18             mov ax,data
19             mov ds,ax
20             mov bx,0
21             
22             jmp word ptr ds:[bx]
23             
24     
25             mov ax,4C00H
26             int 21H
27         
28 code ends
29 
30 end start
View Code
 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     dd    12345678H
 5 data ends
 6 
 7 stack segment stack
 8     db 128 dup(0)
 9 stack ends
10 
11 
12 code segment
13     ;跳转到第一条指令
14     start:    mov ax,stack
15             mov ss,ax
16             mov sp,128
17             
18             mov ax,data
19             mov ds,ax
20             mov bx,0
21             
22             mov word ptr ds:[bx],0
23             mov word ptr ds:[bx+2],cs
24             
25             jmp dword ptr ds:[0]
26             
27     
28             mov ax,4C00H
29             int 21H
30         
31 code ends
32 
33 end start
View Code

 

在屏幕中间分别显示绿色,绿地红色,白底蓝色的字符串‘welcome to masm!’

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4         ;0123456789ABCDEF
 5     db    'welcome to masm!'
 6     db    00000010B
 7     db    00100100B
 8     db    01110001B
 9 data ends
10 
11 stack segment stack
12     db 128 dup(0)
13 stack ends
14 
15 
16 code segment
17     ;在屏幕中间分别显示绿色,绿地红色,白底蓝色的字符串
18     ;‘welcome to masm!’
19     start:    mov ax,stack
20             mov ss,ax
21             mov sp,128
22     
23             jmp show_masm
24     
25     
26 next:        mov ax,4C00H
27             int 21H
28         
29 show_masm:
30             mov bx,data
31             mov ds,bx
32             
33             mov bx,0B800H
34             mov es,bx
35             mov di,160*12 + 30*2        ;es:[di]
36             
37             mov cx,3
38             mov bx,16        ;ds:[bx]
39             
40 showMasm:    push cx
41             push di
42             mov cx,16
43             mov si,0        ;ds:[si]
44             mov dh,ds:[bx]
45             
46 showString:    mov dl,ds:[si]
47             mov es:[di],dx
48             add di,2
49             inc si
50             loop showString
51             
52             pop di
53             pop cx
54             add di,160
55             inc bx
56             
57             loop showMasm
58             
59             jmp next
60         
61 code ends
62 
63 end start
View Code

 

将指令转移到1000:0000H

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     
 5 data ends
 6 
 7 stack segment stack
 8     db 128 dup(0)
 9 stack ends
10 
11 
12 code segment
13     ;将指令转移到1000:0000H
14     start:    mov ax,stack
15             mov ss,ax
16             mov sp,128
17             
18             mov ax,1000H
19             push ax
20             mov ax,0
21             push ax
22             retf
23     
24             mov ax,4C00H
25             int 21H
26         
27 code ends
28 
29 end start
View Code

 

指定内存单元传递参数

  1 assume cs:code,ds:data,ss:stack
  2 
  3 data segment
  4     db 'conversation',0    ;jcxz
  5 data ends
  6 
  7 stack segment stack
  8     db 128 dup(0)
  9 stack ends
 10 
 11 
 12 code segment
 13     ;指定内存单元传递参数
 14     start:    mov ax,stack
 15             mov ss,ax
 16             mov sp,128
 17             
 18             call init_reg
 19             call clear_screen
 20             
 21             call show_conversation1
 22             call up_Letter
 23             call show_conversation2
 24             
 25             mov ax,4C00H
 26             int 21H
 27             
 28             
 29 ;==================================        
 30 show_conversation2:
 31             mov si,0
 32             mov di,160*11+40*2
 33             
 34             call show_string
 35             ret
 36 ;==================================        
 37 up_Letter:
 38             mov si,0
 39             call capital_letter
 40             ret            
 41 ;==================================        
 42 capital_letter:
 43             push cx
 44             push ds
 45             push si
 46             push di
 47             
 48             mov cx,0
 49             
 50 capitalLetter:    
 51             mov cl,ds:[si]
 52             jcxz capitalRet
 53             and byte ptr ds:[si],11011111B
 54             inc si
 55             jmp capitalLetter
 56             
 57 capitalRet:
 58             pop di
 59             pop si
 60             pop ds
 61             pop cx
 62             
 63             ret
 64             
 65 ;==================================        
 66 show_conversation1:
 67             mov si,0
 68             mov di,160*10+40*2
 69             
 70             call show_string
 71             ret
 72 ;==================================        
 73 show_string:
 74             push cx
 75             push ds
 76             push si
 77             push di
 78             
 79             mov cx,0
 80             
 81 showString:    mov cl,ds:[si]
 82             jcxz showStringRet
 83             mov es:[di],cl
 84             add di,2
 85             inc si
 86             jmp showString
 87             
 88             
 89 showStringRet:
 90             pop di
 91             pop si
 92             pop ds
 93             pop cx
 94             ret
 95 
 96 ;==================================        
 97 init_reg:    
 98             mov bx,data
 99             mov ds,bx
100             mov bx,0B800H
101             mov es,bx
102             ret
103 ;==================================        
104             
105 clear_screen:
106             mov bx,0
107             mov dx,0700H
108             mov cx,2000
109             
110 clearScreen:
111             mov es:[bx],dx
112             add bx,2
113             loop clearScreen
114             
115             ret
116 code ends
117 
118 end start
View Code

 

abc  加进位   32加法

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     
 5 data ends
 6 
 7 stack segment stack
 8     db 128 dup(0)
 9 stack ends
10 
11 
12 code segment
13     ;abc  加进位   32加法    
14     start:    mov ax,stack
15             mov ss,ax
16             mov sp,128
17                 
18             mov ax,data
19             mov ds,ax
20             
21             mov ax,0FFFFH    ;存放低16bit
22             mov dx,1000H    ;存放高16bit
23             add ax,0FFFFH
24             adc dx,0
25     
26     
27             mov ax,4C00H
28             int 21H
29         
30 code ends
31 
32 end start
View Code

 

将字符串大写显示出来

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     db "Beginner's All-purpose Symbolec Instruction Code.",0
 5 data ends
 6 
 7 stack segment stack
 8     db 128 dup(0)
 9 stack ends
10 
11 
12 code segment
13         
14     start:    mov ax,stack
15             mov ss,ax
16             mov sp,128
17             
18             call init_reg
19             call inid_data
20             call show_string
21             call up_letter
22             mov di,160*11+20*2
23             call show_string
24             
25             mov ax,4C00H
26             int 21H
27 
28 ;===================================    
29 up_letter:
30             push dx
31             push ds
32             push es
33             push si
34 
35             mov si,0
36             
37 upLetter:    mov dl,ds:[si]
38             cmp dl,0
39             je upLetterRet
40             cmp dl,'a'
41             jb nextLetter
42             cmp dl,'z'
43             ja nextLetter
44             and byte ptr ds:[si],11011111B
45 nextLetter:    inc si    
46             jmp upLetter
47 
48 upLetterRet:
49             pop si
50             pop es
51             pop ds
52             pop dx
53             ret
54 ;===================================    
55 inid_data:
56             mov si,0
57             mov di,160*10+20*2
58             ret
59 ;===================================    
60 show_string:
61             push dx
62             push ds
63             push es
64             push si
65             push di
66 showString:
67             mov dl,ds:[si]
68             cmp dl,0
69             je show_stringRet
70             mov es:[di],dl
71             add di,2
72             inc si
73             jmp showString
74             
75 show_stringRet:
76             pop di
77             pop si
78             pop es
79             pop ds
80             pop dx
81             ret
82 ;===================================    
83 init_reg:
84             mov bx,data
85             mov ds,bx
86             
87             mov bx,0B800H
88             mov es,bx
89             ret
90 
91 code ends
92 
93 end start
View Code

 

除0时,在屏幕上显示'divide error'

 1 assume cs:code,ds:data,ss:stack
 2 
 3 data segment
 4     
 5 data ends
 6 
 7 stack segment stack
 8     db 128 dup(0)
 9 stack ends
10 
11 
12 code segment
13         
14     start:    mov ax,stack
15             mov ss,ax
16             mov sp,128
17     
18             call cpy_new_int0
19             call set_new_int0
20             
21             mov ax,0
22             mov dx,1
23             mov bx,1
24             div bx
25             
26             
27             mov ax,4C00H
28             int 21H
29 
30 ;======================================
31 set_new_int0:
32             mov bx,0
33             mov es,bx
34             
35             mov word ptr es:[0*4],7E00H
36             mov word ptr es:[0*4+2],0
37             
38             ret
39 ;======================================
40 new_int0:
41             jmp newInt0
42             
43 string:            db         'divide error',0
44             
45 newInt0:    
46             mov bx,0B800H
47             mov es,bx
48             
49             mov bx,0
50             mov ds,bx
51             
52             mov di,160*10+30*2
53             mov si,7E03H
54             
55 showString:
56             mov dl,ds:[si]
57             cmp dl,0
58             je showStringRet
59             mov es:[di],dl
60             add di,2
61             inc si
62             jmp showString
63             
64 showStringRet:
65             mov ax,4C00H
66             int 21H
67             
68 new_int0_end:
69             nop
70 ;======================================
71 cpy_new_int0:
72             mov bx,cs
73             mov ds,bx
74             mov si,offset new_int0
75             
76             mov bx,0
77             mov es,bx
78             mov di,7E00H
79             
80             mov cx,offset new_int0_end - new_int0
81             cld
82             rep movsb
83             
84             ret
85 code ends
86 
87 end start
View Code

 

posted @ 2018-12-07 22:48  starry_sky  阅读(412)  评论(0编辑  收藏  举报