Y86装配全局变量 [英] Y86 assembly global variables

查看:196
本文介绍了Y86装配全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我努力让全局变量为我Y86分配正常工作。不幸的是我们提供的唯一例子是IA-32装配。我已经寻找过去的几个小时,但无济于事。这是非常基本的,但我知道我在Y86一个完整的新手。

I am struggling to get global variables to work correctly for my Y86 assignment. Unfortunately the only examples we were provided with are in IA-32 assembly. I have searched for the last few hours but to no avail. This is very basic I know but I am a complete novice at Y86.

我宣布我的变量如下:

.align 4
x: .long 1
y: .long 4

当我使用他们的操作,如 irmovl X,EDX%我看到了价值380被分配到EDX寄存器,而不是价值4.我认为正在发生的事情是,我分配的内存位置寄存器,而不是价值。什么是正确的语法来设置全局变量的寄存器的值?

When I use them in an operation such as irmovl x, %edx I see the value 380 is assigned to the edx register instead of the value 4. I think what is happening is that I am assigned the memory location to the register instead of the value. What would be the correct syntax to set the value of the global variable to the register?

我一直在使用,而不是mrmovl试过,但我不能确定的语法与一个全局变量mrmovl的。

I have tried using mrmovl instead but am unsure of the syntax for mrmovl with a global variable.

mrmovl X,EDX%给我的错误X不是一个数字

mrmovl x, %edx give me the error "x is not a number"

推荐答案

irmovl 作为名字说是的 mmediate为研究 egister。
你想 mrmovl ,因为这是<强> M 埃默里为研究 egister。

irmovl as the name says is immediate to register. You want mrmovl as that is memory to register.

至于语法,因为Y86不支持位移,我希望 mrmovl X,EDX%工作。你说没有,作为一种解决方法,你可以使用2说明:

As for the syntax, since y86 does support displacement, I would expect mrmovl x, %edx to work. You say it doesn't, as a workaround you could use 2 instructions:

irmovl x, %edx     # load address
mrmovl (%edx), %edx # fetch value

这篇关于Y86装配全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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