Solved

command line parameters without PSP

Posted on 2004-10-11
2
425 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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