Re: Display file name



news wrote:
I try 4 methods : the last use moh ah,0eh int 10h

the aim : display th name of the file, i just run.

You appear to be trying to display the first FCB (File Control Block). Is that what you have in mind?

When i use Debug, it is ok ; alone, the file no nothing
Below, my asm

mov bl,16h ; for offset of T1

Why not "mov bx, offset T1"? Assuming you're assembling to a .com file, have you got "org 100h" (or equivalent for your assembler) in there somewhere?

mov si,005dh ; the good address

ici: lodsb

inc bx ; give a good offset

???

mov [offset moi+1],bl

Okay, you modify your code...

xchg ax,bx

nop ; wait : i change th address of the offset below

xchg ax,bx

??? If this is intended to make sure the code you're modifying isn't already in cache, it isn't enough. Shouldn't be necessary anyway... unless you're running an 8086 or 80186...

moi: mov offset t1,al ; change the place of the letters

Copy FCB to T1?

cmp al,20h

jne ici

jmp short suite

t1 db: ,0,0,0,0 ,0,0,0,0�,0,0,0 ,10,13,36

Dunno what that "funny character" is supposed to be.

suite: mov dx,offset t1 ; display the file name

mov ah,9

int 21h

Well... if your intent is to try out some self-modifying code, we could look into this more... If you just want to copy the FCB to a "terminated" string, I'd do something more like:

org 100h

mov si, 5Dh
mov di, offset T1

copyloop:
lodsb
cmp al, 20h
jz display
stosb
jmp copyloop
display:
mov dx, offset T1
.... etc.

If this is an MZ .exe file, you'll have to twiddle segment registers. Your FCB is in your PSP segment - where ds/es will point on startup. T1 is in your code segment. I guess you'd want to "push cs"/"pop es" before the "copyloop" and "push cs"/"pop ds" after the copy, but before you try to display T1... If it's a .com file, the "org 100h" is important...

; second method............

mov si,005dh

second:

lodsb

int 29h ; display char in al

cmp al,20h

jnz second

; 3rd method

mov si,005dh

third:

mov dl,[si]

mov ah,02

int 21h

inc si

cmp dl,20h

jne third

int 20h

Your second and third method ought to work. That is, if you type "myprog foo", you ought to see "FOO". If you just type "myprog", you wn't have anything in the first FCB, so you won't see anything. If you want to see "myprog", that's a little more complicated... (fetch the environment segment from PSP, then "walk" past the environment strings... terminated by two zeros and a word count of "extra strings" - always one, I think - and there will be the program name - "argv[0]" in C).

I'm really not sure what your question is...

Best,
Frank

.



Relevant Pages

  • Re: Display file name
    ... You appear to be trying to display the first FCB. ... mov bl,16h; for offset of T1 ...
    (comp.lang.asm.x86)
  • Display file name
    ... display th name of the file, ... mov bl,16h; for offset of T1 ... mov si,005dh; the good address ... int 29h; display char in al ...
    (comp.lang.asm.x86)
  • Again : diplay file name
    ... display the name file i run. ... mov di, offset T1 ... int 21h ...
    (comp.lang.asm.x86)
  • Time,Date,and Chime TSR
    ... Clock display can be toggled on and off by repeating 'chime'. ... Turning the chime off and on ... mov CS:count500,TICKS; Reset Count500 ...
    (alt.lang.asm)
  • Re: Time,Date,and Chime TSR
    ... Clock display can be toggled on and off by repeating 'chime'. ... Turning the chime off and on ... mov CS:count500,TICKS; Reset Count500 ...
    (alt.lang.asm)