In high-level languages such as C language to write a factorial is very simple, it is now familiar with the Linux use at/T assembly format to write a program to calculate the factorial bar
The first is to use the jump instruction implementation, the second is to use the function to implement
Convention: This program does not print the results on the standard output. Need to use GDB debug to view
The wording of a
#as filename.s-o filename.o#ld filename.o-o filename # gdb filename.section. data.section. Text.globl _START_START:MOVL $%eax #result = 1movl $6,%ecx # n = 5cmpl $,%ecxjle. Loop_exit.start_loop:imull%ecx,%eaxsubl $ ,%ecxcmpl $, %ecxjge. START_LOOPMOVL%eax,%EBXMOVL $,%eaxint $0x80. LOOP_EXIT:MOVL $,%eaxint $0x80
--------------------function to be updated-------------------------
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
------Computing the factorial of N in the assembly language of Linux