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

Assembly language program create a program that outputs a picture that represents halloween in ASCll art...
Assembly language program create a program that outputs a picture that represents halloween in ASCll art (jack-o-lantern, witch's hat, etc)
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,...
1. Write a program that does the following. Write in Assembly Language program Loads your student...
1. Write a program that does the following. Write in Assembly Language program Loads your student ID number into memory starting at location 0x2000 0100 a. DO NOT do any conversion on your ID number. If my ID number is 123456789, I should be able to read your ID in memory as 123456789 2. Loads the first six characters of your name, in ASSIC, in to memory right after your student ID. Total of 6 bytes. a. This means that...
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,...
**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)
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT