anyone know about dynamic arrays...?

[b][red]This message was edited by emperor at 2002-10-30 5:31:40[/red][/b][hr]
I haven't been here long, but I had a quick look around and couldn't find an answer (I'm not even sure if this is the best place to post). I'm not too hot with assembly language programing (read: I'm stupid) so a foolproof (and NASM-specific!) reply would be appreciated. Basically I wondered if it were possible in assembler to EASILY create a dynamic array.

For example I'm currently trying to write a program which parses the arguments passed to it in the command line and would like to store the address of each argument somewhere in the data segment so that they can easily be accessed individually, without knowing how many there are going to be (eg so that theoretically you could use ah=9 int 21h or something to print them out in reverse order, if you were so inclined)

before I get on to parsing [es:82h] I'd like to know if there's anywhere I can put them! thanks


Comments

  • : [b][red]This message was edited by emperor at 2002-10-30 5:31:40[/red][/b][hr]
    : I haven't been here long, but I had a quick look around and couldn't find an answer (I'm not even sure if this is the best place to post). I'm not too hot with assembly language programing (read: I'm stupid) so a foolproof (and NASM-specific!) reply would be appreciated. Basically I wondered if it were possible in assembler to EASILY create a dynamic array.
    :
    : For example I'm currently trying to write a program which parses the arguments passed to it in the command line and would like to store the address of each argument somewhere in the data segment so that they can easily be accessed individually, without knowing how many there are going to be (eg so that theoretically you could use ah=9 int 21h or something to print them out in reverse order, if you were so inclined)
    :
    : before I get on to parsing [es:82h] I'd like to know if there's anywhere I can put them! thanks
    :
    :
    :
    [blue]Well, good question! Basically, you have a limit for the parameter count, so you do not need dynamic array. Let me explain - the cmd. line cannot exceed 127 symbols in length. Max. parameter count in that line can be 127/2 (2 symbols is a parameter of 1 char and 1 char is a separator) - it gives 64 params. Easy - you can keep the offsets in a static array as:

    [b]arrOfsCmdLnParms DW 64 DUP (0)
    arrOfsCmdLnCount Dw 0[/b]

    The cmd. line area [ES:0082h] can be destroyed by the default FCB when you processing files, so you should make a copy of it. Then parse that copy and fill the 'arrOfsCmdLnParms' and 'arrOfsCmdLnCount'.

    Now, if you really want a completely dynamic array - you need to use INT 21H Func. 48H/49H/4AH to allocate and reallocate blocks of memory, but this hassle is not worth it - unless you need that functionality somewhere else in the code.[/blue]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion