NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: mik3ca on January 16, 2021, 07:17:03 PM

Title: Determining count of parameters on command line
Post by: mik3ca on January 16, 2021, 07:17:03 PM
My goal is to allocate at least 64KB conventional memory from DOS to use with my program and for me to try to achieve that I'm writing my own TSR since Int 21h function 48h (allocate memory) doesn't give me much despite dos reporting 500+KB free.

I'm using nasm and writing code as follows to follow the DOS COM format:

Code: [Select]
org 100h
mov SI,80h
lodsb
;result in AL

Documents everywhere state that offset 80h in the DOS program segment prefix will reveal the number of bytes used on the command line after the program name but this does not seem to be the case because AL never returns the correct value.

What could I be doing wrong here?
Title: Re: Determining count of parameters on command line
Post by: debs3759 on January 16, 2021, 07:53:44 PM
Have you set the value of DS? You can't assume it will be the same as CS. Try

Code: [Select]
    org     100h
    push    cs
    pop     ds
    mov     si,80h
    lodsb
Title: Re: Determining count of parameters on command line
Post by: mik3ca on January 17, 2021, 10:55:44 PM
ok ill look into that