是否有更快的方式除以2,带符号,在汇编中比下例中的那个?
...
mov ecx, 2
idiv ecx
push eax #push the result
...
Run Code Online (Sandbox Code Playgroud) 我将参与一个大型的大会项目,但现在我刚开始学习这种新语言.我试图做一些简单的例子,比如你可能在highschool找到c ++(总和两个数字,是数字素数等).
现在我必须显示所有素数到n.问题是应用程序冻结在"call printf",我不明白为什么.
你能帮帮我吗?
.section .data
prime_number_str:
.asciz "%d "
.section .text
.global _start
_start:
pushl $20
call .first_prime_numbers
addl $4, %esp
pushl $0
call exit
.first_prime_numbers: #argument first n numbers
movl 4(%esp), %ecx #get the first argument
do_test:
pushl %ecx #push function arguments
call .prime
addl $4, %esp #restore the stack
#if not prime jump to the next number
cmpl $0, %eax
je no_not_prime
#print the number
pushl %eax #save eax
pushl %ecx #first argument
pushl $prime_number_str #text …Run Code Online (Sandbox Code Playgroud) 又是我。
我的程序中有很多“ add esp,4”,并且试图减小它的大小。有没有更小的指令可以代替“ add esp,4”?