Solved

command line parameters without PSP

Posted on 2004-10-11
2
417 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
debugging dll files in a .NET project 5 479
ASM problem 2 31 351
Windows 7, Delphi Code, Drawcolumn ERROR 13 411
How to Replace 2003 failover Cluster node 4 365
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In order to fulfill our mission of inspiring learning in the technology community, Experts Exchange is launching a Course of the Month program. Premium and Team Account members will have access to one course per month as a part of their membership, …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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