PSP and making it a ASCIIZ string

I'm just getting into Assembly and was wanting to make a delete that will read from the command prompt for the file to delete. The delete needs a ASCIIZ string in DX. How do you convert from the PSP to a ASCIIZ string?

Comments

  • : I'm just getting into Assembly and was wanting to make a delete that will read from the command prompt for the file to delete. The delete needs a ASCIIZ string in DX. How do you convert from the PSP to a ASCIIZ string?
    :
    [green]
    In a .com file, your DTA in your PSP is 80h where a byte holds the input character count, everything after that is your command line input.
    80h ARGC arguement count on the command line
    81h space, follows program basename
    82h input string starts, & the last byte of input = 13 = CR = Carriage Return = Enter key pressed.

    A quickie way to change an INfile name to a usable ASCIIZ name is to change the 13=CR to 0=nul
    MOV AL,[80h] ;ARGC adr 80h immediate, direct addressing, AL=ARGC
    XOR AH,AH ; zero out AH bits
    MOV BX,81h ;I think it was 81h, check it
    ADD BX,AX ; add the command line length to the DTA addr
    MOV BYTE [BX],AH ;put the nul where the CR=13 was

    FNAME DB "MYFILE.EXT",0 ;this is an ASCIIZ file name declaired in .asm
    CMNDL DB " MYFILE.EXT",13 ;this is your command line input
    MOV DX,82h ; puts the address of your PSP ASCIIZ name in DX
    but it's actually DS:DX that File interrupts uses, so you need to
    PUSH CS
    POP DS ; move DS to the Code Seg Where the PSP is.

    I like to make an include file that parces the name & does some checks, then adds the nul ending.
    That way I don't have to rewrite it every time.

    In an .EXE file it's a bit different, but I've found the comand line
    sitting a few bytes before CS on start up
    MOV AX,CS
    SUB AX,100h ;could sub a smaller number
    MOV ES,AX
    MOV BX,1000h ; ES:BX = CS:0000 now

    TOP:
    MOV AL,[ES:BX]
    CMP AL,':' ;look backwards for some command line character
    JZ GOTIT
    DEC BX
    JNZ TOP

    Make a quickie/small .COM or .EXE and
    do some checks by printing out the PSP in a .COM file
    and pre startup data in an .EXE to find the data er DTA.
    Use different comand line input so you know what is your's
    There is an INTerrupt that gets you the DTA addr, try that?

    I have some command line parcers C:NASMINC16GIFNAMES.INC ,in
    http://bitdog.home.att.net/files/nasmenv.zip
    It's free, look around in it, use what you want, any way you want.
    Bitdog
    [/green]



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion