[S S S T S S S S S S N
_Push_64][S N
S _Duplicate][N
S S S N
_Create_Label_LOOP][S N
N
_Discard_top][S S S T N
_Push_1][T S S S _Add][S N
S _Duplicate][S N
S _Duplicate][S S S T S T T S T T N
_Push_91][T S S T _Subtract][N
T S S S N
_Jump_to_Label_EXIT_if_0][S S S T S S N
_Push_4][N
S S T N
_Create_Label_INNER_LOOP][S S S T N
_Push_1][T S S T _Subtract][S N
S _Duplicate][N
T T S N
_Jump_to_Label_LOOP_if_negative][S N
T _Swap_top_two][S N
S _Duplicate][T N
S S _Print_as_character][S S S T S T S N
_Push_10][T N
S S _Print_as_character][S N
T _Swap_top_two][N
S N
T N
_Jump_to_Label_INNER_LOOP]
Letters S
(space), T
(tab), and N
(new-line) added as highlighting only.
[..._some_action]
added as explanation only.
Try it online (containing raw spaces, tabs and new-lines only).
General explanation in pseudo-code:
Integer i = 64
Start Loop:
i = i+1
If i == 91: Exit program with error
Integer j = 4
Start Inner Loop:
j = j-1
If j is negative: Go to the next iteration of the outer Loop
Print i as character
Print new-line
Go to the next iteration of the Inner Loop
Example run:
Command Explanation Stack STDOUT STDERR
SSSTSSSSSSN Push 64 [64]
SNS Duplicate top (64) [64,64]
NSSSN Create Label_LOOP [64,64]
SNN Discard top [64]
SSSTN Push 1 [64,1]
TSSS Add (64+1) [65]
SNS Duplicate top (65) [65,65]
SNS Duplicate top (65) [65,65,65]
SSSTSTTSTTN Push 91 [65,65,65,91]
TSST Subtract (65-91) [65,65,-26]
NTSSSN If 0: Jump to Label_EXIT [65,65]
SSSTSSN Push 4 [65,65,4]
NSSTN Create Label_INNER_LOOP [65,65,4]
SSSTN Push 1 [65,65,4,1]
TSST Subtract (4-1) [65,65,3]
SNS Duplicate top (3) [65,65,3,3]
NTTSN If negative: Jump to Label_LOOP [65,65,3]
SNT Swap top two [65,3,65]
SNS Duplicate top (65) [65,3,65,65]
TNSS Print as character [65,3,65] A
SSSTSTSN Push 10 [65,3,65,10]
TNSS Print as character [65,3,65] \n
SNT Swap top two [65,65,3]
NSNTN Jump to Label_INNER_LOOP [65,65,3]
SSSTN Push 1 [65,65,3,1]
TSST Subtract (2-1) [65,65,2]
SNS Duplicate top (2) [65,65,2,2]
NTTSN If negative: Jump to Label_LOOP [65,65,2]
SNT Swap top two [65,2,65]
SNS Duplicate top (65) [65,2,65,65]
TNSS Print as character [65,2,65] A
SSSTSTSN Push 10 [65,2,65,10]
TNSS Print as character [65,2,65] \n
SNT Swap top two [65,65,2]
NSNTN Jump to Label_INNER_LOOP [65,65,2]
SSSTN Push 1 [65,65,2,1]
TSST Subtract (2-1) [65,65,1]
SNS Duplicate top (1) [65,65,1,1]
NTTSN If negative: Jump to Label_LOOP [65,65,1]
SNT Swap top two [65,1,65]
SNS Duplicate top (65) [65,1,65,65]
TNSS Print as character [65,1,65] A
SSSTSTSN Push 10 [65,1,65,10]
TNSS Print as character [65,1,65] \n
SNT Swap top two [65,65,1]
NSNTN Jump to Label_INNER_LOOP [65,65,1]
SSSTN Push 1 [65,65,1,1]
TSST Subtract (1-1) [65,65,0]
SNS Duplicate top (1) [65,65,0,0]
NTTSN If negative: Jump to Label_LOOP [65,65,0]
SNT Swap top two [65,0,65]
SNS Duplicate top (65) [65,0,65,65]
TNSS Print as character [65,0,65] A
SSSTSTSN Push 10 [65,0,65,10]
TNSS Print as character [65,0,65] \n
SNT Swap top two [65,65,0]
NSNTN Jump to Label_INNER_LOOP [65,65,0]
SSSTN Push 1 [65,65,0,1]
TSST Subtract (0-1) [65,65,-1]
SNS Duplicate top (-1) [65,65,-1,-1]
NTTSN If negative: Jump to Label_LOOP [65,65,-1]
(Note: Contains additional trailing `[65,` here, but we'll ignore that for now.)
SNS Discard top [65]
SSSTN Push 1 [65,1]
TSSS Add (65+1) [66]
SNS Duplicate top (66) [66,66]
SNS Duplicate top (66) [66,66,66]
SSSTSTTSTTN Push 91 [66,66,66,91]
TSST Subtract (66-91) [66,66,-25]
NTSSSN If 0: Jump to Label_EXIT [66,66]
SSSTSSN Push 4 [66,66,4]
NSSTN Create Label_INNER_LOOP [66,66,4]
SSSTN Push 1 [66,66,4,1]
TSST Subtract (4-1) [66,66,3]
SNS Duplicate top (3) [66,66,3,3]
NTTSN If negative: Jump to Label_LOOP [66,66,3]
SNT Swap top two [66,3,66]
SNS Duplicate top (66) [66,3,66,66]
TNSS Print as character [66,3,66] B
SSSTSTSN Push 10 [66,3,66,10]
TNSS Print as character [66,3,66] \n
SNT Swap top two [66,66,3]
NSNTN Jump to Label_INNER_LOOP [66,66,3]
... etc. etc. for all letters in the alphabet
SNN Discard top [90]
SSSTN Push 1 [90,1]
TSSS Add (90+1) [91]
SNS Duplicate top (91) [91,91]
SNS Duplicate top (91) [91,91]
SSSTSTTSTTN Push 91 [91,91,91]
TSST Subtract (91-91) [91,91,0]
NTSSSN If 0: Jump to Label_EXIT [91,91] error
(Label_EXIT doesn't exit, so exits program with an error to STDERR)
4I'm slightly confused. Is the challenge here just to output the alphabet with each letter repeated four times, or does the output actually need to be stored in a file as well? – Iszi – 2013-12-13T17:26:35.687
And do I have to output only the alphabet? – Justin – 2013-12-13T17:33:25.533
@MarkReed Do I need to print it with newlines in between? Why not just print it, but newlines optional? – Justin – 2013-12-13T17:44:28.813
3Also, I recommend rephrasing your challenge so that it is more like a challenge and less like telling the story of how you invented your answer. – Justin – 2013-12-13T17:46:33.117
The last bit muddies the whitespace rules just a tad. Could you please clarify? Particularly, am I reading it right to interpret that extra whitespace is okay but omission of newlines is not? – Iszi – 2013-12-13T19:44:33.120