小编Dav*_*idH的帖子

装配快速划分2

是否有更快的方式除以2,带符号,在汇编中比下例中的那个?

...
mov ecx, 2
idiv ecx
push eax #push the result
...
Run Code Online (Sandbox Code Playgroud)

assembly division

7
推荐指数
1
解决办法
1万
查看次数

从汇编中调用C函数 - 应用程序冻结在"call printf",我不知道为什么

我将参与一个大型的大会项目,但现在我刚开始学习这种新语言.我试图做一些简单的例子,比如你可能在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)

assembly printf

6
推荐指数
1
解决办法
7197
查看次数

比“ add esp,4”小的指令

又是我。

我的程序中有很多“ add esp,4”,并且试图减小它的大小。有没有更小的指令可以代替“ add esp,4”?

optimization x86 assembly

5
推荐指数
2
解决办法
2732
查看次数

标签 统计

assembly ×3

division ×1

optimization ×1

printf ×1

x86 ×1