简体   繁体   中英

How to run Assembly Code in FASM

Hello I downloaded FASM to run Assembly code.

I need to write a small program like this

Sum: 
push %ebp
movl %esp, %ebp
movl 8(%ebp), %ecx 
movl 12(%ebp), %edx
xorl %eax, %eax 
testl %edx, %edx 
je .L34 

.L35: 
addl (%ecx), %eax 
addl $4, %ecx 
decl %edx 
jnz .L35 

.L34: 
movl %ebp, %esp 
popl %ebp 
ret 

The problem is that i am not sure how to run it in FASM, do i need to do a include something somewhere or something? my pc is a 64bit and also when i compile something it gives me an error, but if i import one of the examples it works fine.,..

Thank you for your help

Regards

fasm does not support AT&T syntax. Perhaps with some complicated macros it would be possible to add such support, but none of the package-provided includes will provide this feature.

You'll need to add extra code and specify a format, please refer to the manual, below I'll only translate your code:

Sum: 
push ebp
mov  ebp, esp
mov  ecx, [ebp + 8]
mov  edx, [ebp + 12]
xor  eax, eax 
test edx, edx 
je   .L34 

.L35: 
add  eax, [ecx]
add  ecx, 4
dec  edx 
jnz  .L35 

.L34: 
mov  esp, ebp
pop  ebp 
ret 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM