flat assembler
Message board for the users of flat assembler.
Index
> DOS > Cannot get command line tail from parameter structure |
Author |
|
ChrisLeslie 06 Jun 2006, 09:11
Hmmm! Perhaps I did not make the problem clear:
I am writing a .com program that calls up a child program. I am able to call a child program OK but I cannot pass a command line argument to the child program. The DOS interupt that enables this expects that the address of the string with my command line is part of a memory block. I have defined a structure to form the memory block. My problem is that the DOS interupt will not pick up the part of the structure with the comman line address. I am not sure if: 1) I am putting the address correctly to the structure, or 2) If I am addressing the whole structure correctly, or 3) maybe something else is wrong. I have not used structures much in the past and I am also not sure about the FASM syntax. My code in the post uses fasmw.exe as the child program to call up, and the command line could be any text file. Chris |
|||
06 Jun 2006, 09:11 |
|
LocoDelAssembly 06 Jun 2006, 15:34
http://board.flatassembler.net/topic.php?t=5193 <- This calls a child program passed as argument, check it out.
Hope it helps you Regards |
|||
06 Jun 2006, 15:34 |
|
ChrisLeslie 06 Jun 2006, 22:00
Thanks locodelassembly. However, your example passes a child program as an argument. My problem is different as I need to pass an argument WITH the child program. I have looked at your code and I can't see any tips in there to help me. Any other suggestions?
Regards Chris |
|||
06 Jun 2006, 22:00 |
|
LocoDelAssembly 06 Jun 2006, 23:13
Code: ;Parent program org 100h jmp begin child db "C:\fasm\fasmw.exe",0 cmdLine db 12," parent3.asm",0dh msg1 db "Cannot resize memory block",0dh,1Ah,'$' msg2 db "Error trying to execute",0dh,0ah,'$' struc paramBlock env,cmdLine,f1,f2 { .env dw env .pcmd dd cmdLine .f1 dd f1 .f2 dd f2 } my paramBlock 0,0,0,0 ;establish an instance of paramBlock with cmdLine begin: mov bx,50h ; resize memory block mov ah,4Ah int 21h jc resizeProblem mov word [my.pcmd], cmdLine mov word [my.pcmd+2], cs mov dx,child mov bx,my.env ; not sure here if I am passing the address of the parameter block mov ax,4B00h int 21h jc executeProblem jmp quit executeProblem: mov ah,09h mov dx,msg2 int 21h jmp quit resizeProblem: mov ah,09h mov dx,msg1 int 21h jmp quit quit: mov ax,4C00h int 21h http://board.flatassembler.net/topic.php?t=290 <- Here there is an example by Tomasz too. Also note I relocated the instantiation of the structure, I did't do that for styling I did that to prevent the execution of the structure. You was extremately lucky that the structure by accident has data which also was valid opcodes (for example 0000h is ADD [BX+SI], AL). Regards [edit] Here a struc for make cmd lines Code: struc CmdLine cmdLine { . db 0, cmdLine, $0D store $ - . - 2 at . } cmdLine CmdLine "test.asm" ; A space at the start seems to be unnecesary anotherCmdLine CmdLine "fasm.asm" I don't remember which is the size limit for the cmdline, if you know which is then add that check. At this time you have a limit of 255 bytes.[/edit] |
|||
06 Jun 2006, 23:13 |
|
ChrisLeslie 07 Jun 2006, 02:48
Thankyou again locodelassembly.
The key section of code that made it all work was "mov word [my.pcmd+2], cs". Since my.pcmd is a dword then you have moved the word cmdLine address into the high word end but I can't understand why we need to move cs to the low word end. Can you explain to me why this is needed. Regards Chris |
|||
07 Jun 2006, 02:48 |
|
LocoDelAssembly 07 Jun 2006, 14:00
Because this COM file is running on 16-bit mode so when something is asking you for a dword ptr that means you need both offset and segment. Note that since in COM executables CS = DS = SS = ES you can use any of these. Note that actually I'm moving CS to the high word and the offset to low word, it's little endian.
Regards |
|||
07 Jun 2006, 14:00 |
|
ChrisLeslie 07 Jun 2006, 22:21
That makes sense. I thank you very much for your interest in helping me.
Regards Chris |
|||
07 Jun 2006, 22:21 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.