2013-10-24 100 views
1

我希望做两件事情:
1)采取从用户
2串)查找长度的输入字符串的

我试着下面的代码串的长度:

.model small  
.stack 100h 
.data 
    MAXLEN DB 100 
    ACT_LEN DB 0    ;Actual length of the string 
    ACT_DATA DB 100 DUP('$') ;String will be stored in ACT_DATA 
    MSG1 DB 10,13,'ENTER STRING : $' 
.CODE 
START: 
    MOV AX,@data 
    MOV DS,AX 
    ;Normal printing 
    LEA DX,MSG1 
    MOV AH,09H 
    INT 21H 
    ;Cant understand code from here! 
    LEA DX,ACT_DATA 
    MOV AH,0AH 
    MOV DX,OFFSET MAXLEN 
    INT 21H 

    LEA SI,ACT_DATA 
    MOV CL,ACT_LEN 

    ;AND THEH SOME OPERATIONS 

END START 

但我很困惑如何将长度存储在CL寄存器中,即ACT_LEN值如何递增?而实际上mov AH,0A与长度有关系吗?

回答

3

Int 21/AH=0Ah

Format of DOS input buffer: 

Offset Size Description  (Table 01344) 
00h BYTE maximum characters buffer can hold (MAXLEN) 
01h BYTE (call) number of chars from last input which may be recalled (ACT_LEN) 
(ret) number of characters actually read, excluding CR 
02h N BYTEs actual characters read, including the final carriage return (ACT_DATA) 

缓冲的输入中断将在这些值填补。

LEA DX,ACT_DATA 
MOV AH,0AH 
MOV DX,OFFSET MAXLEN 
INT 21H 

你不需要LEA DX,ACT_DATA

mov AH,0A是中断调用的次数。描述的中断和进出的内容。

+2

ACT_LEN值如何改变。是否我没有得到你!是否全部通过指令MOV AH,0Ah通过偏移01h完成? –

相关问题