从命令提示符读取字符并将它们用于 8086 程序集中的路径名
Reading characters from command prompt and using them for path-name in 8086 assembly
我的程序有目的:从命令行读取符号并将它们用作转到另一个目录的完整路径名。
如果我将缓冲区定义为 "P:\test\" 而不是从命令行输入符号,则该程序可以工作,因此问题出在读取字符上。
但是,我尝试使用以下方法打印出我的缓冲区:ah 02h int 21h(单字符输出)并正确输出。
.model small
.stack 100h
.data
dir db 255 dup (0)
.code
start:
mov dx, @data
mov ds, dx
xor cx, cx
mov cl, es:[80h]
mov si, 0082h ;reading from command prompt 0082h because first one is space
xor bx, bx
l1:
mov al, es:[si+bx] ;filling buffer
mov ds:[dir+bx], al
inc bx
loop l1
mov dx, offset dir ;going to directory
mov ah, 3Bh
int 21h
mov ah, 4ch
mov al, 0
int 21h
end start
命令行的末尾总是 0Dh
。所以 es:[80h]
中的值(命令行中的字符数)太大了。此外,路径的结尾必须为 Int 21h/AH=3Bh
无效("ASCIZ" 表示:ASCII 字符加零)。
这个应该有效:
.model small
.stack 1000h ; Don't skimp on stack.
.data
dir db 255 dup (0)
.code
start:
mov dx, @data
mov ds, dx
xor cx, cx
mov cl, es:[80h]
dec cl ; Without the last character (0Dh)
mov si, 0082h ; reading from command prompt 0082h because first one is space
xor bx, bx
l1:
mov al, es:[si+bx] ; filling buffer
mov ds:[dir+bx], al
inc bx
loop l1
mov byte ptr [dir+bx], 0 ; Terminator
mov dx, offset dir ; going to directory
mov ah, 3Bh
int 21h
mov ax, 4C00h ; Exit with 0
int 21h
end start
您是否认为 Int 21h/AH=3Bh
不能更改盘符?
我的程序有目的:从命令行读取符号并将它们用作转到另一个目录的完整路径名。 如果我将缓冲区定义为 "P:\test\" 而不是从命令行输入符号,则该程序可以工作,因此问题出在读取字符上。 但是,我尝试使用以下方法打印出我的缓冲区:ah 02h int 21h(单字符输出)并正确输出。
.model small
.stack 100h
.data
dir db 255 dup (0)
.code
start:
mov dx, @data
mov ds, dx
xor cx, cx
mov cl, es:[80h]
mov si, 0082h ;reading from command prompt 0082h because first one is space
xor bx, bx
l1:
mov al, es:[si+bx] ;filling buffer
mov ds:[dir+bx], al
inc bx
loop l1
mov dx, offset dir ;going to directory
mov ah, 3Bh
int 21h
mov ah, 4ch
mov al, 0
int 21h
end start
命令行的末尾总是 0Dh
。所以 es:[80h]
中的值(命令行中的字符数)太大了。此外,路径的结尾必须为 Int 21h/AH=3Bh
无效("ASCIZ" 表示:ASCII 字符加零)。
这个应该有效:
.model small
.stack 1000h ; Don't skimp on stack.
.data
dir db 255 dup (0)
.code
start:
mov dx, @data
mov ds, dx
xor cx, cx
mov cl, es:[80h]
dec cl ; Without the last character (0Dh)
mov si, 0082h ; reading from command prompt 0082h because first one is space
xor bx, bx
l1:
mov al, es:[si+bx] ; filling buffer
mov ds:[dir+bx], al
inc bx
loop l1
mov byte ptr [dir+bx], 0 ; Terminator
mov dx, offset dir ; going to directory
mov ah, 3Bh
int 21h
mov ax, 4C00h ; Exit with 0
int 21h
end start
您是否认为 Int 21h/AH=3Bh
不能更改盘符?