Question

In: Computer Science

Write a program in assembly language that outputs the leap years between a beginning and an...


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

Solutions

Expert Solution

.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


Related Solutions

Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
Hi this is Assembly Language MASM x86 program. Please write it in the language and please...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please explain it with comments thank you Please answer it I really need help this question was refunded before so please answer. Thank you so much also these are two separate programs thank you. 1) Write a procedure to read in decimal or hex number (byte-sized) Then write a procedure using shifts and ANDS to convert the string to a binary number (if is backward,...
Using the windows 32 framework , write an assembly language program ; write a procedure to...
Using the windows 32 framework , write an assembly language program ; write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the...
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal....
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal. 1. Request input data type. 2. Request input data. 3. Request output data type. 4. Output the data. Use any algorithm
Write a recursive ARM Assembly program that takes two integers as input and outputs the greatest...
Write a recursive ARM Assembly program that takes two integers as input and outputs the greatest common divisor. *I am using Eclipse DS-5 Community Workspace with A64 Instruction Set) Use the following algorithm: // Given two integers m and n: if (m < n) gcd(n, m) if n is a divisor of m gcd(m, n) = n else gcd (m, n) = gcd (n, m % n) Your program must be recursive. You must create a function that calls itself,...
Write a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
write a assembly language program to convert GRAY to BCD code in 8051
write a assembly language program to convert GRAY to BCD code in 8051
ASSEMBLY LANGUAGE ONLY OR I WILL DOWNVOTE write a program that will allow a person to...
ASSEMBLY LANGUAGE ONLY OR I WILL DOWNVOTE write a program that will allow a person to play a Guess a C♠rd Game. This section specifies the required functionality of the program. The interface must be a BlueJ Terminal Window, otherwise zero marks will be awarded. Only a simple screen presentation of the game is required; however, more marks will be gained for a game that is easy to follow with clear informative messages to the player. The aim of the...
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two...
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. A * 5 (A + B) - (A / B) (A - B) + (A * B)
CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the...
CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is: largest: 15 smallest: 3 Your program should define and call two functions: Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum The function LargestNumber should return the largest number of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT