How to do a reverse offset/index in x86 [duplicate]

这一生的挚爱 提交于 2021-01-29 06:12:09

问题


I am trying to do a negative offset for memory addressing. This is to convert a number to a string and make sure that it doesn't print in reverse order since x86 is little endian. Here is what I'm trying to do:

 # (b) move the asci number to rbp-8-len (to print in reverse)
 movb %al,  -8(%rbp, %r12, -1)

I know -1 is not a valid size, but I've shown what I'm trying to do conceptually above. What would be the proper way to do this?


Currently, I am doing it like:

# (b) move the asci number to rbp-8-len (to print in reverse)
# store offset (8+len) in %r13
mov $-8,        %r13
sub %r12,       %r13
movb %dl,       (%rbp, %r13)

来源:https://stackoverflow.com/questions/63965249/how-to-do-a-reverse-offset-index-in-x86

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!