我有这段代码:
masm
model small
.data
Mystr db 'sssssssdsdsdsdsdsdsdddddddddddddd'
minb db ?
sum db ?
.code
;------------Процедуры_начало------------
mac macro x, y, z
mov ah, 02h
mov dh, y
mov dl, x
int 10h
mov ah, 09h
mov bl, z ;
int 10h
endm
mac2 macro ex
mov ah, 09h
mov al, ex
mov bh,0
mov bl, 1
int 10h
endm
; clear screen BIOS
clrs proc near
mov ax,0600h
mov bh,07h
mov cx,0000
mov dx,184fh
int 10h
mov ax,0
mov bx,0
mov dx,0
mov cx,0
ret
clrs endp
compare proc
cmp al, 10
jl @@metka
add al, 37h
mac2 al
mov dl, al
mov ah, 02h
int 21h
ret
@@metka:
add al, 30h
mac2 al
mov dl, al
mov ah, 02h
int 21h
ret
endp
vivod_number proc
mov AL, sum
and al, 0f0h
ror al, 4
call compare
mov al, sum
and al, 0fh
call compare
ret
endp
calc proc
mov SI, 0 ;j
mov DI, 0 ;i
mov AL, 0 ;sum
mov CL, 0FFh ;min
@while_OUT:
cmp Mystr[DI], 0
je @EndWhile_OUT
mov SI, 0
mov AL, 0
@while_IN:
mov BL, Mystr[SI]
cmp BL, 0
je @EndWhile_IN
mov BL, Mystr[DI]
cmp Mystr[SI],BL;
jne @IfNot_1;
inc AL
@IfNot_1:
inc SI
jmp @while_IN
@EndWhile_IN:
cmp CL, AL
jna @IfNot_2
mov CL, AL
mov BL, Mystr[DI]
mov minb, BL
@IfNot_2:
inc DI
jmp @while_OUT
@EndWhile_OUT:
dec AL
mov sum, AL
ret
endp
vivod_leter proc
mac 39,12,1
mov DX,0
mov dl, minb
mov ah, 02h
int 21h
call vivod_number
mac 42,12,0
ret
endp
programm:
mov AX, @data
mov DS, AX
mov ah,0ah
int 21h
call clrs
call calc
call vivod_leter
mov ax, 4c00h
int 21h
end programm
此代码搜索字符串中的 MIN 符号。如果我在.data中声明了 string ,它就可以了 但我需要从键盘输入 string 。 所以,我的问题: 如何输入键盘字符串并将其移动到变量Mystr。对于下一步行动。请用注释修改我的代码。非常感谢,对不起我的英语^^
答案 0 :(得分:2)
由于您使用的是DOS操作系统,因此您可以使用DOS函数0Ah从标准输入读取。
mov ax, @data ;this line may depend on actual assembler (check for exact masm syntax if it doesn't work)
mov ds, ax
mov dx, Mystr ; now ds:dx is pointing to Mystr string
; some assemblers accept mov dx, offset Mystr or similar syntax
mov ah, 0Ah ; Function 0Ah
int 21h ;invoke the DOS function