移动寄存器的值到一个数组 [英] Move register value into an array

查看:209
本文介绍了移动寄存器的值到一个数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的地方,我通过每个元素数组1 循环和存储数组的索引这个装配问题,其中的条目是F。

I'm working on this assembly problem where I'm looping through each element in array1 and storing the index of that array where the entry is "F".

我使用的x86 Intel处理器MASM。汇编语言

I'm using MASM for x86 intel processors. Assembly Language

INCLUDE Irvine32.inc
.data
array1 BYTE "FMMFMFMMFFMMFFFMFMFM",0
indexa1 BYTE SIZEOF array1 DUP(?)
ArraySize = ($ - array1)

.code
main PROC

mov esi,0          ; index
mov ecx,ArraySize

L1: cmp esi,ecx            ; check to continue loop
    jl  L2                 ; continue
    jmp L5                 ; exit

L2: cmp array1[esi], "F" ; Check if "F"
    je L3                ; jump if "F"
    jmp L4               ; jump to L4 if not "F"

L3: 
   mov indexa1[ah], esi   ; store index number,---- ERROR ----
   inc ah
   jmp L4

L4: inc esi ; increment loop counter
    jmp L1  ; jump to beginning

L5: movzx eax, ah
    call DumpRegs

exit    
main ENDP
END main

为什么我会尝试存储在indexa1索引错误?
错误说,必须是索引或基址寄存器

Why do I get an error trying to store the index in indexa1? Error says, must be index or base register

推荐答案

indexa1 [AH] 不匹配,在x86上任何有效的寻址模式。使用32位寄存器(例如 EAX )作为计数器来代替。

indexa1[ah] doesn't match any valid addressing mode on the x86. Use a 32-bit register (e.g. eax) as the counter instead.

见<一图3-11 href=\"http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html\"相对=nofollow>英特尔的软件开发人员手册。

这篇关于移动寄存器的值到一个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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