run external bat file in 16bit dos assembly?

Hi All!

I would like to ask, if there are any way of executing a batch file in assembly, by dos. I'm using microsoft mams!

Thanks!

SoftMan

Comments

  • : Hi All!
    :
    : I would like to ask, if there are any way of executing a batch file in assembly, by dos. I'm using microsoft mams!
    :
    : Thanks!
    :
    : SoftMan
    :
    sure. You'd issue a load/execute function like this:

    [code]
    .model small
    .code
    ORG 100H
    main: Jmp start

    save_ss dw ?
    save_sp dw ?
    cmd1len db 7 ; length of the cmd
    cmd1txt db 'mybatch',0dh,0 ; batch file to call

    start:
    push ax
    push bx
    push cx
    push dx
    Mov bx,offset endflag
    mov cl,4
    shr bx,cl
    inc bx
    mov ax,cs
    mov es,ax
    mov ah,4ah
    int 21h
    mov ax,cs
    mov ds,ax
    mov ax,offset cmd1len
    mov si,ax

    mov ax,ss
    mov save_ss,ax
    mov save_sp,sp
    int 2eh

    Mov ax,cs:save_ss
    mov ss,ax
    mov sp,cs:save_sp
    pop dx
    pop cx
    pop bx
    pop ax

    exit:
    mov ax,4c00h
    int 21h
    endflag label near

    END MAIN
    [/code]

    Sorry about the COMPLETE lack of comments. I wrote this years ago when I thought I'd remember how everything worked.

    This is MASM friendly, compile it into a COM file.

    Basically it points to free memory just beyond the end of the program, then calls the load/execute function in DOS. I think you can replace 'mybatch' with 'command.com' and do a DOS shell with it, provided command.com is in the same directory as this program. Otherwise, add the full path to the file you want to call.
    Be sure to change the cmd1len parameter based on how long the program is you want to call. Check ole ralph brown's interrupt list for the specifics of the INT 21h's that are called.

    good luck,

    -jeff!

  • Thank you wery much for your help. Actualy my msdos book does not contain any information about this interrupt. It only says "Reserved" so you saved my life!

    Softman


    : : Hi All!
    : :
    : : I would like to ask, if there are any way of executing a batch file in assembly, by dos. I'm using microsoft mams!
    : :
    : : Thanks!
    : :
    : : SoftMan
    : :
    : sure. You'd issue a load/execute function like this:
    :
    : [code]
    : .model small
    : .code
    : ORG 100H
    : main: Jmp start
    :
    : save_ss dw ?
    : save_sp dw ?
    : cmd1len db 7 ; length of the cmd
    : cmd1txt db 'mybatch',0dh,0 ; batch file to call
    :
    : start:
    : push ax
    : push bx
    : push cx
    : push dx
    : Mov bx,offset endflag
    : mov cl,4
    : shr bx,cl
    : inc bx
    : mov ax,cs
    : mov es,ax
    : mov ah,4ah
    : int 21h
    : mov ax,cs
    : mov ds,ax
    : mov ax,offset cmd1len
    : mov si,ax
    :
    : mov ax,ss
    : mov save_ss,ax
    : mov save_sp,sp
    : int 2eh
    :
    : Mov ax,cs:save_ss
    : mov ss,ax
    : mov sp,cs:save_sp
    : pop dx
    : pop cx
    : pop bx
    : pop ax
    :
    : exit:
    : mov ax,4c00h
    : int 21h
    : endflag label near
    :
    : END MAIN
    : [/code]
    :
    : Sorry about the COMPLETE lack of comments. I wrote this years ago when I thought I'd remember how everything worked.
    :
    : This is MASM friendly, compile it into a COM file.
    :
    : Basically it points to free memory just beyond the end of the program, then calls the load/execute function in DOS. I think you can replace 'mybatch' with 'command.com' and do a DOS shell with it, provided command.com is in the same directory as this program. Otherwise, add the full path to the file you want to call.
    : Be sure to change the cmd1len parameter based on how long the program is you want to call. Check ole ralph brown's interrupt list for the specifics of the INT 21h's that are called.
    :
    : good luck,
    :
    : -jeff!
    :
    :

  • : Thank you wery much for your help. Actualy my msdos book does not contain any information about this interrupt. It only says "Reserved" so you saved my life!
    : Softman

    Hello,
    Jef's referance to Ralf Browns interrupt list sounds like what you need
    for future referance & problem solving. If you haven't got it, do a
    www.google.com search for "Ralf Brown interrupt list"
    it's a free down load that consists of about 7 files of 300k each.
    inter61A.zip A,B,C,D,E,F + supliments er something.
    I choze to copy all the int list files to one sub directory,
    then copy all the files to one file, (allints.txt)
    then a string search for what I want was the solution.

    type allints.txt | find /I "%1" > myfinds.txt

    in a batch file would help me find key words to search for.
    There is PORTS.A A,B,C,D,E,? for port info
    MEMORY.LST gives absolute addresses of info for bios, vector table, etc.
    Anyway the RB list is a must.

    Bitdog

  • Thanx, I'v downloaded the Ralf Browns interrupt list. That's what I needed.

    : : Thank you wery much for your help. Actualy my msdos book does not contain any information about this interrupt. It only says "Reserved" so you saved my life!
    : : Softman
    :
    : Hello,
    : Jef's referance to Ralf Browns interrupt list sounds like what you need
    : for future referance & problem solving. If you haven't got it, do a
    : www.google.com search for "Ralf Brown interrupt list"
    : it's a free down load that consists of about 7 files of 300k each.
    : inter61A.zip A,B,C,D,E,F + supliments er something.
    : I choze to copy all the int list files to one sub directory,
    : then copy all the files to one file, (allints.txt)
    : then a string search for what I want was the solution.
    :
    : type allints.txt | find /I "%1" > myfinds.txt
    :
    : in a batch file would help me find key words to search for.
    : There is PORTS.A A,B,C,D,E,? for port info
    : MEMORY.LST gives absolute addresses of info for bios, vector table, etc.
    : Anyway the RB list is a must.
    :
    : Bitdog
    :
    :

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