pouët.net

Go to bottom

Num-B-in-ator 512 bytes + raytraced RTC in it

category: code [glöplog]
 
Hi all!
I coded a byte code interpreter in 512 bytes for x86 PC ( 386 plus 387 fpu or compatible CPU) with VGA graphic card.
No dos , windows or linux.
Use old BIOS. No uefi.
Not tested on real hardware only in bochs emulator.
Use any assembler that can output plain binary image.
Then use it as boot sector.
Code: db 031h ; Copyright 2020 SoLO tHe ChaOs / Easy Future db 0C0h ; db 050h ; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following db 01Fh ; conditions are met: db 050h ; db 007h ; 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following db 0FAh ; disclaimer. db 050h ; db 017h ; 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following db 050h ; disclaimer in the documentation and/or other materials provided with the distribution. db 05Ch ; db 0FBh ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, db 050h ; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE db 068h ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, db 02Dh ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; db 07Ch ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN db 0CBh ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS db 000h ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. db 000h ; db 010h ; num-B-in-ator a byte code interpreter by SoLO tHe ChaOs / Easy Future in 512-byte boot sector version 2020 August first db 040h ; ----------------------------------------------------------------- db 000h ; You need a 386 cpu & 387 coprocessor (FPU) or compatiblile db 000h ; Program starts in data entry mode and You may turn off caps lock then: db 0C0h ; Press a key like 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e or f to put high 4-bit part (H) of a data byte. db 03Fh ; Press a key like 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e or f to put low 4-bit part (L) of a data byte, then a byte represented by db 0CEh ; both parts (H0h or 0Lh = HLh) will be placed in memory at adress 08000h and pointer will be advanced to the next byte. db 0FAh ; You can decrement pointer by 1 when You press once a backspace key. db 000h ; To switch to code entry press an 'm' key. db 000h ; In byte code entry mode You may check if You shift key isn't stuck then : db 001h ; Press a key like 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e or f to put high 4-bit part (H) of a byte code. db 000h ; Press a key like 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e or f to put low 4-bit part (L) of a byte code then a byte represented by db 000h ; both parts (H0h or 0Lh = HLh) will be placed in memory at adress 07E00h and pointer will be advanced to the next byte. db 000h ; You can decrement pointer by 1 when You press once a backspace key. db 03Ch ; To swich to data entry mode reboot or power off your machine. All data will be lost forever! db 000h ; To swich to execution mode press a 'g' key and see if You fingers are numb. db 000h ; If You typed correctly num-B-in-ator will execute Yours byte code. db 000h ; These are byte code instuructions that num-B-in-ator can execute: db 010h ; 3ch XXh - call procedure at byte code pointer (BCP) plus XXh signed byte offset , no recurse allowed, db 00Eh ; no nesting allowed, no parameters allowed db 000h ; 41h - return from procedure called by above byte code , no results returned db 000h ; 36h XXh - jump to byte code pointer plus XXh signed byte offset db 0C0h ; 2eh XXh YYh ZZh - jump to byte code pointer plus ZZh signed byte offset IF float at unsigned byte data pointer XXh db 0A8h ; is above float at unsigned byte data pointer YYh ([XXh]>[YYh] if true then jump BCP+ZZh) db 000h ; 52h WWh XXh YYh ZZh - add an unsigned integer (word 16-bit) pointed by unsigned byte data pointer XXh to db 000h ; an unsigned integer (word 16-bit) pointed by unsigned byte data pointer WWh then db 0DBh ; compare a signed integer (short 16-bit) pointed by unsigned byte data pointer WWh with db 0E3h ; a signed integer (short 16-bit) pointed by unsigned byte data pointer YYh and if db 0B8h ; greater jump to byte code pointer plus ZZh signed byte offset db 000h ; ([WWh]=[WWh]+[XXh] then [WWh]>[YYh] if ture then jump BCP+ZZh) db 0A0h ; c6h XXh YYh ZZh - add a float at unsigned byte data pointer XXh to a float at unsigned byte data pointer YYh db 050h ; then store result in a float at unsigned byte data pointer ZZh ([XXh]+[YYh]=[ZZh]) db 00Fh ; 8bh XXh YYh - change sign and store float at unsigned byte data pointer YYh from db 0A1h ; a float at unsigned byte data pointer XXh ([YYh]=-[XXh]) db 0BBh ; 84h XXh YYh - copy a float at unsigned byte data pointer XXh to db 000h ; a float at unsigned byte data pointer YYh ([YYh]=[XXh]) db 080h ; db 031h ; db 0FFh ; 7fh XXh YYh ZZh - divide a float at unsigned byte data pointer XXh by a float at unsigned byte data pointer YYh db 031h ; and store it at a float at unsigned byte data pointer ZZh db 0C9h ; no check for zeros at [YYh] ([ZZh]=[XXh]/[YYh]) "crash and burn" if [YYh]=0! db 0B4h ; 9ah XXh YYh - Square root of a float at unsigned byte data pointer XXh stored in db 010h ; a float at unsigned byte data pointer YYh ([YYh]=sqrt([XXh]) db 0CDh ; a3h XXh YYh - Length of a 3D vector (3 floats X,Y,Z) starting at unsigned byte data pointer XXh stored in db 016h ; a float at unsigned byte data pointer YYh ([YYh]=sqrt([XXh]*[XXh]+[XXh+4]*[XXh+4]+[XXh+8]*[XXh+8])) db 0B4h ; b3h XXh YYh ZZh - copy a float at unsigned byte data pointer YYh plus four times db 00Eh ; an unsigned integer (word 16-bit) pointed by unsigned byte data pointer XXh to db 0CDh ; a float at unsigned byte data pointer ZZh then db 010h ; decrement by one an unsigned integer (word 16-bit) pointed by unsigned byte data pointer XXh db 03Ch ; d7h WWh XXh YYh ZZh - signed multipy an unsigned integer (word 16-bit) pointed by unsigned byte data pointer WWh by db 06Dh ; signed integer (word 16-bit) pointed by unsigned byte data pointer XXh then db 077h ; substract an unsigned integer (word 16-bit) pointed by unsigned byte data pointer YYh finaly db 0F4h ; store result in unsigned integer (word 16-bit) pointed by unsigned byte data pointer ZZh db 074h ; ([ZZh]=([WWh]*[XXh])-[YYh]) db 00Bh ; 93h XXh YYh ZZh - dot product of 3D vector (3 floats X,Y,Z) pointed by unsigned byte data pointer XXh and db 03Ch ; 3D vector (3 floats U,V,W) pointed by unsigned byte data pointer YYh stored db 067h ; at a float at unsigned byte data pointer ZZh ([ZZh]=([XXh]*[YYh]+[XXh+4]*[YYh+4]+[XXh+8]*[YYh+8])) db 074h ; c1h WWh XXh YYh ZZh - signed multipy a float at unsigned byte data pointer WWh by a float at unsigned byte data pointer XXh db 027h ; then add a float at unsigned byte data pointer YYh and store result in db 03Ch ; a float at unsigned byte data pointer ZZh ([ZZh]=([WWh]*[XXh])+[YYh]) db 008h ; 78h WWh XXh YYh ZZh - signed multipy a 3D vector (3 floats X,Y,Z) pointed by unsigned byte data pointer XXh by db 075h ; a float at unsigned byte data pointer WWh then add a db 007h ; 3D vector (3 floats U,V,W) pointed by unsigned byte data pointer YYh and store result in db 04Fh ; 3D vector (3 floats R,S,T) pointed by unsigned byte data pointer ZZh db 0EBh ; ([ZZh]=[XXh]*[WWh]+[YYh],[ZZh+4]=[XXh+4]*[WWh]+[YYh+4],[ZZh+8]=[XXh+8]*[WWh]+[YY h+8]) db 0E5h ; 22h XXh YYh - put a dot of 1 of 64 grays selected by a float at unsigned byte data pointer XXh db 0B7h ; converted to short integer on a 320x200 dots screen at point a,b where b is veritical cordinate db 07Eh ; represented by unsigned byte (8-bit) pointed by unsigned byte data pointer YYh and db 0EBh ; a is horizontal corrdinate represented by unsigned integer (word 16-bit) pointed by unsigned byte db 0DFh ; data pointer at YYh-2 ([YYh+2]=shade(int([XXh])) screen[[YYh]*320+[YYh-2]]=[YYh+2]) db 02Ch ; d9h XXh YYh ZZh - store a 2D vector (2 floats X,Y) of length 2.25f based on a real time clock seconds db 030h ; at unsigned byte data pointer XXh then db 078h ; store a 2D vector (2 floats U,V) of length 2.25f based on a real time clock minutes db 0DFh ; at unsigned byte data pointer YYh then db 03Ch ; store a 2D vector (2 floats S,T) of length 1.5f based on a real time clock hours db 031h ; at unsigned byte data pointer ZZh db 072h ; db 002h db 02Ch db 027h db 041h db 083h db 0E1h db 001h db 074h db 007h db 0C0h db 0E0h db 004h db 088h db 001h db 0EBh db 0CCh db 008h db 001h db 047h db 0EBh db 0C7h db 0B8h db 013h db 000h db 0CDh db 010h db 031h db 0C0h db 0BAh db 0C8h db 003h db 0EEh db 042h db 0EEh db 0EEh db 0EEh db 0FEh db 0C0h db 075h db 0F9h db 0BDh db 0ACh db 07Ch db 089h db 0DAh db 00Fh db 0B6h db 007h db 0BBh db 000h db 07Eh db 029h db 0C3h db 042h db 0FFh db 0D3h db 0EBh db 0F1h db 0B9h db 003h db 000h db 0D9h db 004h db 0D8h db 00Dh db 066h db 0A7h db 0E2h db 0F8h db 0DEh db 0C1h db 0DEh db 0C1h db 0C3h db 089h db 0D3h db 00Fh db 0B6h db 007h db 005h db 000h db 080h db 089h db 0C6h db 043h db 0C3h db 0E8h db 0F1h db 0FFh db 097h db 0EBh db 0F0h db 0E8h db 0EBh db 0FFh db 0D9h db 004h db 0C3h db 0E8h db 0F7h db 0FFh db 0EBh db 0E5h db 0E8h db 0E0h db 0FFh db 031h db 0C0h db 0A3h db 019h db 07Ch db 0B4h db 002h db 0CDh db 01Ah db 088h db 0F0h db 0BAh db 011h db 07Ch db 0BFh db 021h db 07Ch db 0E8h db 019h db 000h db 0FFh db 0D5h db 088h db 0C8h db 066h db 0AFh db 0E8h db 010h db 000h db 0FFh db 0D5h db 088h db 0E8h db 03Ch db 012h db 072h db 003h db 02Ch db 012h db 02Fh db 0BAh db 015h db 07Ch db 066h db 0AFh db 053h db 0BBh db 000h db 081h db 0D9h db 0EEh db 0DFh db 037h db 088h db 007h db 0D9h db 0EBh db 0D8h db 0C0h db 0DFh db 027h db 0DAh db 04Dh db 0FCh db 0BBh db 019h db 07Ch db 0DAh db 007h db 0DBh db 017h db 0DAh db 035h db 0DEh db 0C9h db 0D9h db 0FBh db 089h db 0D3h db 0D9h db 007h db 0D9h db 0C0h db 0DEh db 0CBh db 0DEh db 0C9h db 0D9h db 05Ch db 004h db 05Bh db 0EBh db 023h db 0EBh db 09Eh db 0E8h db 08Ah db 0FFh db 08Bh db 005h db 0F7h db 02Ch db 097h db 0FFh db 0D5h db 02Bh db 03Ch db 0FFh db 0D5h db 089h db 03Ch db 0C3h db 0E8h db 085h db 0FFh db 0EBh db 007h db 0E8h db 080h db 0FFh db 0D8h db 00Ch db 0FFh db 0D5h db 0D8h db 004h db 0FFh db 0D5h db 0D9h db 01Ch db 0C3h db 0E8h db 066h db 0FFh db 08Bh db 005h db 0FFh db 00Dh db 0C1h db 0E0h db 002h db 001h db 0C6h db 0D9h db 004h db 0EBh db 0EBh db 0E8h db 04Ah db 0FFh db 097h db 0E8h db 036h db 0FFh db 0EBh db 003h db 0E8h db 053h db 0FFh db 0D9h db 0FAh db 0EBh db 0DBh db 0E8h db 046h db 0FFh db 0E8h db 027h db 0FFh db 0EBh db 0D3h db 0E8h db 044h db 0FFh db 0D9h db 0E0h db 0EBh db 0CCh db 0E8h db 03Dh db 0FFh db 0EBh db 0C7h db 0E8h db 03Eh db 0FFh db 0D8h db 034h db 0EBh db 0C0h db 0E8h db 02Bh db 0FFh db 056h db 0FFh db 0D5h db 092h db 0FFh db 0D5h db 058h db 060h db 089h db 0F5h db 0B9h db 003h db 000h db 089h db 0CEh db 04Eh db 0C1h db 0E6h db 002h db 089h db 0C3h db 0D9h db 000h db 0D8h db 00Dh db 089h db 0D3h db 0D8h db 000h db 0D9h db 01Ah db 0E2h db 0ECh db 061h db 0C3h db 0E8h db 005h db 0FFh db 08Bh db 004h db 001h db 005h db 0FFh db 0D5h db 08Bh db 004h db 039h db 005h db 07Fh db 00Fh db 043h db 0C3h db 08Bh db 01Eh db 0FEh db 07Dh db 0C3h db 042h db 089h db 016h db 0FEh db 07Dh db 04Ah db 089h db 0D3h db 00Fh db 0BEh db 007h db 001h db 0C3h db 0C3h db 0E8h db 0EDh db 0FEh db 0D8h db 01Ch db 0DFh db 0E0h db 09Eh db 077h db 0F0h db 043h db 0C3h db 0E8h db 0DBh db 0FEh db 0FFh db 0D5h db 0DFh db 05Ch db 002h db 00Fh db 0B6h db 004h db 0C1h db 0E0h db 006h db 002h db 024h db 053h db 089h db 0C3h db 08Ah db 044h db 002h db 08Bh db 074h db 0FEh db 064h db 088h db 000h db 05Bh db 0C3h db 0F9h db 0E4h db 055h db 0AAh


