Hello all,
I would like to ask for a little help ,basicaly what im trying to do is to get a program parameter from the command line (example : test.com file.txt) and use this parameter as a filename for opening a file but somehow i cant make my programm working :(

the source code :
%define STDOUT 0x0001


SECTION .text

org 0x100

mov bp,STDOUT


    mov ax, datap
    mov ds, ax

    mov si, 0x80      ; cmd parameters offset.

    ; copy command line to our buffer:
    xor cx, cx      ; zero cx register.
    mov cx, [0x81] ; get command line size.
    or cx,cx
    jz  no_param    ; then skip the copy.   
    mov di,cx
    add di,cx
    inc di
    mov byte ,'$'
    ;;;;;;;;My MOD OF THE SOUCE CODE;;;;;;;;it should open the file from the program parameter
    mov ax,0x3D  ;open the file
    mov dx,datap                ;filename
    int 0x21 
    jc erro
    mov bx,ax ;id of the opened file
    jmp short read_znak
   
read_znak:
mov ah,0x3F
mov dx,buffer ;here we write to the buffer
mov cx,0x1

int 0x21

cmp byte ,0x41 ;filtering out all the ASCII stuff that is below 0x41
jb vypis

cmp byte , 0x5A          ;filtering out all the ASCII stuff that are between big and small letters
ja dalsi_test

jmp newmarker

dalsi_test:
cmp byte , 0x61          ;upper boundary
jb vypis


newmarker:
cmp byte ,0x40 ;is it a big letter?
ja docasne_velke ;jump to the next test
jb docasne_male ;jump to he next test


docasne_velke:
cmp byte ,0x5B ;control of the upper boundary
jb velke_na_male
;ja male_na_velke
jmp docasne_male


docasne_male:
cmp byte ,0x60 ;lower
ja male_na_velke
jmp docasne_velke


vypis:
or ax,ax ; the same as cmp ax,0 but this should be faster
jz konec_citania

mov cx,ax
mov ah, 0x40 ;we are gonna write to the STDIOU
xchg bp,bx

int 0x21

xchg bp,bx
jmp read_znak

velke_na_male:
add byte ,0x20 ;make big letters to small
jmp vypis

male_na_velke:
sub byte ,0x20    ;and vice versa
jmp vypis

konec_citania:
mov ah,0x3E
int 0x21

konec:
mov ah,4CH
int 0x21


no_param:
mov ah,0x9
mov dx,nopara
int 0x21
mov al,1
jmp short konec



erro:
mov ah,0x9
mov dx,open_error
int 0x21
mov al,1
jmp short konec







SECTION .data
nazov_suboru db "test.sbr",0
open_error db "Prepacte ale subor sa otvorit neda",0xd,0xa,'$'
nopara db "ERROR:Ziaden parameter na vstupe...",0xd,0xa,'$'


SECTION .bss
buffer resb 0x1 ;buffer for 1 byte
datap resb 0x21
Posted on 2006-11-26 14:22:22 by psicho
I don't quite understand 16-bit ASM popgramming
But I know there is a site full of that information
Try this http link, maybe you'll find the answer you want::
http://courses.ece.uiuc.edu/ece390/books/artofasm/artofasm.html
Posted on 2006-11-27 01:26:18 by guidry
You should access the PSP (Program Segment Prefix) and grab the command line argument and also the command line length.

Your question, however, has been answered in this post

If you are looking for a ready-to-use procedue that can do all that for you, you can download OASML 1.0 library and use the procedure included in the "DOS.asm" unit.

Good luck.
Posted on 2006-11-27 13:45:57 by XCHG