I' learning assembly and trying to process arguments. I can't figure out how to print nth character from arguments.
Here is code segment from my program:
CODE SEGMENT
ASSUME CS:CODE, DS:DATA, SS:ZAS
START:
; print nth character from arguments
mov dl, 81h+n ; replace n with number
mov ah, 2
int 21h
; end program
mov ah, 4ch
int 21h
CODE ENDS
END START
Not sure if I'm using incorrect syntax, or if I'm missing something important.
Edit: I found the solution to my problem.
mov dl, byte ptr ds:[82h]
mov ah, 2
int 21h
When I run exe file like this: "filename.exe arg" then at address 81h is byte ' '. At the address 82h is the first byte 'a'. Therefore my argument starts at address 82h relative to the ds. Also I have to read the argument before I load data segment [mov ax, SEG DATA; mov ds, ax].