flat assembler
Message board for the users of flat assembler.

Index > DOS > Executing batch files...

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 06 May 2004, 23:34
How to execute a ms-dos batch file (*.bat) from an asm program using function ah=4B,al=00 - int 21h ??
Post 06 May 2004, 23:34
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 07 May 2004, 05:35
You should execute system shell (in particular, command.com), with the /C parameter and path to the bath file.
Post 07 May 2004, 05:35
View user's profile Send private message Visit poster's website Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 07 May 2004, 16:11
Oh yeah, but how to adapt this to this code? I 'm how to do it?

Code:
      org     100h

; first, we need to free the conventional memory we don't use,
; so there will be some memory available for the program we want
; to run, if we used MZ format of executable, the directive
; "heap 0" would be enough for this purpose, in case of .com
; program we have to free that memory manually be resizing the
; memory block starting at our PSP (es is already set to it)

     mov     ah,4Ah                  ; resize memory block
       mov     bx,10010h shr 4         ; only memory needed for .com
       int     21h

; now set up the pointer to command line in the parameters block

     mov     word [cmdline],_command
     mov     word [cmdline+2],ds

; we are ready to execute the program now

    mov     ax,4B00h                ; load and execute program
  mov     dx,_program             ; ASCIIZ path of program
    mov     bx,params               ; parameter block
   int     21h

     int     20h                     ; exit program


_program db 'c:\command.com',0
_command db 0                                ; length of command line
     db 13                          ; must end with CR character

params:
environment dw 0       ; segment of environment, 0 means to use parent's one
cmdline dd ?               ; pointer to command line
default_fcb1 dd 0      ; pointers to file control blocks
default_fcb2 dd 0

    


Thanks
Post 07 May 2004, 16:11
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 09 May 2004, 10:14
Code:
        org     100h

; first, we need to free the conventional memory we don't use,
; so there will be some memory available for the program we want
; to run, if we used MZ format of executable, the directive
; "heap 0" would be enough for this purpose, in case of .com
; program we have to free that memory manually be resizing the
; memory block starting at our PSP (es is already set to it)

        mov     ah,4Ah          ; resize memory block
        mov     bx,10010h shr 4 ; only memory needed for .com
        int     21h

; now set up the pointer to command line in the parameters block

        mov     word [cmdline],_command
        mov     word [cmdline+2],ds

; we are ready to execute the program now

        mov     ax,4B00h        ; load and execute program
        mov     dx,_program     ; ASCIIZ path of program
        mov     bx,params       ; parameter block
        int     21h

        int     20h             ; exit program


_program db 'c:\command.com',0
_command db _end-$              ; length of command line
         db '/C test.bat'
    _end db 13                  ; must end with CR character

params:
environment dw 0                ; segment of environment, 0 means to use parent's one
cmdline dd ?                    ; pointer to command line
default_fcb1 dd 0               ; pointers to file control blocks
default_fcb2 dd 0    
Post 09 May 2004, 10:14
View user's profile Send private message Visit poster's website Reply with quote
Bitdog



Joined: 18 Jan 2004
Posts: 97
Bitdog 07 Jul 2004, 04:20
Resize memory block in a .COM file doesn't seem to do anything usefull.
The only thing I found it usefull for is SB sound DMA probramming
where an ABS full seg was needed, then you could find the next ABS seg
from CS:0000h and if it left enough room for your .COM code,
you could resize & move the stack into the remaining .COM's allocated memory.

If you resize memory for the .COM you don't have more segment space to allocate to other external segments since a .COM is only allotted one seg
and can't allocate other segments.

Please correct me if I'm wrong on anything.

Bitdog
Post 07 Jul 2004, 04:20
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.