Making Snake Boot Sector Game in Assembly (x86)

Поділитися
Вставка
  • Опубліковано 1 бер 2024
  • In this video I will make a simple boot sector snake game in Assembly that runs using BIOS interrupts.
    Documentation:
    FASM - flatassembler.net/docs.php?ar...
    IBM BIOS Interface - ia801505.us.archive.org/18/it...
    Intel 8086 User Manual - edge.edx.org/c4x/BITSPilani/E...
    Code:
    gist.github.com/nir9/fd672882...
  • Наука та технологія

КОМЕНТАРІ • 48

  • @LB4FH
    @LB4FH 3 місяці тому +13

    I love these small bytes of low-level programming, great work

  • @maxscott3349
    @maxscott3349 3 місяці тому +11

    I like that it just overwrites the text in your console

  • @ItsCOMMANDer_
    @ItsCOMMANDer_ 3 місяці тому +18

    Got it running on my android phone (via limbo vm)

  • @multiamphetaminsaft
    @multiamphetaminsaft Місяць тому +1

    Wow, got my PC crashed but this was defenitly worth it!!! Please more low level stuff 👾

  • @low-key-gamer6117
    @low-key-gamer6117 3 місяці тому +10

    you are the defiiniton of mad genius!

  • @varshneydevansh
    @varshneydevansh 3 місяці тому +3

    Dude I was planning for so long to make a pong like game for the boot loader. Thanks for inspiring.

  • @pianissimo7121
    @pianissimo7121 3 місяці тому +2

    I haven't watched the video, but I am guessing the code in not production ready(joking).
    But the main reason I am subbed to your channel is that it gives me confidence for some odd reason.
    Seeing you show how your read the documentation and perform such simple application makes it seem like even I can do it.
    Once I am done with whatever I am learning, I will go through your channel and try to implement a lot of the simpler stuff myself.

  • @YetAnotherSysAdmin
    @YetAnotherSysAdmin 3 місяці тому +1

    Great informative videos!
    Keep it up.
    Never been very deep into ASM but like seeing low level code - if that makes sense.

  • @radderek007
    @radderek007 3 місяці тому

    Luv your style. From the docs … Lo level learning … hi level thinking

  • @milk-it
    @milk-it 2 місяці тому

    If I saw that screen appear with the text "Booting from Hard Disk..." and a snake crawling back on my old XT, I would've thought it was infected with the BIOS Snake Virus!

  • @twobob
    @twobob 3 місяці тому

    hah. I saw your post and already had a go at this!!! Glad this was picked

  • @A5A5A5A5h
    @A5A5A5A5h 3 місяці тому

    I once built a LISP interpreter in real mode using C. This is definitely too much for me. 😂 Nice video as always btw 👍

  • @eugenesorokin6602
    @eugenesorokin6602 3 місяці тому

    well, good video, thanks, it's pleasant to see pc's asm. by the way nobody (yet) cancelled tabstops in asm. the first tab is for labels, second for the code mnemonics

  • @plato4ek
    @plato4ek 3 місяці тому

    Yeah! You've put the links to the docs. 👍

  • @ChandrashekarCN
    @ChandrashekarCN 3 місяці тому

    💖💖💖💖

  • @AhmadAlMutawa_abunoor
    @AhmadAlMutawa_abunoor 3 місяці тому +2

    Very nice. Would the game still work if you implemented the growing of the snake after handling food?

    • @EinSatzMitX
      @EinSatzMitX 3 місяці тому

      Why not?

    • @nirlichtman
      @nirlichtman  3 місяці тому +1

      Yes, just skipped that to not overcomplicate the vid :)

    • @EinSatzMitX
      @EinSatzMitX 3 місяці тому +1

      @@nirlichtman also you would have to stay below 512 bytes, if you really wanted to have the game in the boot sector

    • @maxmuster7003
      @maxmuster7003 3 місяці тому

      OSdevWiki Detecting memory: By far the best way to detect the memory of a PC is by using the INT 0x15, EAX = 0xE820 command. This function is available on all PCs built since 2002, and on most existing PCs before then. It is the only BIOS function that can detect memory areas above 4G. It is meant to be the ultimate memory detection BIOS function.

    • @xormak3935
      @xormak3935 Місяць тому

      @@EinSatzMitX I know this is late but if you're referring to the 512 bytes listed after assembly, that's just the binary being forced into a default binary alignment. The actual code he wrote probably doesn't scratch that limit at all, so adding the growing of the snake shouldn't be an issue at all.

  • @bebdaumon3948
    @bebdaumon3948 3 місяці тому

    😎😎👍👍

  • @jazzd2k
    @jazzd2k 3 місяці тому

    nice video, do it for uefi also, it would be great 😊

  • @aliaxxei
    @aliaxxei 3 місяці тому

    Doesn't boot tho :) Thanks for the video, it was nice to recall this experience.

    • @ItsCOMMANDer_
      @ItsCOMMANDer_ 3 місяці тому

      Why? Vm kr real hardware, if real hardware (and maybe vm) yoili have to select csm/legacy boot, thta could be the issue

  • @GlorytoTheMany
    @GlorytoTheMany 3 місяці тому

    Was my comment deliberately moderated or was it automatically removed by the algorithm? If the former, it's OK; if the latter, I'd reword and post it again. Anyway, it was about how I also implemented a boot sector game which is also a hybrid executable so it can be started from DOS too.

  • @maxmuster7003
    @maxmuster7003 3 місяці тому

    Intel developer manual pdf from MS and Ralph Browns Interrupt List original within some zip archiv + html version with a table of interrupt numbers online

  • @anon_y_mousse
    @anon_y_mousse 3 місяці тому

    This makes me wonder how small you can get it and still use graphics. For that matter, what's the smallest you can get the source code, assuming we don't allow a unique code golf language just to play snake.

  • @ItsCOMMANDer_
    @ItsCOMMANDer_ 3 місяці тому

    Also fits into a qr which is a nice bonus, but what advantage does fasm have over gas (gnu assembler, aka default linux assembler), also, snake no lengthen :(
    (ik it would be much harder (speaking from experience (also in asm but with linux)))

    • @nirlichtman
      @nirlichtman  3 місяці тому +1

      Nice, didn't think about that :) I prefer FASM if I am writing x86 since gas uses by default the AT&T syntax which in my opinion is less intuitive. gas does have an option to set intel syntax but from what I read it is pretty buggy when using intel syntax.

    • @maxmuster7003
      @maxmuster7003 3 місяці тому

      I use NASM on linux with intel syntax.

  • @EnLopXf
    @EnLopXf 3 місяці тому

    I'm waiting for next Win API tutorials

    • @nirlichtman
      @nirlichtman  3 місяці тому

      Next video will be Windows API related

  • @ABCABC-sw8mh
    @ABCABC-sw8mh 3 місяці тому +3

    The snake eats the boot logs 😂😂

  • @subhamcoder
    @subhamcoder 3 місяці тому

    😮😮😮😮😮😮😮

  • @EStartive
    @EStartive 3 місяці тому

    Wouldn't this be able to fit on a floppy disk? Would be cool if this was ran on like a Windows 95 computer lol

    • @npc_code
      @npc_code 3 місяці тому

      3½-inch had 1,44mb so yes plenty of space. But it would be a nice video idea to do it on real hardware.

    • @nirlichtman
      @nirlichtman  3 місяці тому +1

      Yes, this is a nice idea I wanted to also show this running on a real computer and also talk a little about disassembling the binary using Rizin but since the video turned out quite long in the end, I will do these stuff in a separate video

    • @maxmuster7003
      @maxmuster7003 3 місяці тому

      I guess the game need less than 64 kb.

  • @shad578
    @shad578 3 місяці тому

    What is your github?

  • @maxmuster7003
    @maxmuster7003 3 місяці тому

    We can write ASCII and color directly into the screen memory without to set the cursor.
    Example:
    mov ax, x0b800
    mov es, ax
    cld
    mov di, (row*80*2) + (collum*2)
    mov ah, color
    mov al, ASCII
    stosw

  • @maxmuster7003
    @maxmuster7003 3 місяці тому

    How to exchange 8 ASCII character capital letter A - H with some new pixel using 8x16 character size on 80x25 text screen.
    ABCD
    EFGH
    All values are hexadecimal:
    mov ax,1110 ; function of user character
    mov bp,0118 ; buffer with character
    mov cx,8
    mov dx,41 ; start with "A"
    xor bl,bl
    mov bh,10 ; 16
    int 10
    ret
    org 0118
    DB 0,0,1,7,1f,3f,7f,7f,7f,7e,7c,7c,7c,7c,7c,7c
    DB 0,3f,ff,ff,ff,ff,ff,ff,1f,f,7,7,7,7,7,7
    DB 0,fc,ff,ff,ff,ff,ff,ff,f8,f0,e0,e0,e0,e0,e0,e0
    DB 0,0,80,e0,f8,fc,fe,fe,fe,7e,3e,3e,3e,3e,3e,3e
    REM 00000000 00000000 00000000 00000000
    REM 00000000 00111111 11111100 00000000
    REM 00000001 11111111 11111111 10000000
    REM 00000111 11111111 11111111 11100000
    REM 00011111 11111111 11111111 11111000
    REM 00111111 11111111 11111111 11111100
    REM 01111111 11111111 11111111 11111110
    REM 01111111 11111111 11111111 11111110
    REM 01111111 00011111 11111000 11111110
    REM 01111110 00001111 11110000 01111110
    REM 01111100 00000111 11100000 00111110
    REM 01111100 00000111 11100000 00111110
    REM 01111100 00000111 11100000 00111110
    REM 01111100 00000111 11100000 00111110
    REM 01111100 00000111 11100000 00111110
    REM 01111100 00000111 11100000 00111110
    DB 7c,7c,7c,7c,7c,3e,3f,3f,1f,7,3,1,0,0,0,0
    DB 7,7,7,7,7,7,1f,fe,fc,fc,ff,c0,f0,7f,f,0
    DB e0,e0,e0,e0,e0,e0,f8,7f,3f,3f,ff,3,f,fe,f0,0
    DB 3e,3e,3e,3e,3e,7c,fc,fc,f8,e0,c0,80,0,0,0,0
    REM 01111100 00000111 11100000 00111110
    REM 01111100 00000111 11100000 00111110
    REM 01111100 00000111 11100000 00111110
    REM 01111100 00000111 11100000 00111110
    REM 01111100 00000111 11100000 00111110
    REM 00111110 00000111 11100000 01111100
    REM 00111111 00011111 11111000 11111100
    REM 00111111 11111110 01111111 11111100
    REM 00011111 11111100 00111111 11111000
    REM 00000111 11111100 00111111 11100000
    REM 00000011 11111111 11111111 11000000
    REM 00000001 11000000 00000011 10000000
    REM 00000000 11110000 00001111 00000000
    REM 00000000 01111111 11111110 00000000
    REM 00000000 00001111 11110000 00000000
    REM 00000000 00000000 00000000 00000000