In: Computer Science
Write a program in assembly language that outputs the leap years
between a beginning and an ending year.
1. Initialize $a0 and $a1 with the beginning and ending
years.
2. Print out the leap years between 1970 and 2030.
OUTPUT:
From 1970 to 2030:
1972
…
2028
.data
newline: .asciiz "\n"
.text
.globl main
main:
li $a0, 1970
li $a1, 2030
find: #finding first leap year from
starting $a0
move $t1, $a0
li $t2, 4
div $t1, $t2
mfhi $t2
beq $t2, 0, print
addi $a0, $a0, 1
j find
print: # print all the leap by
incrementing by 4 to the fisrt leap year
slt $t3, $a1, $t1
beq $t3, 1, end
li $v0, 1
move $a0, $t1
syscall
li $v0, 4
la $a0, newline
syscall
addi $t1, $t1, 4
j print
end:
li $v0, 10
syscall
#Output