ASM-创建过程 [英] ASM-creating a procedure

查看:152
本文介绍了ASM-创建过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个数组和数组b中分别设置。
该过程将得到一个值V,如果该值在数组B或不存在返回。
,如果是这样,存储在P中的索引,如果没有,店里-1 P.
该计划应与以下DATAS开始:

An Array A and Array B were set. The procedure will get an value V and return if the value exist in array B or not. If it does-store the index in P, if not, store -1 in P. The program should begin with the following datas:

ARR_B DB 100 DUP()
ARR_A DB 10 DUP ()
V DB ?
P DB ?

下面就是我们所做的:

TEST1 PROC
; Chek if the variable of V  found in ARR_B.
MOV SI,0
MOV DX,0
MOV Flag,0
MOV AL,1H
NEG AL
MOV CX,9H
GO:
    MOV DL,ARR_B[SI]
    CMP  V,DL
    JE X
    INC SI
    LOOP GO
    MOV  P,AL
    JMP END1
X:  MOV DX,SI
    MOV  P,DL
        INC FLAG
END1:   NOP
    RET
TEST1 endp

(旗以下选项一起使用)

(flag in used on the following option)

推荐答案

您通常会想要做这样使用代表SCASB 搜索:

You'd normally want to do a search like this using rep scasb:

test1 proc
    mov P, 0ffffh ; for now, assume it won't be found
    mov al, V                ; what we're going to look for
    mov di, offset array_b   ; where we're going to look
    mov cx, size array_b     ; how many items to search
    repnz scasb              ; do the search
    jnz done                 ; Z flag clear = not found
    sub di, offset array_b   ; found: compute offset into array_b
    mov P, di                ;        and save it
done:
    ret

这篇关于ASM-创建过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