【发布时间】:2014-06-16 11:55:12
【问题描述】:
Possible duplicate exist,但我不知道如何将这个或其他解决方案应用于类似问题,所以我来了。
我正在创建一个函数,该函数在 x86 AT&T 程序集中将整数作为字符串返回。
我有这段代码来声明变量resdes。
.data
.align 4
resdes: .long 12
resdes 现在指向一个内存位置,后跟 11 个其他字节供我使用(我理解正确吗?)。
我想一次将一位数字从整数加载到字节中。这是我的代码:
ifd:
movl (%esp, %ecx), %eax //This loads %eax with my int
movl resdes, %ecx //This is incorrect and causes errors later
inc %ecx
movl $10, %ebx //Division by 10 to basically do a modulo operation
cdq
divloop:
div %ebx
movb %dl, (%ecx) //This is where I move the digit into the memory
//And here I get the ERROR because (%ecx) does
//not contain the proper address
inc %ecx //And set the pointer to point to the next byte
cmp $0, %eax //If there are noe more digits left we are finished
je divfinish1
jmp divloop //I leave out alot of the code that I know
//work because it's not relevant
我的问题是将resdes 的实际地址放入%ecxregister,即上述代码的第一行。据我所知,该行将resdes-address 的内容移动到%ecx,这不是我想要的。
【问题讨论】:
标签: memory assembly gnu-assembler att