Untitled
Anonymous
Plain Text
08/18/2025 6:07 AM
806 B
14
Indexable
Never
.data input_prompt1:.asciiz "Enter first number :" input_prompt2:.asciiz "Enter second number :" gcd_result_msg: .asciiz "GCD is :" .text .globl main main: #Prompt and read first number li $v0,4 la $a0,input_prompt1 syscall li $v0,5 syscall move $t0,$v0 #t0=first number(a) #Prompt and read second number li $v0,4 la $a0,input_prompt2 syscall li $v0,5 syscall move $t1,$v0 gcd_loop: beq $t1,$zero,gcd_done #if b==0,done div $t0,$t1 #divide a by b mfhi $t2 # remainder =a%b move $t0,$t1 # a=b move $t1,$t2 #b=remainder j gcd_loop gcd_done: #Print result li $v0,4 la $a0,gcd_result_msg syscall move $a0,$t0 #GCD is into li $v0,1 syscall #Exit li $v0,10 syscall
Editor is loading...
Leave a Comment