Skip to content

Instantly share code, notes, and snippets.

@bieniekmateusz
Created October 6, 2012 19:35
Show Gist options
  • Save bieniekmateusz/3845880 to your computer and use it in GitHub Desktop.
Save bieniekmateusz/3845880 to your computer and use it in GitHub Desktop.
Factorial function in assembly language
; The input is a decimal number,
; Result is a hexadecimal number
section .text
; to make the printf out work the main 'method' is needed
global main
; for printing numbers out
extern printf
main:
; Find factorial for the initial value of ecx,
mov ecx, 5
; Copy the initial value of ecx to eax,
; eax is our factorial result
mov eax, ecx
loop:
; If the counter is less or equal to 1, finish
cmp ecx, 1
jle end
sub ecx, 1
mul ecx
jmp loop
end:
; Display the message and exit
push eax
push message
call printf
add esp, 8
ret
section .data
message: db "The result is = %08X", 10, 0
@GopiKrishna96777
Copy link

Can u write a 8051 assembly language program for reversal of given number

@DAOXUANPHUNG-2750-NGUYENDINHTU-2883

Where's the risc-v version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment