Skip to content

Instantly share code, notes, and snippets.

@xk
Last active October 29, 2017 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xk/faf76ab3687b0a5718824b81595bc761 to your computer and use it in GitHub Desktop.
Save xk/faf76ab3687b0a5718824b81595bc761 to your computer and use it in GitHub Desktop.
SANER 6502 COUNT TO ONE MILLION
;see "Counting from 1 to 1,000,000 on the FASTChip" @ c.s.a2
;https://groups.google.com/forum/#!topic/comp.sys.apple2/ibI06hDLiaY
;And
;https://gist.github.com/xk/d2b95a4dcfc6f6fd40310dfeacb257da
;In theory the limit is ~1e6*6 cycles, ~ 6s, totally unrolled.
;This does it in ~ 6.2s.
* = $1000
bell = $ff3a
digito0 = 1029
digito1 = 1028
digito2 = 1027
digito3 = 1026
digito4 = 1025
digito5 = 1024
ldy #176 ;'0'
ldx #177 ;'1'
sty digito0
sty digito1
sty digito2
sty digito3
sty digito4
sty digito5
loop
lda #178 ;'2'
jsr to_100_000
stx digito5
jsr to_100_000
sta digito5
jsr to_100_000
inc digito5
jsr to_100_000
inc digito5
jsr to_100_000
inc digito5
jsr to_100_000
inc digito5
jsr to_100_000
inc digito5
jsr to_100_000
inc digito5
jsr to_100_000
inc digito5
jsr to_100_000
sty digito5
jsr bell
jmp loop
to_100_000
jsr to_10_000
stx digito4
jsr to_10_000
sta digito4
jsr to_10_000
inc digito4
jsr to_10_000
inc digito4
jsr to_10_000
inc digito4
jsr to_10_000
inc digito4
jsr to_10_000
inc digito4
jsr to_10_000
inc digito4
jsr to_10_000
inc digito4
jsr to_10_000
sty digito4
rts
to_10_000
jsr to_1000
stx digito3
jsr to_1000
sta digito3
jsr to_1000
inc digito3
jsr to_1000
inc digito3
jsr to_1000
inc digito3
jsr to_1000
inc digito3
jsr to_1000
inc digito3
jsr to_1000
inc digito3
jsr to_1000
inc digito3
jsr to_1000
sty digito3
rts
to_1000
jsr to_100
stx digito2
jsr to_100
sta digito2
jsr to_100
inc digito2
jsr to_100
inc digito2
jsr to_100
inc digito2
jsr to_100
inc digito2
jsr to_100
inc digito2
jsr to_100
inc digito2
jsr to_100
inc digito2
jsr to_100
sty digito2
rts
to_100
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
stx digito1
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
sta digito1
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
inc digito1
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
inc digito1
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
inc digito1
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
inc digito1
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
inc digito1
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
inc digito1
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
inc digito1
stx digito0
sta digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
inc digito0
sty digito0
sty digito1
rts
1000:A0 B0 A2 B1 A9 B2 8C 05
:04 8C 04 04 8C 03 04 8C
:02 04 8C 01 04 8C 00 04
:20 5C 10 8E 00 04 20 5C
:10 8D 00 04 20 5C 10 EE
:00 04 20 5C 10 EE 00 04
:20 5C 10 EE 00 04 20 5C
:10 EE 00 04 20 5C 10 EE
:00 04 20 5C 10 EE 00 04
:20 5C 10 EE 00 04 20 5C
:10 8C 00 04 20 3A FF A9
:B2 4C 18 10 20 99 10 8E
:01 04 20 99 10 8D 01 04
:20 99 10 EE 01 04 20 99
:10 EE 01 04 20 99 10 EE
:01 04 20 99 10 EE 01 04
:20 99 10 EE 01 04 20 99
:10 EE 01 04 20 99 10 EE
:01 04 20 99 10 8C 01 04
:60 20 D6 10 8E 02 04 20
:D6 10 8D 02 04 20 D6 10
:EE 02 04 20 D6 10 EE 02
:04 20 D6 10 EE 02 04 20
:D6 10 EE 02 04 20 D6 10
:EE 02 04 20 D6 10 EE 02
:04 20 D6 10 EE 02 04 20
:D6 10 8C 02 04 60 20 13
:11 8E 03 04 20 13 11 8D
:03 04 20 13 11 EE 03 04
:20 13 11 EE 03 04 20 13
:11 EE 03 04 20 13 11 EE
:03 04 20 13 11 EE 03 04
:20 13 11 EE 03 04 20 13
:11 EE 03 04 20 13 11 8C
:03 04 60 8E 05 04 8D 05
:04 EE 05 04 EE 05 04 EE
:05 04 EE 05 04 EE 05 04
:EE 05 04 EE 05 04 8C 05
:04 8E 04 04 8E 05 04 8D
:05 04 EE 05 04 EE 05 04
:EE 05 04 EE 05 04 EE 05
:04 EE 05 04 EE 05 04 8C
:05 04 8D 04 04 8E 05 04
:8D 05 04 EE 05 04 EE 05
:04 EE 05 04 EE 05 04 EE
:05 04 EE 05 04 EE 05 04
:8C 05 04 EE 04 04 8E 05
:04 8D 05 04 EE 05 04 EE
:05 04 EE 05 04 EE 05 04
:EE 05 04 EE 05 04 EE 05
:04 8C 05 04 EE 04 04 8E
:05 04 8D 05 04 EE 05 04
:EE 05 04 EE 05 04 EE 05
:04 EE 05 04 EE 05 04 EE
:05 04 8C 05 04 EE 04 04
:8E 05 04 8D 05 04 EE 05
:04 EE 05 04 EE 05 04 EE
:05 04 EE 05 04 EE 05 04
:EE 05 04 8C 05 04 EE 04
:04 8E 05 04 8D 05 04 EE
:05 04 EE 05 04 EE 05 04
:EE 05 04 EE 05 04 EE 05
:04 EE 05 04 8C 05 04 EE
:04 04 8E 05 04 8D 05 04
:EE 05 04 EE 05 04 EE 05
:04 EE 05 04 EE 05 04 EE
:05 04 EE 05 04 8C 05 04
:EE 04 04 8E 05 04 8D 05
:04 EE 05 04 EE 05 04 EE
:05 04 EE 05 04 EE 05 04
:EE 05 04 EE 05 04 8C 05
:04 EE 04 04 8E 05 04 8D
:05 04 EE 05 04 EE 05 04
:EE 05 04 EE 05 04 EE 05
:04 EE 05 04 EE 05 04 8C
:05 04 8C 04 04 60
1000G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment