Please help me about attribute of file!

Started by vasant, October 31, 2005, 12:18:02 AM

Previous topic - Next topic

vasant

[2.ASM]
Title Make_File
.Model small
.stack 100H
INCLUDE MACRO
Extrn MF:Near
Public Handle,File_name,ATTRIBUTE
;--------------------------------------------------------
.Data
File_name DB 8 DUP(?),'TXT',0
ATTRIBUTE DB ?
TEXT_1    DB 'PUT FILE NAME: $'
HANDLE    DW ?
TEXT_3    DB 'PUT ATTRIBUTE: $'
TEXT_4    DB 'SELECT ATTRIBUTE Read-only,Hidden,System,Archive$'
TEXT_5    DB 'abcdefghijklmnopqrstuvwxyz'
TEXT_6    DB 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-.'

.CODE
Main Proc
        Mov Ax,@data
        MOv DS,ax
        Mov ES,Ax
        WriteLn TEXT_1
        Mov Cx,8
        Lea DI,File_Name
A1:     Mov aH,8
        INT 21H
        CMP AL,0DH
        JE BREAK_
        PUSH CX
        PUSH DI
        Mov Cx,26
        LEA DI,TEXT_5
        REPNE SCASB
        jz   A3
        LEA DI,TEXT_6
        Mov CX,38
        REPNE SCASB
        JNZ A1
        JMP A4
A3:     SUB AL,20H
A4:     Mov ah,2
        Mov dl,al
        int 21h
        POP DI
        STOSB
        Pop CX
        Loop A1
BREAK_:
        NEWLINE
        Writeln TEXT_4
        NEWLINE
        WRITELN TEXT_3
A5:     Mov Ah,8
        int 21h
        cmp al,'a'
        je A5_2
        cmp al,'r'
        je A5_2
        cmp al,'s'
        je A5_2
        cmp al,'h'
        je A5_2
        jmp A5_3
A5_2:   SUB AL,20H
A5_3:   cmp al,'A'
        JE A6
        cmp al,'R'
        je A6
        cmp al,'H'
        je A6
        cmp al,'S'
        je A6
        jmp A5
A6:     Printf
        Mov ATTRIBUTE,AL
;
; MAKE NEW FILE
;
        CALL MF
        DOS
        MAIN ENDP
        end

[2-2.asm]
.MODEL SMALL
PUBLIC MF
Extrn Handle:WORD,File_name:Byte,ATTRIBUTE:Byte
.CODE
MF PROC
        Mov CX,0
        CLC
        CMP ATTRIBUTE,'A'
        JNE A71
        Mov CL,0
        JMP A8
A71:    Cmp ATTRIBUTE,'R'
        jne A72
        MOV CL,1
        JMP A8
A72:    CMP ATTRIBUTE,'H'
        JNE A73
        MOV CL,2
        JMP A8
A73:    CMP ATTRIBUTE,'S'
        JNE A8
        MOV CL,4
A8:     Mov ah,3ch
        LEA DX,FILE_NAME
        INT 21H
        MOV HANDLE,AX
        MOV AH,3EH
        MOV BX,HANDLE
        INT 21H
        RET
        MF  ENDP
        END

PROBLEM:
1'Why ATTRIBUTE OF FILE is 'A' ONLY?
2. Why Extension 'TXT' not set?
Note :
I use MASM For Dos ver. 6.15
I'm Newly.

Gustav


> 2. Why Extension 'TXT' not set?

you should possibly code:

File_name DB 8 DUP(' '),'TXT',0

> 1 'Why ATTRIBUTE OF FILE is 'A' ONLY?

my guess is that your "printf" macro destroys AL

vasant

Sorry! I forget Past Macro

{MACRO)
NEWLINE MACRO
Push ax
Push dx
Mov ah,2
Mov dl,0ah
Int 21H
Mov dl,0Dh
INT 21h
POP Dx
Pop AX
ENDM
WriteLn MACRO String
PUSH DX
Push Ax
Lea Dx,String
Mov aH,9
Int 21h
POp AX
POP DX
ENDM
DOS MACRO
Mov AH,4CH
INT 21H
ENDM
PRINTF MACRO
PUSH DX
PUSH AX
MOV DL,AL
MOV AH,2
INT 21H
POP DX
POP AX
ENDM
;--------------------------------------------------------

vasant

I compile code but .TXT no show in filename 's new file.

I will try your guide.

Gustav


PRINTF MACRO
PUSH DX
PUSH AX
MOV DL,AL
MOV AH,2
INT 21H
POP DX           ;<--- wrong order
POP AX           ;<---
ENDM

vasant

Printf macro  clear.
Thank you.

But problem  filename not clear.

MichaelW

If the JNZ A1 jump is taken it will cause a stack imbalance.

A1:     Mov aH,8
        INT 21H
        CMP AL,0DH
        JE BREAK_
        PUSH CX          <===
        PUSH DI          <===
        Mov Cx,26
        LEA DI,TEXT_5
        REPNE SCASB
        jz   A3
        LEA DI,TEXT_6
        Mov CX,38
        REPNE SCASB
        JNZ A1           <=== loop could repeat here
        JMP A4
A3:     SUB AL,20H
A4:     Mov ah,2
        Mov dl,al
        int 21h
        POP DI           <===
        STOSB
        Pop CX           <===
        Loop A1


You might try testing each part of your code separately. For example, create a test program that contains only the code that accepts the file name and code to display the file name. That way you are dealing with only one problem at a time.
eschew obfuscation

vasant