Date format: Difference between revisions
Content deleted Content added
m →{{header|Phix}}: added personal tag |
Puppydrum64 (talk | contribs) |
||
Line 11: | Line 11: | ||
<lang 11l>print(Time().format(‘YYYY-MM-DD’)) |
<lang 11l>print(Time().format(‘YYYY-MM-DD’)) |
||
print(Time().strftime(‘%A, %B %e, %Y’))</lang> |
print(Time().strftime(‘%A, %B %e, %Y’))</lang> |
||
=={{header|68000 Assembly}}== |
|||
{{works with|NEOGEO MVS}} |
|||
This code only works on the arcade system, not the home consoles, because only the arcade system has a built-in system clock. which can be read using <code>JSR $C0045C</code>. MAME uses your computer's date and time as the source for this data. The code below runs in-line and uses a few macros and labels, but they are mostly self-explanatory. The code required to set up the palettes and print characters to the screen has been omitted for brevity, but is fully implemented. |
|||
<lang 68000devpac> JSR SYS_READ_CALENDAR ;outputs calendar date to BIOS RAM |
|||
MOVE.B #'2',D0 ;a character in single or double quotes refers to its ascii equivalent. |
|||
JSR PrintChar |
|||
MOVE.B #'0',D0 |
|||
JSR PrintChar |
|||
LEA BIOS_YEAR,A1 |
|||
MOVE.B (A1)+,D0 ;stores last 2 digits of year into D0, in binary coded decimal |
|||
JSR UnpackNibbles8 ;separate the digits into high and low nibbles: D0 = 00020001 |
|||
ADD.L #$00300030,D0 ;convert both numerals to their ascii equivalents. |
|||
SWAP D0 ;print the "2" first |
|||
JSR PrintChar |
|||
SWAP D0 ;then the "1" |
|||
JSR PrintChar |
|||
MOVE.B #'-',D0 |
|||
JSR PrintChar |
|||
MOVE.B (A1)+,D0 ;get the month |
|||
JSR UnpackNibbles8 |
|||
ADD.L #$00300030,D0 |
|||
SWAP D0 |
|||
JSR PrintChar |
|||
SWAP D0 |
|||
JSR PrintChar |
|||
MOVE.B #'-',D0 |
|||
JSR PrintChar |
|||
MOVE.B (A1)+,D0 ;get the day |
|||
JSR UnpackNibbles8 |
|||
ADD.L #$00300030,D0 |
|||
SWAP D0 |
|||
JSR PrintChar |
|||
SWAP D0 |
|||
JSR PrintChar |
|||
;now the date is printed. |
|||
;Now do it again only written out: |
|||
jsr NewLine |
|||
CLR.L D0 ;reset D0 |
|||
MOVE.B (A1),D0 ;A1 happens to point to the weekday |
|||
LSL.W #2,D0 ;we are indexing into a table of longs |
|||
LEA Days_Lookup,A2 |
|||
LEA (A2,D0),A2 |
|||
MOVEA.L (A2),A3 ;dereference the pointer into A3, which the PrintString routine takes as an argument. |
|||
JSR PrintString |
|||
CLR.L D0 |
|||
LEA BIOS_MONTH,A1 ;GET THE MONTH |
|||
MOVE.B (A1)+,D0 |
|||
LSL.W #2,D0 |
|||
LEA Months_Lookup,A2 |
|||
LEA (A2,D0),A2 |
|||
MOVEA.L (A2),A3 |
|||
JSR PrintString |
|||
MOVE.B (A1),D0 ;GET THE DAY |
|||
JSR UnpackNibbles8 |
|||
ADD.L #$00300030,D0 |
|||
SWAP D0 |
|||
JSR PrintChar |
|||
SWAP D0 |
|||
JSR PrintChar |
|||
MOVE.B #',',D0 |
|||
JSR PrintChar |
|||
MOVE.B #' ',D0 |
|||
JSR PrintChar |
|||
MOVE.B #'2',D0 |
|||
JSR PrintChar |
|||
MOVE.B #'0',D0 |
|||
JSR PrintChar |
|||
LEA BIOS_YEAR,A1 |
|||
MOVE.B (A1)+,D0 ;stores last 2 digits of year into D0, in binary coded decimal |
|||
JSR UnpackNibbles8 ;separate the digits into high and low nibbles: D0 = 00020001 |
|||
ADD.L #$00300030,D0 ;convert both numerals to their ascii equivalents. |
|||
SWAP D0 ;print the "2" first |
|||
JSR PrintChar |
|||
SWAP D0 ;then the "1" |
|||
JSR PrintChar |
|||
forever: |
|||
bra forever ;trap the program counter |
|||
UnpackNibbles8: |
|||
; INPUT: D0 = THE VALUE YOU WISH TO UNPACK. |
|||
; HIGH NIBBLE IN HIGH WORD OF D0, LOW NIBBLE IN LOW WORD. SWAP D0 TO GET THE OTHER HALF. |
|||
pushWord D1 |
|||
CLR.W D1 |
|||
MOVE.B D0,D1 |
|||
CLR.L D0 |
|||
MOVE.B D1,D0 ;now D0 = D1 = $000000II, where I = input |
|||
AND.B #$F0,D0 ;chop off bottom nibble |
|||
LSR.B #4,D0 ;downshift top nibble into bottom nibble of the word |
|||
SWAP D0 ;store in high word |
|||
AND.B #$0F,D1 ;chop off bottom nibble |
|||
MOVE.B D1,D0 ;store in low word |
|||
popWord D1 |
|||
rts</lang> |
|||
Output can be seen [https://ibb.co/52Ks0yf here,] but is also reproduced below: |
|||
<pre> |
|||
2021-09-19 |
|||
Sunday, September 19, 2021 |
|||
</pre> |
|||
=={{header|8th}}== |
=={{header|8th}}== |
||
Line 19: | Line 139: | ||
bye |
bye |
||
</lang> |
</lang> |
||
=={{header|AArch64 Assembly}}== |
=={{header|AArch64 Assembly}}== |
||
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |