[英]Adding 0x80000000 to register won't work when trying to build a mask
Given the following code: 给出以下代码:
.section .rodata
input_format: .string "%d"
output_format1: .string ""
output_format2: .string ""
.section .text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
.loop:
addl $-4 ,%esp # moving down the stack
pushl %esp
pushl $input_format
call scanf # call scanf to get a number from the user
addl $8,%esp
movl (%esp),%edx # get the new number
movl $0,%esi # reseting first mask
addl $0x1,%esi # first mask of 0x1
movl $0,%ecx # reseting second mask
addl $0x80000000,%ecx
// more code in the future
# return from printf:
movl %ebp,%esp
popl %ebp
ret
I'm trying to build a mask in order to identify if a given number is a palindrome. 我正在尝试构建一个掩码,以识别给定的数字是否是回文。 So I want to have to masks, first with all zeros and a "1" bit in the MSB, and the other with all zeros and "1" bit in the LSB, and then run 16 times and compare the result using AND.
因此,我想要屏蔽,首先屏蔽MSB中的全零和“ 1”位,然后屏蔽LSB中的所有零和全1,然后运行16次并使用AND比较结果。 However, when writing
addl $0x80000000,%ecx
, the register %ecx
won't get the immediate 0x80000000
. 但是,当编写
addl $0x80000000,%ecx
,寄存器%ecx
不会立即获得0x80000000
。 Why is that ? 这是为什么 ?
What is 0x80000000 + 0x80000000? 0x80000000 + 0x80000000是什么? The result of that is why it doesn't seem to work.
结果就是为什么它似乎不起作用。
To set the high bit no matter what, use the bit operations 无论如何要设置高位,请使用位操作
orl $0x80000000, %ecx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.