使用cmp与数组。如何比较8086中的数组元素 [英] using cmp with array. how to compare array elements in 8086

查看:71
本文介绍了使用cmp与数组。如何比较8086中的数组元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何比较数组元素?

假设我有一个名为row的变量,它的值是45

然后是arr db 42,41



cmp row,arr [0]或cmp row,[arr]



两者似乎都不起作用。或者我必须将内容移动到变量??然后使用cmp?

how do you compare array elements?
lets say i have a variable named row and its value is 45
then an arr db 42,41

cmp row, arr[0] or cmp row, [arr]

both doesnt seem to work. or do i have to move the contents to a variable?? then use cmp?

推荐答案

你必须使用寄存器作为索引来移动数组:

You have to use a register as index to move in the array:
mov si, arr  ;register si points to base array
xor bx,bx    ;BX=0
mov al, BYTE PTR[ROW]
cmp al, BYTE PTR[SI+BX]  ;make comparison, address is SI(=arr)+BX(=index)
je  IsEqual  ;Match



更多信息你可以看到这个 [ ^ ]。


这篇关于使用cmp与数组。如何比较8086中的数组元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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