我不知道如何使用中断21,AH = 0AH [英] I don't understand how to use Interrupt 21, AH=0ah
问题描述
我的信息是从这里到来。分配要求一个程序,读取不超过20个字符,这些字符转换为大写,然后打印输入的首都。
我不知道如何从INT21 / AH = 0AH访问输入。我真的,除非我明白什么是上面链接不能要求一个更precise问题。有人能解释一下吗?另外,我使用TASM如果让任何区别。另外,我上的FreeDOS测试这个。
UPDATE1:
好吧,感谢你的帮助,我相信我明白中断需要如何设置和行为方式。
设置:
我必须指定一个DS:DX,我想这个缓冲区存在
我必须设置DS:DX 20(设置字符的最大数量的缓冲区可容纳)
我必须设置DS:DX + 1改为0(我认为这在某种程度上设定最低数目的字符阅读)
实际调用INT21 / AH = 0AH,这将去DS:DX和跨preT的preSET字节。在等待输入它会停止程序
INT21 / AH = 0AH将填补从DS:DX + 2 + N与我的输入(其中n是包括'\\ r'字符输入的数量)
我的问题是,现在,我该怎么做。我刚刚通过x86汇编语言参考看了一遍,但一直没能找到什么有用的呢。
code,我走到这一步
假设CS:code,DS:code
code段
开始: MOV AX,code;移动code段进章AX
MOV DS,AX;使得DS指向code段 MOV啊,0AH
INT 21H
MOV AX,1234H;断点 MOV啊,9
MOV DX,偏移消息
INT 21H现在结束:
;;;;;;;;;;结束程序;;;;;;;;;;
MOV啊,0;终止程序
INT 21H;程序结束消息分贝世界,你好!,13,10,$
code端
年底启动
这是DOS功能检索与用户输入的缓冲区。看到这个表。似乎程序正在使用该呼叫暂停执行等待用户恢复程序
编辑:我只是重读的问题。我还以为你只是要求什么函数调用在给定的源一样。如果你想读不超过20个字符的输入,你首先需要内存来存储它。加入这样的:
BUFFERSIZE 21分贝; 20个字符+ RETURN
inputLength分贝0;的读字符数
缓冲分贝21 DUP(0);实际缓冲区
然后填写缓冲区:
MOV AX,CS
MOV DS,AX;确保CS == DS
MOV DX,偏移缓冲区大小;加载我们指针结构的开始
MOV啊,0AH; getline函数的
INT 21H
如何转换为大写留给读者。
My information is coming from here. The assignment asks for a program that reads in no more than 20 characters, converts those characters to upper case, and then prints the input as capitals.
I have no idea how to access the input from int21/AH=0ah. I really can't ask a more precise question unless I understand what is linked above. Can someone explain? Also, I'm using TASM if that makes any difference. Also, I'm testing this on freedos.
UPDATE1:
Alright, thanks to your help, I believe I understand how the interrupt needs to be set up and behaves.
Setup: I have to designate a ds:dx where I want this buffer to exist
I have to set ds:dx to 20 (which sets the max number of characters the buffer can hold)
I have to set ds:dx+1 to 0 (which I think somehow set a min number of characters to read in)
Actually call int21/AH=0ah, which will go to ds:dx and interpret the preset bytes. It will halt the program while it waits for input
int21/AH=0ah will fill from ds:dx+2+n with my input (where n is the number of characters input including '\r')
My question is now, how do I do this. I've just looked through the x86 Assembly Language Reference again, but haven't been able to find anything helpful yet.
Code I've got so far
assume cs:code,ds:code
code segment
start:
mov ax,code ;moves code segment into reg AX
mov ds,ax ;makes ds point to code segment
mov ah,0ah
int 21h
mov ax,1234h ;breakpoint
mov ah,9
mov dx,offset message
int 21h
endNow:
;;;;;;;;;;ends program;;;;;;;;;;
mov ah,0 ;terminate program
int 21h ;program ends
message db 'Hello world!!!',13,10,'$'
code ends
end start
That DOS function retrieves a buffer with user input. See this table. It seems that program is using that call to pause execution waiting for the user to resume the program.
Edit: I just reread the question. I thought you were only asking what the function call did in your given source. If you want to read input of no more than 20 characters, you first need memory to store it. Add something like this:
bufferSize db 21 ; 20 char + RETURN
inputLength db 0 ; number of read characters
buffer db 21 DUP(0) ; actual buffer
Then fill the buffer:
mov ax, cs
mov ds, ax ; ensure cs == ds
mov dx, offset bufferSize ; load our pointer to the beginning of the structure
mov ah, 0Ah ; GetLine function
int 21h
How to convert to uppercase is left to the reader.
这篇关于我不知道如何使用中断21,AH = 0AH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!