Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Classic Atari games are so small that you could include them as inline comments (twitter.com/id_aa_carmack)
3 points by tosh on Jan 5, 2024 | hide | past | favorite | 1 comment


> Arthur Rasmusson @vGPUArthur

> My favourite thing in TempleOS is inline assembly and sprite graphics in C code.

BBC Basic has inline 6502 assembler.

    10 DIM code 100
    20 P% = code
    30 [
    40   LDA #&48
    50   JSR &FFEE
    60   LDA #&65
    70   JSR &FFEE
    80   LDA #&6C
    90   JSR &FFEE
    100  LDA #&6C
    110  JSR &FFEE
    120  LDA #&6F
    130  JSR &FFEE
    140  RTS
    150 ]
    160 CALL code
In this example:

Line 10 reserves 100 bytes of memory for a block called code.

Line 20 sets the program counter P% to point to the start of this memory block.

Lines 30-150 define the assembly code block. This code loads the ASCII value of each character in "Hello" into the accumulator and then calls the OSWRCH routine (at &FFEE) to print the character to the screen.

Line 160 calls the machine code routine to execute the print operation.




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

Search: