Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given a year, write down the assembly program to determine whether it is leap or

ID: 3543189 • Letter: G

Question

Given a year, write down the assembly program to determine whether it is leap

or not as follows:

if (year is divisible by 400) then

is_leap_year

else if (year is divisible by 100) then

not_leap_year

else if (year is divisible by 4) then

is_leap_year

else

not_leap_year

[Use the rem instruction for the modulo operation. Indicate the result by storing the

either 0/1 in the register, 1 to indicate leap year and 0 otherwise.]

[Try to minimize the nop instructions by substituting it with one of the instructions

from the code. Make sure it doesn

Explanation / Answer

ASSUME DS:DATA1,CS:CODE1
DATA1 SEGMENT
MSG DB 0AH,0DH,'ENTER THE YEAR$'
NUMBER DB 6,0,6 DUP('$')
YS DB 0AH,0DH,'YES,IT IS A LEAP YEAR$'
N DB 0AH,0DH,'NO,IT IS NOT A LEAP YEAR$'
DATA1 ENDS
CODE1 SEGMENT
START: MOV AX,DATA1
MOV DS,AX
LEA DX,MSG

MOV AH,09H
INT 21H
LEA DX,NUMBER
MOV AH,0AH
INT 21H LEA BX,NUMBER+4
MOV AH,[BX]

MOV AL,[BX+1] AAD
MOV BL,04H
DIV BLAND AH,0FFH
JZ YES
LEA DX,N
MOV AH,09H
INT 21H

JMP DOWN

YES:LEA DX,YS

MOV AH,09H
INT 21H DOWN:
MOV AH,4CH
INT 21H
CODE1 ENDS
END START
**************** Output:- Enter the Year 2000
                                      Yes, It Is A Leap Year
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote