Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 在程序集中递增数组_Arrays_Assembly_X86_Tasm - Fatal编程技术网

Arrays 在程序集中递增数组

Arrays 在程序集中递增数组,arrays,assembly,x86,tasm,Arrays,Assembly,X86,Tasm,编写汇编程序以用作字典。用户输入单词,程序检查该单词是否存在。TASM,16位。程序对于数组的前两个元素非常有效,但如果我提供球。,数组的第三个元素,即使正在选择数组的下一个元素,(在emu8086上验证,bx变为007ch,->请参阅codeinc words;数组中的下一个单词 不,很抱歉。您已经增加了w0的偏移量(原来是多少)。您尚未移动到数组中的下一个单词。您想要更像。。。 在查找“.”的循环中,如果讨厌的用户没有输入“.”会发生什么?中断返回后,输入缓冲区(buf+1)中的第二个字

编写汇编程序以用作字典。用户输入单词,程序检查该单词是否存在。TASM,16位。程序对于数组的前两个元素非常有效,但如果我提供
球。
,数组的第三个元素,即使正在选择数组的下一个元素,(在
emu8086上验证,
bx
变为
007ch
,->请参阅code
inc words;数组中的下一个单词

不,很抱歉。您已经增加了
w0
的偏移量(原来是多少)。您尚未移动到数组中的下一个单词。您想要更像。。。


在查找“.”的循环中,如果讨厌的用户没有输入“.”会发生什么?中断返回后,输入缓冲区(buf+1)中的第二个字节是实际输入的计数。它包括“.”(如果有)和回车(13或0Dh)输入结束。您可以使用此信息排除明显错误的输入。

字典将超过近200个单词,所以是的,数组是必须的,没有其他方法:)buf db 99,99 dup(?)的目的是什么(与buf db 99 dup(?)相比,
)?us2012对于输入,必须这样做,否则程序将不会接受输入Hanks frank,实施了回车策略,现在正在处理第一个问题:)一个问题,我的数组
单词
已经存储了偏移量,为什么我要再次将其偏移到bx,因为您的代码状态为
mov bx,偏移词
.model large
.data
arrayele db 00d ;to count if all elements of the array have been compared with
count db 00d ;length of input count
nl db 10d,13d,'$' ;newline
mne db "Not Equal$" ;message if not equal
me db "Equal$" ;message if equal
buf db 99,?,99 dup(?) ;buffer where the input will be saved
w0 db "hello$" ;word 0-5
w1 db "which$"
w2 db "balls$"
w3 db "table$"
w4 db "chair$"
w5 db "apples$"
words dw offset w0,offset w1 ;the array
      dw offset w2,offset w3
      dw offset w4,offset w5
.code

main proc
    mov ax,@data
    mov ds,ax
    mov es,ax

    ;take user input
    mov ah,0ah
    mov dx,offset buf
    int 21h

    ;print new line
    mov ah,09h
    mov dx,offset nl
    int 21h

    ;load input to di
    mov di,offset buf
    add di,2

    ;//saving length to a variable
    repeat:
    mov al,[di]
    inc count
    cmp al,"."
    je lenchck
    inc di
    jmp repeat
    ;//end saving
    lenchck: 

    dec count  ;as full stop (period) (.) is also included in the count

    stringmatch1:
    mov cx,0  ;reset register
    mov arrayele,0 ;reset variable
    stringmatch: 
    mov di,offset buf  ;loading input to di
    add di,2
                          ;loading array element to si
    mov bx,0
    mov bl,byte ptr words
    mov si,bx             ;end loading array element to si
    mov cl,count
    repe cmpsb
    je equal

    inc arrayele
    inc words    ;next word in the array
    mov bx,0         ;loading it
    mov bl,byte ptr words
    mov si,bx        ;end loading
    cmp arrayele,06d      ;compare to check if all elements have been compared with
    jg wrong

    jmp stringmatch

    wrong:                ;load notequal message
    mov dx,offset mne
    jmp print

    equal:
    mov dx,offset me      ;load equal message
    print:
    mov ah,09h            ;print it    
    int 21h

    mov ah,4ch            ;exit the program
    int 21h
main endp
end main
mov bx, offset words
top:
; get offset of a string
mov si, [bx]
; do your comparison
; start at beginning of input every time
mov di, offset buf + 2 ; don't need a separate operation
mov cl, count ; (are we sure ch is clear?)
repe cmpsb
je found
; no? get next offset in words array
add bx, 2
jmp top