|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 youmingshi 于 2013-7-12 21:34 编辑
之前每个程序分开编译是可以的,不过合在一块,不知道哪里出错了。。。
而且debug的时候,在h3那段,执行完movsb后,再单步运行2次,就出现错误,cs ip的地址都变了, cs变到020a,ip 02bf
不知道怎么回事。。。额 求助!下面是合并的不能显示的代码和分开的、各个分开的代码运行良好的代码
合并的:
assume cs:code,ds:data,ss:stack
stack segment
db 128 dup (0)
stack ends
data segment
db 9,8,7,4,2,0
db '// :: '
data ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,128
s0: mov si,offset h3
call far ptr h3
;jmp h3 ;调用开始
s1: jmp h2
s2: jmp h1
s3: jmp h0 ;调用结束
h0: mov ax,0b800h ;az循环开始
mov es,ax
l2: mov ah,'a'
l1: mov es:[160*13+40*2],ah
inc ah
cmp ah,'z'
je l2
jne l1
loop l1 ;az循环结束
mov ax,4c00h
int 21h
h1: ;日期显示开始
mov ax,data
mov ds,ax
mov di,0
mov si,0
mov cx,6
l3:
push cx
mov al,ds:[di]
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov bx,0b800h
mov es,bx
mov byte ptr es:[11*160+30*2+si],ah
inc si
inc si
mov byte ptr es:[11*160+30*2+si],al
inc si
inc si
mov al,ds:[6+di]
mov byte ptr es:[11*160+30*2+si],al
inc di
inc si
inc si
pop cx
loop l3
jmp s3 ;日期显示结束
h2: mov ax,cs ;安装overflow开始
mov ds,ax
mov si,offset d0
mov ax,0
mov es,ax
mov di,200h
mov cx,offset d1-offset d0
cld
rep movsb
mov ax,0
mov es,ax
mov word ptr es:[0*4],200h
mov word ptr es:[0*4+2],0
int 0
jmp s2;
d0: jmp short d2
db 'overflow!'
d2: mov ax,cs
mov ds,ax
mov si,202h
mov ax,0b800h
mov es,ax
mov di,12*160+36*2
mov cx,9
l4: mov al,[si]
mov es:[di],al
inc si
add di,2
loop l4
retf
popf
d1: nop ;安装overflow结束
;安装int9开始
h3: mov ax,cs
mov ds,ax
mov ax,0
mov es,ax
mov si,offset d6
push es:[9*4]
pop ds:[si]
push es:[9*4+2]
pop ds:[si+2]
mov si,offset d3
mov ax,200h
mov di,ax
mov ax,0
mov es,ax
cld
mov cx,offset d4-offset d3
rep movsb
mov word ptr es:[9*4],200h
mov word ptr es:[9*4+2],0h
mov ax,0b800h
mov es,ax
mov ah,'a'
mov es:[160*14+40*2],ah
; inc ah
; cmp ah,'z'
; je l2
; jne l1
; loop l1
retf
;jmp s1
d3: jmp short d5 ;新int9开始
d6: dw 0,0
d5: push si
push ax
push bx
push es
in al,60h
cmp al,1
jne int9ret
mov ax,0b800h
mov es,ax
inc byte ptr es:[160*14+40*2+1]
int9ret:pushf
pushf
pop bx
and bh,11111100b
push bx
popf
mov ax,cs
mov ds,ax
mov si,200h+offset d6-offset d3
call dword ptr ds:[si]
pop es
pop bx
pop ax
pop si
iret
d4: nop ;新int9结束
;安装int9结束
code ends
end start
分开的:
第一个:对应这h3
assume cs:code
stack segment
db 128 dup (0)
stack ends
code segment ;安装int9开始
start: mov ax,cs
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,128
mov ax,0
mov es,ax
mov si,offset d6
push es:[9*4]
pop ds:[si]
push es:[9*4+2]
pop ds:[si+2]
mov si,offset d3
mov ax,200h
mov di,ax
mov ax,0
mov es,ax
cld
mov cx,offset d4-offset d3
rep movsb
mov word ptr es:[9*4],200h
mov word ptr es:[9*4+2],0h
mov ax,0b800h ;az循环开始
mov es,ax
l2: mov ah,'a'
l1: mov es:[160*13+40*2],ah
inc ah
cmp ah,'z'
je l2
jne l1
loop l1
mov ah,1
int 21h
mov ax,4c00h
int 21h
d3: jmp short d5 ;新int9开始
d6: dw 0,0 ;040a020a
d5: push si
push ax
push bx
push es
in al,60h
cmp al,1
jne int9ret
mov ax,0b800h
mov es,ax
inc byte ptr es:[160*13+40*2+1]
int9ret:pushf
pushf
pop bx
and bh,11111100b
push bx
popf
mov ax,cs
mov ds,ax
mov si,200h+offset d6-offset d3
call dword ptr ds:[si]
pop es
pop bx
pop ax
pop si
iret
d4: nop ;新int9结束
code ends
end start
;安装int9结束
分开的:
对应着h2
assume cs:code
data segment
data ends
code segment
start: mov ax,cs
mov ds,ax
mov si,offset d0
mov ax,0
mov es,ax
mov di,200h
mov cx,offset d1-offset d0
cld
rep movsb
mov ax,0
mov es,ax
mov word ptr es:[0*4],200h
mov word ptr es:[0*4+2],0
int 0
;mov ax,4c00h
;int 21h
d0: jmp short d2
db 'overflow!'
d2: mov ax,cs
mov ds,ax
mov si,202h
mov ax,0b800h
mov es,ax
mov di,12*160+36*2
mov cx,9
s: mov al,[si]
mov es:[di],al
inc si
add di,2
loop s
mov ax,4c00h
int 21h
d1: nop
code ends
end start
分开的:
对应着h1
assume cs:code,ds:data,ss:stag
stag segment
db 128 dup (0)
stag ends
data segment
db 9,8,7,4,2,0
db '// :: '
data ends
code segment
start:
mov ax,stag
mov ss,ax
mov sp,128
mov ax,data
mov ds,ax
mov di,0
mov si,0
mov cx,6
s:
push cx
mov al,ds:[di]
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov bx,0b800h
mov es,bx
mov byte ptr es:[11*160+30*2+si],ah
inc si
inc si
mov byte ptr es:[11*160+30*2+si],al
inc si
inc si
mov al,ds:[6+di]
mov byte ptr es:[11*160+30*2+si],al
inc di
inc si
inc si
pop cx
loop s
mov ax,4c00h
int 21h
code ends
end start
分开的:
对应着h0
assume cs:code,ds:data,ss:stag
stag segment
stag ends
data segment
data ends
code segment
start: mov ax,0b800h ;az循环开始
mov es,ax
l2: mov ah,'a'
l1: mov es:[160*13+40*2],ah
inc ah
cmp ah,'z'
je l2
jne l1
loop l1 ;az循环结束
mov ax,4c00h
int 21h
code ends
end start
|
|