Day of the week: Difference between revisions
Content added Content deleted
PatGarrett (talk | contribs) (→{{header|360 Assembly}}: Section added) |
|||
Line 10: | Line 10: | ||
compare the dates calculated with the output of other languages to discover any anomalies in the handling of dates which may be due to, for example, overflow in types used to represent dates/times similar to [[wp:Y2k#See_also|y2k]] type problems. |
compare the dates calculated with the output of other languages to discover any anomalies in the handling of dates which may be due to, for example, overflow in types used to represent dates/times similar to [[wp:Y2k#See_also|y2k]] type problems. |
||
<br><br> |
<br><br> |
||
=={{header|360 Assembly}}== |
|||
{{trans|REXX}} |
|||
The program uses two ASSIST macro (XDECO,XPRNT) to keep the code as short as possible. |
|||
<lang 360asm> |
|||
* Day of the week 06/07/2016 |
|||
DOW CSECT |
|||
USING DOW,R15 base register |
|||
LA R6,2008 year=2008 |
|||
LOOP C R6,=F'2121' do year=2008 to 2121 |
|||
BH ELOOP . |
|||
LR R7,R6 y=year |
|||
LA R8,12 m=12 |
|||
LA R9,25 d=25 |
|||
C R8,=F'3' if m<3 |
|||
BNL MGE3 then |
|||
LA R8,12(R8) m=m+12 |
|||
BCTR R7,0 y=y-1 |
|||
MGE3 LR R10,R7 y |
|||
SRDA R10,32 . |
|||
D R10,=F'100' r=y//100 ; l=y/100 |
|||
LR R3,R8 m |
|||
LA R3,1(R3) m+1 |
|||
M R2,=F'26' *26 |
|||
D R2,=F'10' /10 |
|||
AR R3,R9 +d |
|||
AR R3,R10 +r |
|||
LR R2,R10 r |
|||
SRA R2,2 /4 |
|||
AR R2,R3 (d+(m+1)*26/10+r+r/4 |
|||
LR R3,R11 l |
|||
SRA R3,2 /4 |
|||
AR R2,R3 (d+(m+1)*26/10+r+r/4+l/4 |
|||
LA R5,5 5 |
|||
MR R4,R11 *l |
|||
AR R2,R5 (d+(m+1)*26/10+r+r/4+l/4+5*l) |
|||
SRDA R2,32 . |
|||
D R2,=F'7' w=(d+(m+1)*26/10+r+r/4+l/4+5*l)//7 |
|||
C R2,=F'1' if w=1 (sunday) |
|||
BNE WNE1 then |
|||
XDECO R6,PG edit year |
|||
XPRNT PG,12 print year |
|||
WNE1 LA R6,1(R6) year=year+1 |
|||
B LOOP next year |
|||
ELOOP BR R14 exit |
|||
PG DS CL12 buffer |
|||
YREGS |
|||
END DOW |
|||
</lang> |
|||
{{out}} |
|||
<pre style="height:20ex"> |
|||
2011 |
|||
2016 |
|||
2022 |
|||
2033 |
|||
2039 |
|||
2044 |
|||
2050 |
|||
2061 |
|||
2067 |
|||
2072 |
|||
2078 |
|||
2089 |
|||
2095 |
|||
2101 |
|||
2107 |
|||
2112 |
|||
2118 |
|||
</pre> |
|||
=={{header|ABAP}}== |
=={{header|ABAP}}== |