2014-10-27 41 views
0

你好我真的很陌生,我仍然有點迷路了,無論我在網上讀了多少次論壇或者教程,它仍然很模糊。所以我的第一個任務是從用戶讀取一個字符串並將其存儲在數據段中。我也想假設字符串的長度爲20個字符或更少,並且用戶永遠不會輸入超過20個字符。我將如何去做這件事?我目前有:從用戶那裏讀取一個字符串並將其保存

mov ah, 0Ah   ; Function 0Ah Buffered input 
mov dx, string_buf ; ds:dx points to string buffer 
int 21h 

我不認爲然而這會工作...

回答

-1

我愛的彙編語言和Im很高興你想了解它。但你似乎對此有點新,我會建議拿一本書。我認爲很好的一個是大會的藝術和x86大會。也就是在幾晚前剛剛開始之後進行的,你的語法並不是真正的裝配體的工作方式,所以我保證在閱讀其中一本書後你會變得更好。

+0

感謝然而建議,並沒有完全回答我的問題... – user2961971 2014-10-27 21:57:38

+0

是啊我很抱歉我不能回答你的問題,但我想只是幫助你。 @ user2961971 – JohnS 2014-10-27 22:15:59

+0

你的代碼應該可以工作,只要你在一個可以運行DOS的環境中(可能是一個模擬器,如今是DosBox或其他)。您必須提供Dirk和Ralf顯示的緩衝區。你爲什麼認爲這不起作用? – 2014-10-28 03:04:18

1

這個DOS軟件中斷需要一個輸入緩衝區。

  ; Example using Microsoft Macro Asssembler (MASM) 

.MODEL small 
.STACK 100h 

.DATA 
BUFF DB 20 
ACTR DB ? 
ASCII 20 dup DB ("$") 
DB "$" ; We needd to have one "$" for print function. 

.CODE 
START: 
MOV AX, @DATA 
MOV DS, AX 
MOV AH, 0Ah   ; Function 0Ah Buffered input 
MOV DX, OFFSET BUFF ; ds:dx points to string buffer 
INT 21h 

MOV AH, 9   ; Print to output device 
MOV DX, OFFSET ASCII ; ds:dx points to string 
INT 21h 

MOV AX, 4C00h  ; Return to DOS with ERRORLEVEL=0 
INT 21h 
END START 

-

Ralf Browns x86/MSDOS Interrupt List(RBIL) 
http://www.pobox.com/~ralf 
http://www.pobox.com/~ralf/files.html 
ftp://ftp.cs.cmu.edu/afs/cs.cmu.edu/user/ralf/pub/ 

inter61b.zip->INTERRUP.F 
--------D-210A------------------------------- 
INT 21 - DOS 1+ - BUFFERED INPUT 
AH = 0Ah 
DS:DX -> buffer (see #01344) 
Return: buffer filled with user input 
Notes: ^C/^Break are checked, and INT 23 is called if either detected 
reads from standard input, which may be redirected under DOS 2+ 
if the maximum buffer size (see #01344) is set to 00h, this call returns 
immediately without reading any input 
SeeAlso: AH=0Ch,INT 2F/AX=4810h 

Format of DOS input buffer: 
Offset Size Description (Table 01344) 
00h BYTE maximum character buffer can hold 
01h BYTE (call) number of chars from last input which may be recalled 
    (ret) number of characters actually read, excluding CR 
02h N BYTEs actual characters read, including the final carriage retur 
相關問題