I'm writing a program in x86 MASM assembler, and I need access to the command line arguments provided when starting the program. I read on multiple websites that I can access these arguments at the Program Segment Prefix or PSP.
As a test, I tried printing the first character of the provided arguments. My problem is that (depending on how I try to access the PSP) I get the wrong character (or no character at all) in return.
...
mov ah, 21h
int 50h
mov ds, dx
mov ah, 0Ah
mov al, offset ds:[81h]
mov bh, 0
mov cx, 1
int 10h
...
Is this the right way of accessing the command line arguments? What am I missing? I tried accessing the arguments in a couple of different ways, so I'm sure my problem is caused by a lack of understanding about how to access information at a specific memory address with an offset.
Can someone explain to me how to access the command line arguments at the PSP, or how I can access something at a specific memory location in general?