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... - Наука та технологія
I love these small bytes of low-level programming, great work
I like that it just overwrites the text in your console
Got it running on my android phone (via limbo vm)
Wow, got my PC crashed but this was defenitly worth it!!! Please more low level stuff 👾
you are the defiiniton of mad genius!
Dude I was planning for so long to make a pong like game for the boot loader. Thanks for inspiring.
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.
Great informative videos!
Keep it up.
Never been very deep into ASM but like seeing low level code - if that makes sense.
Luv your style. From the docs … Lo level learning … hi level thinking
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!
hah. I saw your post and already had a go at this!!! Glad this was picked
I once built a LISP interpreter in real mode using C. This is definitely too much for me. 😂 Nice video as always btw 👍
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
Yeah! You've put the links to the docs. 👍
💖💖💖💖
Very nice. Would the game still work if you implemented the growing of the snake after handling food?
Why not?
Yes, just skipped that to not overcomplicate the vid :)
@@nirlichtman also you would have to stay below 512 bytes, if you really wanted to have the game in the boot sector
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.
@@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.
😎😎👍👍
nice video, do it for uefi also, it would be great 😊
Doesn't boot tho :) Thanks for the video, it was nice to recall this experience.
Why? Vm kr real hardware, if real hardware (and maybe vm) yoili have to select csm/legacy boot, thta could be the issue
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.
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
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.
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)))
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.
I use NASM on linux with intel syntax.
I'm waiting for next Win API tutorials
Next video will be Windows API related
The snake eats the boot logs 😂😂
😮😮😮😮😮😮😮
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
3½-inch had 1,44mb so yes plenty of space. But it would be a nice video idea to do it on real hardware.
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
I guess the game need less than 64 kb.
What is your github?
nir9
Ok @@nirlichtman
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
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