问题描述
- 闰年除以 4 时不是平年
- 但如果那一年除以 100,则有两种情况。
- 除以 400 时为闰年。
- 如果不除以 400,则是普通年份。
它运行良好,但我无法退出程序。输入负数时想转义。
我在主要标签中制作了 cmp %l1,0
和 bl next_r
以逃脱,但它不起作用
fmt1 : .asciz "input a year (EXIT : negative number )\n"
fmt2 : .asciz "%d"
fmt3 : .asciz "%d is leap year.\n"
fmt4 : .asciz "%d is common year.\n"
.align 4
.global main,printf,scanf
main : save %sp,-96,%sp
set fmt1,%o0
call printf
nop
set fmt2,%o0
add %fp,-4,%o1
call scanf
nop
ld [%fp-4],%l1
cmp %l1,0
bl next_r
nop
loop_a : mov %l1,%o0
mov 4,%o1
call .rem
nop
cmp %o0,0
be loop_b
nop
bne print_a
nop
print_a : set fmt4,%o0
ld [%fp-4],%o1
call printf
nop
ba main
nop
loop_b :
ld [%fp-4],%o0
mov 100,0
be loop_c
nop
bne print_b
nop
print_b : set fmt3,%o1
call printf
nop
ba main
nop
loop_c : ld [%fp-4],%o0
mov 400,0
be print_b
nop
bne print_a
nop
next_r : ret
restore
这是一个结果。
input a year (EXIT : negative number)
2000
2000 is a leap year
input a year (EXIT : negative number)
2001
2001 is a common year
input a year (EXIT : negative number)
-23
input a year (EXIT : negative number)
-23
input a year (EXIT : negative number)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)