Skip to content

Commit

Permalink
Intel 8080 assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredkrinke committed Nov 9, 2024
1 parent 1502c4b commit a1075b4
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ This repository tracks a [misguided quest to write code in 100 different program
| 94 | [Almost Equilateral Triangles](https://projecteuler.net/problem=94) | TBD | |
| 95 | [Amicable Chains](https://projecteuler.net/problem=95) | TBD | |
| 96 | [Su Doku](https://projecteuler.net/problem=96) | [Prolog](https://en.wikipedia.org/wiki/Prolog) ([SWI-Prolog](https://www.swi-prolog.org/)) | [p96.pro](src/p96.pro) |
| 97 | [Large Non-Mersenne Prime](https://projecteuler.net/problem=97) | TBD | |
| 97 | [Large Non-Mersenne Prime](https://projecteuler.net/problem=97) | [8080](https://en.wikipedia.org/wiki/Intel_8080) assembly ([Altair 8800](https://en.wikipedia.org/wiki/Altair_8800)) | [p97.asm](src/p97.asm) |
| 98 | [Anagramic Squares](https://projecteuler.net/problem=98) | TBD | |
| 99 | [Largest Exponential](https://projecteuler.net/problem=99) | TBD | |
| 100 | [Arranged Probability](https://projecteuler.net/problem=100) | TBD | |
77 changes: 77 additions & 0 deletions src/p97.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
main:
; Add binary-coded decimal digits (10 digits, 5 bytes)
lda digits
add a
daa
sta digits
lda digits+1
adc a
daa
sta digits+1
lda digits+2
adc a
daa
sta digits+2
lda digits+3
adc a
daa
sta digits+3
lda digits+4
adc a
daa
sta digits+4

; Update counter
lda counter
sui 1
sta counter
lda counter+1
sbi 0
sta counter+1
lda counter+2
sbi 0
sta counter+2
lda counter+3
sbi 0
sta counter+3

# Loop if needed
lda counter
adi 0
jnz main
lda counter+1
adi 0
jnz main
lda counter+2
adi 0
jnz main
lda counter+3
adi 0
jnz main

; Add one, as given in the problem
lda digits
adi 1 ; TODO
sta digits

; All done; inspect "digits" for resulting digits
hlt

; Store data at 0xe0
org 0eh

digits:
; 28433 as 10 packed binary coded decimal digits (little-endian)
db 33h
db 84h
db 02h
db 00h
db 00h

counter:
; 7830457 as 32-bit little-endian
db 0b9h
db 7bh
db 77h
db 00h

0 comments on commit a1075b4

Please sign in to comment.