This is a example of what You can do in Num-B-in-ator.
A real time raytraced clock with shadows.
Type it in after booting Num-B-in-ator (one LONG line of code , no spaces, no return).
Idk why code tag put spaces in... :(
Code: 3f01c700ffff020004000f000100ffff7f4b00007c4200008040000000400000003f000000bfcd cccc3d9a99993e17b7d138cdcc4cbb0ad7a33b0000803f0000803f000080bf0000000000001040000 0a040000080bd000000000000c03f0000a040000080be00000000000000000000a040000080bf0000 00000000000000003041000010c200000000000000000000803f737463082020md93a465684228ad7 020c6694841e86d7000c669236232ea28e3bc1a21266c622c694c1868e328652920404e9c18a8e368 a52940404d736c98486ae848ab2848eb68466ba8466be8466c2848e9e3c75529c666606848ea236be 78a6aebaded79c080698b39846f2b39846eeb39846ea7872eaded2a3d2ea7fd2ead27fd6ead67fdae ada843aae843eb28442b684deba84e2be84e6c2842e9e3c2a520c669c068426a236b4842aa293d23a c62ec6660336a7c11ec666caa33ac67fcac6c6c6c6a2a23695840ea6d76666669c93aeaec6d70a0c6 698d7080c669ab39846ceb39846f2b39846eeb39846ea7872eabaea93eaaecac1ca1a66ca93eaeaea c6eacecec1c61666eac1eace66ea8beaeac1cacaeaea2eea6607529a0466c0419aeaea2eca66048be aeac6eacaeac1ea2266ea7feac6aa7fceeaea2eea9e03360f2ea6ea03360984eaa6d79a0c669c2eaa 9e0336c62ea6aa0336c084aaa6d79a0c669c36b6g

Simualtion animation:
www.vogons.org/download/file.php?id=87089&mode=view
Happy typing!
Quote:
This is a example of what You can do in Num-B-in-ator.


But what is it?
added on the 2020-08-01 21:01:06 by El Topo El Topo
Quote:
A real time raytraced clock with shadows.
Ok, got confused by
Quote:
Type it in after booting Num-B-in-ator
added on the 2020-08-04 09:00:39 by El Topo El Topo

login

Go to top