-3

我有这个代码:

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 中声明字符串,它可以工作,但我需要从键盘输入字符串。所以,我的问题是:如何使用键盘字符串输入并将它移动到变量 Mystr。为下一步行动。请用注释修改我的代码。非常感谢,对不起我的英语^^

4

1 回答 1

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
于 2013-10-20T13:56:34.737 回答