Solved

command line parameters without PSP

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now