Solved

command line parameters without PSP

Posted on 2004-10-11
2
400 Views
Last Modified: 2008-03-06
Hi I need some help.
I am writing an Assembly program that makes use of command line parameters. I know how to accomplish the program with PSP (Program Segment Prefix), but I may not use the PSP as the target for interrupt 21 function 9.i need to copy the entire command line into another string variable that I have created in the data segment.

Look thru many tutorials but they all use PSP, it makes sense using it but my Lecturer disagrees.
I am not trying to abuse expert-exchange, and I also do not want to waste the expert’s time with my basic question, this is really my last option and I would appreciate your help.


Thanks
TRG
0
Comment
Question by:TRG00
2 Comments
 
LVL 22

Accepted Solution

by:
grg99 earned 200 total points
ID: 12275345
A few questions:

Are you trying to print out the command line using  function 9 of int 21h?

If so, that's not going to work very well, as the command line is stored in the PSP as a Pascal-style string,
i.e. a length byte followed by the characters.   Function 09 of int21h expects a zero-terminated string.

There are THREE ways you can print out this string:

(1)  Put a zero byte after the end of the string in the PSP.  Kinda dirty to mess with the PSP though!

(2)  Copy the string somewhere else and zero terinate it, then call Function 09.

(3)  Print the string out one character at a time from the PSP.


Here's roughly how to do (3):

; set2var.asm
; Version 0.2 - 8/aug/2004
; By Brad Driver
;
; Originally based on command-line demo code by HoaX_69.
;

      .model small
      .stack

      .data


PSP_SEG            segment at 00h                  ;Define segment for addressing PSP information
      org      80h                        ;Command line data offset is 80h(in PSP)
      
      CMD_LEN            db      ?            ;Bytes in command-line
      CMDS            db      127 dup(?)      ;Command line start

PSP_SEG            ends                        ;End of PSP segment definition




display_params      proc

    xor   ax,ax
    mov   es,ax   ; point es to PSP

      mov      ah, 02h                  ;Prepare for single-char printing
      xor      cl, cl                  ;Set cl(counter) to 0

      assume      es:PSP_SEG            ;Associate es with PSP_SEG

      lea      bx, CMDS            ;Load address of CMDS into bx
      inc      cl                  ;Increase counter
      inc      bx

print_loop:
      mov      dl,es: [bx]            ;Move byte at bx into dl
      int      21h                  ;and print it
      inc      cl                  ;Increase counter
      inc      bx                  ;and increase pointer
      cmp      cl, CMD_LEN            ;Check if we have reached the end of the string
      jnz      print_loop            ;if not, then continue printing characters

      ret

display_params      endp


0
 

Author Comment

by:TRG00
ID: 12284512
What i  think i have to do is from the command line:
ex: pro.com text.txt

Copy the command line to a strings, with the interrupt 21h.
And then contiue working with the parameter in the comand line.(Create the file)

So your option 2, if you have a sugestion how to go about it, i would appreciate it.

Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Citrix policies are the most efficient method to configure and tune XenDesktop environments, allowing organizations to control connection, security and bandwidth settings based on various combinations of users, devices or connection types.  Citrix …
When converting a physical machine to a virtual machine using VMware vCenter Converter Standalone or vCenter Converter Enterprise, if an adapter type is not selected during the initial customization the resulting virtual machine may contain an IDE d…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question