?
Solved

command line parameters without PSP

Posted on 2004-10-11
2
Medium Priority
?
428 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 600 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

800 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