2014-06-15 74 views
-1

我再次遇到显示文件名称的问题。为什么呢?驻留功能未正确执行

居民功能改变目录并显示行,但不显示文件名。我从其他程序导致功能。

.model tiny 
.code 
.186 
org 100h 
main: mov ah, 33h 
     int 60h 
     ret 
     end main 

如果功能号码不正确,该错误会显示:“未实现功能%somefunction%” 。

我的函数号33h,我必须收到消息“最早创建日期的文件:%myoldfile%”,但是 我只接收没有文件名的行。

.MODEL tiny 
.code 
.386 

org  100h 

main: 


jmp init 

Int_60h: 
xor  cx, cx 
mov  cl, ah 
push ds 
pusha 
mov  bl, ah 
sal  bx, 1 
mov  ax, cs 
mov  ds, ax 
call TAB[bx] 
popa 
mov  bl, count 
pop  ds 
iret 






OldFile PROC 

mov ah,3bh 
mov dx,offset root ; Change directory to the root 
int 21h 

lea dx, dta ; dta: disk transfer area 
mov ah, 1AH ; SET DISK TRANSFER AREA ADDRESS 
int 21h ; DOS INTERRUPT 

mov ah, 4EH ; FIND FIRST MATCHING FILE 
lea dx, path ; DS:DX -> ASCIZ file specification (may include path and wildcards) 
mov cx, 0 ; file attribute mask 
int 21h ; DOS INTERRUPT 

call store_dta 


FindNext: 

mov ah, 4FH ; FIND NEXT MATCHING FILE 
int 21h ; DOS INTERRUPT 
jc Finish 

; compare filedates & filetimes 
lea si, dta_hold ; DTA of the oldest file 
lea di, dta ; DTA of the just found file 
mov ax, [si+18h] ; filedate 
mov bx, [di+18h] ; filedate 
cmp ax, bx 
jc FindNext ; just found file is newer 
jne Older 
; filedates are identical 
mov ax, [si+16h] ; filetime 
mov bx, [di+16h] ; filetime 
cmp ax, bx 
jc FindNext 

Older: ; just found file is older 
call store_dta ; copy dta to dta_hold 
jmp FindNext 

Finish: 
call print_filename ; print the last filename 




store_dta PROC 
mov cx, (128/2) ; size of DTA in WORDs (half of BYTEs) 
lea si, dta 
lea di, dta_hold 
rep movsw ; copy CX times DS:SI => ES:DI 
ret 
store_dta ENDP 

print_filename PROC 

lea dx, line ; new line 
mov ah, 09h ; WRITE STRING TO STANDARD OUTPUT 
int 21h ; DOS INTERRUPT 

lea di, dta_hold + 1Eh 
mov dx, di ; start of filename 
_B: ; look for NULL (ASCIZ-termination) 
cmp BYTE PTR [di], 0 
je _F 
inc di 
jmp _B 
_F: ; replace NULL by '$' 
mov [di], BYTE PTR '$' ; end-of-string delimiter for INT 21h/09h 
mov ah, 09h ; WRITE STRING TO STANDARD OUTPUT 
int 21h ; DOS INTERRUPT 

lea dx, LF ; new line 
mov ah, 09h ; WRITE STRING TO STANDARD OUTPUT 
int 21h ; DOS INTERRUPT 
ret 

dta db 128 DUP(?) 
dta_hold db 128 DUP(?) 
path db "*.*",0 
LF db 13,10,'$' 
root db "/",0 
line db "The file with the oldest date of creation: ",'$' 

print_filename ENDP 

    OldFile ENDP 

    Zproc proc near 
xor  ax, ax 
mov al, cl 
mov cx, 5   
    L1:     
xor dx, dx   
mov di, cx   
div hexdel 
mov bx, dx   
mov dl, chararray[bx] 
mov Znum[di-1], dl 
dec cx 
cmp ax, 0 
jne L1   
mov si, offset Zmessage1 
l4: mov al, [si] 
mov ah, 0Eh 
inc si 
int 10h 
cmp byte ptr [si], '$' 
jne l4 
    ret 
Zproc endp 




TAB dw 51 DUP (Zproc), (OldFile), 204 DUP (Zproc) 
hexdel   dw 16 
Zmessage1 db "Function " 
Znum db 3 dup (?) 
Zmessage2 db "h is not realized.", 0Dh, 0Ah, '$' 
count db  (?) 
chararray db '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',  'D', 'E', 'F' 

init: 
mov ax,2560h 
mov dx,offset Int_60h 
int 21h 
mov dx, (init-main+10Fh)/16 
mov ah, 31h 
int 21h 
end main 

回答

0

的主要问题是,你打电话给你的函数call TAB[bx],但不正确填写BXmov bl, ah是不够的,因为BH的值也对BX有影响。写XOR BX, BX您填写BL之前:

xor  bx,bx 
mov  bl, ah 

第二是程序OldFile不正确返回。在正确的地方插入一个ret

Finish: 
call print_filename ; print the last filename 
ret 

三:store_dta需要ES的程序进行初始化:

mov  ds, ax 
mov  es, ax 
call TAB[bx] 
+0

我加了,但它并没有落实。 – lifetowin

+0

@lifetowin,我忘了:程序'OldFile'没有正确返回。你的代码中有另一个丑陋的东西可能会导致问题。它在DOSBox中工作,但在WinXP中存在一个我无法弄清楚的问题。为什么你和TSR一起玩? – rkhb

+0

我不知道,老师很想在最后一分钟。 – lifetowin