[英]At&T Assembly indexing arrays and declaring arrays
How would I go about indexing and declaring arrays in AT&T assembly? 我该如何在AT&T程序集中索引和声明数组?
Declaring do I do it like this: 声明是否这样做:
array:
.zero 256
Creates array of 256, with values of zero. 创建一个256数组,值为零。
Indexing it do I do it like this: 索引它我这样做吗:
movq $array, %r14 //Set array to a register name
//Say that r11 has the number 5 stored
movq (%r14, %r11, 8), %r15 //This will make r15 at index 5 of array
movq %rbx ,%r15 //This will store value of rbx into r15
Is this how I do it? 这是我的方法吗? If not, how do I go about creating and indexing arrays in AT&T assembly? 如果没有,我该如何在AT&T程序集中创建和索引数组?
Your assembly will store the address of the start of the array in r14
, move the value of the r11
th element of the array into r15
, then move the value in rbx
into r15
. 您的程序集将数组的起始地址存储在r14
,将数组的第r11
个元素的值移动到r15
,然后将rbx
的值移动到r15
。 It will not move any value into the array. 它不会将任何值移入数组。 If you want to move the address of the r11
th element into r15
then move the value in rbx
to the r11
th element of the array, you would need to use leaq (%r14, %r11, 8), %r15
to move the address of the r11
th element of the array into r15
, then use movq %rbx, (%r15)
to move the value in rbx
to the r11
th element of the array. 如果要将第r11
个元素的地址移动到r15
然后将rbx
的值移动到数组的第r11
个元素,则需要使用leaq (%r14, %r11, 8), %r15
来移动将数组第r11
个元素的地址放入r15
,然后使用movq %rbx, (%r15)
将rbx
的值移动到数组第r11
个元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.