Hacker News new | past | comments | ask | show | jobs | submit login
Pi number calculator in 146 bytes of 8088 machine code (github.com/nanochess)
77 points by nanochess on Dec 13, 2022 | hide | past | favorite | 9 comments



The author has other interesting bootable games, like:

- https://github.com/nanochess/Invaders (Invaders)

- https://github.com/nanochess/bricks (bricks and paddle)

- https://github.com/nanochess/bootRogue (Rogue)

If you like learning assembly language/OSDev, his repos are a must to be bookmarked.


The link to the c code it is based on is down but the archive is:

https://web.archive.org/web/20210518022312/http://www.codeco...

Not sure I understand how that's calculating Pi though.


I think it is the Spigot algorithm for Pi

https://www.gavalas.dev/blog/spigot-algorithms-for-pi-in-pyt...

If you enjoy Pi stuff then I'd recommend the Pi Unleashed book

https://link.springer.com/book/10.1007/978-3-642-56735-3

Which has this algorithm and many more!


Simon Tatham (of PuTTY fame) has an implementation of this algorithm which supports far more than just pi.

https://www.chiark.greenend.org.uk/~sgtatham/spigot/


That first link deserves its own submission. Very interesting read


Interested parties should check out Ken Ward's excellent pi-calculating javascriptural here:

https://www.trans4mind.com/personal_development/JavaScript/l...


Impressive!

It fills the screen with digits of pi, then stops (tried it at https://copy.sh/v86/ ) - is it supposed to scroll?


According to comments in the .asm file

    It will generate (14000-14)/14*2 digits.
    Cannot go further with current precision
Which works out to about 500 digits. Maybe it's just reached its limit.

https://github.com/nanochess/pi/blob/master/pi.asm


If this works on an 8088, booting directly from the boot sector, how far are we to compiling it for a Game Boy (an 8080-like) cartridge?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: