44 lines
866 B
Text
44 lines
866 B
Text
;Example
|
|
move.l #2018,d0
|
|
bsr leap_year
|
|
addi.l #28,d1 ; # days in February 2018
|
|
rts
|
|
; Leap Year
|
|
;
|
|
; Input
|
|
; d0=year
|
|
;
|
|
; Output
|
|
; d1=1 if leap year, 0 if not leap year
|
|
; zero flag clear if leap year, set if not
|
|
;
|
|
leap_year:
|
|
cmpi.l #1752,d0
|
|
ble.s not_leap_year
|
|
|
|
move.l d0,d1
|
|
lsr.l #1,d1
|
|
bcs.s not_leap_year
|
|
lsr.l #1,d1
|
|
bcs.s not_leap_year
|
|
|
|
; If we got here, year is divisible by 4.
|
|
move.l d0,d1
|
|
divu #100,d1
|
|
swap d1
|
|
tst.w d1
|
|
bne.s is_leap_year
|
|
|
|
; If we got here, year is divisible by 100.
|
|
move.l d0,d1
|
|
divu #400,d1
|
|
swap d1
|
|
tst.w d1
|
|
bne.s not_leap_year
|
|
|
|
is_leap_year:
|
|
moveq.l #1,d1
|
|
rts
|
|
not_leap_year:
|
|
moveq.l #0,d1
|
|
rts
|