Skip to content

Instantly share code, notes, and snippets.

@BigEd
Created March 14, 2016 15:03
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 BigEd/bf41fdaa44cef9754c43 to your computer and use it in GitHub Desktop.
Save BigEd/bf41fdaa44cef9754c43 to your computer and use it in GitHub Desktop.
Program for March 14th
; "Program for today" by Bruce Clark
; from http://forum.6502.org/viewtopic.php?t=1878
; ported to Easy 6502 (https://skilldrick.github.io/easy6502/#first-program)
define P 1
define M 0
define Q 105
define R 106
*=$600
CLD
JSR INIT
LDX #31
L1:
TXA
PHA
LDA #0
STA Q
LDX #104
L2:
TXA
JSR MUL
PHA
LDA Q
PHA
LDA #10
STA Q
LDA M,X
JSR MUL
STA R
PLA
ADC Q
STA Q
PLA
ADC R
STX R
ASL R
DEC R
JSR DIV
STA M,X
DEX
BNE L2
LDA #10
STA R
LDA #0
JSR DIV
STA P
LDA Q
EOR #48
JSR OUTPUT
PLA
TAX
CPX #31
BNE L3
LDA #46
JSR OUTPUT
L3:
DEX
BNE L1
LDA 13
JSR OUTPUT
LDA 10
JSR OUTPUT
HERE:
JMP HERE
INIT:
LDA #2
LDX #103
I1:
STA P,X
DEX
BPL I1
RTS
MUL:
STA R
LDA #0
LDY #8
LSR Q
M1:
BCC M2
CLC
ADC R
M2:
ROR
ROR Q
DEY
BNE M1
RTS
DIV:
LDY #8
ASL Q
D1:
ROL
BCS D2
CMP R
BCC D3
D2:
SBC R
SEC
D3:
ROL Q
DEY
BNE D1
RTS
OUTPUT:
DCB $42, 0
RTS
@BigEd
Copy link
Author

BigEd commented Mar 22, 2016

153 bytes... some much smaller ones for the 8086 over at http://www.boo.net/~jasonp/pipage.html

@djmips
Copy link

djmips commented Oct 10, 2018

From your G+ post http://asciiexpress.net/files/8088/ is the only link I saw working. The link of the 8086 ones is dead and no archive working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment