Hacker News new | past | comments | ask | show | jobs | submit login
BootLogo: Logo language in 508 bytes of x86 machine code (github.com/nanochess)
226 points by thunderbong 3 months ago | hide | past | favorite | 38 comments



Hello friend. I'm on a crusade to make people's bootsector code work on real hardware.

You're missing several reserved memory areas and state bits to reset. Check out my bootsector I have lots of comments on what things are needed https://github.com/fsmv/bootstrap-os/blob/master/bootloader/...

You can probably drop the extra sector loading code and error printing and only use the header and footer.


This is a crazy comment to find. I LOVE IT.


        mov ax,0x0013 ; VGA 320x200x256 colors mode.
        int 0x10 ; Set video mode.
Oh man that takes me back. Also this is sporting a fixed-point sin table and compiled down to a .com. It's like 1994 all over again.


I had repeating dreams about int 10h and EGA back in 1991 ... It was magic ...


mode 13h gfx programming in tasm well after its heyday was my first programming really (i was young and stumbled) fond memories


I remember copying logo programs from a whiteboard into an Apple II as a grade schooler. It's a great "instant results" way to introduce kids to programming, and it lends itself to exploration in a way that today's copycats ($10/mo iPad subscriptions and visio diagrams to make a character walk around) don't.

Browser emulator link: https://parkertomatoes.github.io/v86/?type=mbr&content=%2FLg...


Thanks! Your project is amazing to test with just a browser. Just I've made a link using the newest version of bootLogo (now supporting procedures!)

TO CURVE REPEAT 4 [LT 10 FD 10] END

TO PETAL [CURVE LT 140 CURVE] END

TO FLOWER REPEAT 4 [PETAL LT 50] END

FLOWER

RT 180

FD 50

RT 140

PETAL

PU

FD 50

Emulator link: https://parkertomatoes.github.io/v86/?type=mbr&content=Dg4fB...


Like others have said this is hardly Logo.

Turtle graphics != Logo.

Turtle graphics is a tiny tiny subset of Logo.

But let us not miss the forest for the trees. It is still very impressive that the tiny tiny subset of Logo fits in 508 bytes of machine code.


Made by Oscar Toledo G., who learned assembly language by age 9 and won the International Obfuscated C Contest five times.

https://nanochess.org/author.html


Is he related to the infamous Familia Toledo http://www.biyubi.com/?


Yes, one and the same (he appears on the homepage you linked)


The jb .5 can be removed, saving 2 bytes. There are other optimizations, like inc di/jmp short avoid_command which could be moved before avoid_command, saving another 2 bytes.


Thanks for the tips! I've updated bootLogo and mentioned you in the manual. Now bootLogo has PU/PD commands.


Thtat reminds me that when I was a kid and I knew literally nothing about computers, I hated Logo because of a totally non-intuitive syntax, but I solved a math puzzle (something like the mpuz form Emacs, but for DOS PC's) at great speeds. With Windows 96/98 and C++ it was even worse, as the programming barrier was uber-high with the Win32 API, and most of sysadmin the stuff under Windows was MS's technobabbled nonsense.

Thus, I tought computers where a crappy blackbox for College engineers and with no open knowledge. Until early 00's.

Then GNU/Linux came, with full manuals included for everything with Debian Woody and then Sarge. I tried to do the same with PostScript, it's kinda the literal same thing as Logo, but now the environment was much saner and understandable, with Emacs calling GV on demand, and the most importang thing: documentation. As simple was that. Bundled help files.

You didn't require books not found anywhere else, nor an internet connection, nor people really far from your blue collar relatives who had no connection to computers. The gap between the nerdy kid with young parents around computers and me became much smaller, and the GNU/BSD guys did an oustanding work spreading IT to anyone.


See https://news.ycombinator.com/from?site=github.com/nanochess for discussions on other such amazing projects.


Same developer


It's 508 bytes, much better than what a compiler can do, and yet from a quick glance at the source I can still find a few more bytes to squeeze out.


Oh? Do tell.


Looks like some of the other comments here have found a few of the optimisations already, but another one is that BIOS functions don't change register values unless specifically used for output --- in HLL jargon, all registers are effectively callee-save. Thus no need to e.g. use 16-bit move immediate when an 8-bit would be sufficient due to the other half already having the right value.


No way to define procedures and no list processing? Hardly LOGO.


But still impressive. I will see, if I can massage Justine Tunney's sectorlisp into something resembling a (subset of) LOGO, probably w/o turtle graphics. Deliverable will probably be a DOS COM-file rather than a boot sector.


The other day when I was hacking together on some GCode for a small CNC table, it felt somehow very similar to me: I realized that, as a five or six year old, playing with Logo/Turtle graphics on Apple ][ machines--my first interactions with computers--was essentially the same conceptual loop.


Programming Computer Animation in 1964 - AT&T Archives: https://www.youtube.com/watch?v=-5mFhDIJfNA

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.


-- Robert Jordan


The same goes for plot(6) on plan 9: http://man.9front.org/6/plot

It's all vectors and arcs though some newer controllers do splines and other curves in hardware during execution using vendor specific instructions.


Thank you so much. Logo was the first computer language I learned. Incredible implementation in asm.


ah same!

i learned logo in my native language (ptbr) when i was in middle school. it absolutely blew my mind that i could "automatically" draw things.

first thing i did when i got home was ask my dad for it -- it took him to find the proper floppy (he borrowed from a friend that was a CS teacher!).

fun fact: we didn't call it logo, we called it "the little turtle game".


Same. Logo taught me the only important part of computer science: the computer does what the program tells it to - no more, no less... Everything else in computer science is implementation details and incident factors !


Yes, but in the mid 90's, teaching Logo to Elementary students sucked at lot. We barely touched Logo for a week and doing advanced stuff was just something for kids with computers at home with young parents.

I was lucky to get a Debian release from a magazine in early 00's, my relation to computers did a 180 degree turn. That and retroemulation, I even learnt C64 basic just for fun under VICE/CSS64. From that era I loved Perl, text adventures, self-learning from books and lots of howtos on C and PostScript.


I am an unabashed nanochess fanboy but it’s not really Logo without lists and functions.


True. People often think Logo is just turtle graphics, but it really is a complete programming language that is, despite the syntax, actually related to Lisp. Brian Harvey even wrote a series of intro CS texts using Logo that didn't use turtle graphics at all. Brian's home page has the full text of them. https://people.eecs.berkeley.edu/~bh/

(that being said, I get that full Logo would not be possible in 508 bytes)


It seems to be the fate of programming languages (especially ones few people currently use) to get stereotyped by a small fraction of their utility. I guess the best we can hope for is that the stereotype (Lisp: parens; C: segfaults) is at least tangentially related to the reasons people use the language, as opposed to completely unrelated stereotypes (Logo: turtle; ??: ??).


This makes me so happy. Logo on the Apple IIe was my first exposure to programming ever as a kid.


So it loads and boots in ... one ... disk command? Under a millisecond, all up?

On actual physical hardware it may well have booted before the power switch makes it all the way back up. Outrageous.


Would it be possible to hack the management engine in such a way that during boot it makes an internet connection and imports some logo from the internet?

Or is it more theory?


> Would it be possible to hack the management engine in such a way that during boot it makes an internet connection and imports some logo from the internet?

This rather sounds like something that one could implement as an UEFI application.


That sounds like PXE booting with one more step


This look so refreshing OP! Will try to make some changes and have fun!




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

Search: