Assembly Array data storing

泄露秘密 提交于 2020-05-02 04:24:12

问题


Here is a new update on what i'm doing currently. I'm confused on how to use the data i stored in S2 to search the same word in the whole screen. If found highlight the word.

DOSBOX - compiler : A86

org 100h
;-----------------------------------------------------
lea bp, S1    
mov cx, 35 
mov al, 1   
mov ah, 13h 
mov bh, 0 
mov dl, 0
mov dh, 25
mov bl, 7
int 10h   
;----------------------------------------------------------            ; Asks input'
mov di,1
start:
mov ah, 0
int 16h
mov dx,ax
mov ah, 0eh
cmp dx,4d00h 
je start2
int 10h
mov S2[di], al
inc di
jmp start 

start2 :
mov cx,di
mov di,1
mov si,0

relop :
mov ah,[si]
cmp ah,S2[di]

mov al, 13h
    mov ah, 0
    int 10h     ; set graphics video mode. 
    mov al, 1100b
    mov cx, 10
    mov dx, 20
    mov ah, 0ch
    int 10h     ; set pixel. 

inc di
add si,2
je  relop 

mov ah, 13h 
lea bp, S2
mov al, 1
mov bh, 0
mov bl, 7
mov dl, 0
mov dh, 25
int 10h 



MOV AH, 4CH
INT 21H







S1 DB "EENTER THE WORD TO FIND ON SCREEN : "  
S2 db 1 dup (?) 







; ========= data ===============

I can't use int 21h for input and output but only to end the program ( return )


回答1:


mov dl, 0
mov dh, 25

You're printing the prompt beyond the screen! Coords are zero-based and for the row they range from 0 to 24 on the standard text screen.


 mov si,0
relop :
 mov ah,[si]
 cmp ah,S2[di]
 mov al, 13h
 mov ah, 0
 int 10h     ; set graphics video mode. 

If you want to read from the screen then you definitely should not be setting up a new screen on each iteration of this retrievel loop! Furthermore initializing the SI register to 0 won't get to the first character of the inputted word.

Solution:

Display your 35 character long prompt at the first row of the screen (mov dh,0). Now you know the inputted word will be at video memory offset address 70, but in the video memory segment.

 mov ax,0B800h
 mov es,ax
 mov si,70
relop :
 es mov ah,[si]  <-- This is the ASCII code of the 1st inputted character

Best also make these corrections:

S1 DB "ENTER THE WORD TO FIND ON SCREEN : "  
S2 db 44 dup (?)


来源:https://stackoverflow.com/questions/38875781/assembly-array-data-storing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!