OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 10:02 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 72 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

What is your favorite entry for the fourth 512-byte OS contest ?
Poll ended at Sun Jan 31, 2010 6:52 am
waveos by waga 6%  6%  [ 1 ]
wordsmith by coddy 0%  0%  [ 0 ]
mon86 by a427 35%  35%  [ 6 ]
bsantm by Gigasoft 12%  12%  [ 2 ]
scrollroad by MessiahAndrw 12%  12%  [ 2 ]
fractalscroll by Gigasoft 6%  6%  [ 1 ]
snake by Cjreek 0%  0%  [ 0 ]
ethernet by XanClic 18%  18%  [ 3 ]
spatiallife by Krap 12%  12%  [ 2 ]
terrain/butterfly by js 0%  0%  [ 0 ]
Total votes : 17
Author Message
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Mon Dec 28, 2009 7:23 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
Yea, I think I know what I'm going to do now.. I'm thinking I could make an at least partial FORTH interpreter... that would be pretty neat and the syntax is easy enough to parse in assembly(without tearing my hair out)

_________________
My new NEW blag


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Wed Dec 30, 2009 9:21 am 
Offline
Member
Member

Joined: Sun Mar 15, 2009 9:45 pm
Posts: 40
Well, apparently quite a lot of other people were in fact interested in this fourth 512 asm compo.
Nice !

Let's hope we can set the closing date..

I propose 2010 january 15th ?
What do you think ?

About an eventual prize, I don't think it's so important..
The previous compos did not feature a winning prize, AFAIK, and I guess we like to compete for the fun, anyway...

Concerning the compo requirements (SSE2, etc..), there are none, except for the obvious :

-the compo entry shall fit a 512 bytes binary single file
-it must be bootable by an x86 compatible BIOS + CPU in real mode
-it's a damn plus if we can quick test it with qemu, bochs, etc..

other than that, everything is allowed !
(8086, pentium 4 instructions sets; BIOS interrupts, etc...)


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Wed Dec 30, 2009 9:31 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
a427 wrote:
Well, apparently quite a lot of other people were in fact interested in this fourth 512 asm compo.
Nice !

Let's hope we can set the closing date..

I propose 2010 january 15th ?
What do you think ?

About an eventual prize, I don't think it's so important..
The previous compos did not feature a winning prize, AFAIK, and I guess we like to compete for the fun, anyway...

Concerning the compo requirements (SSE2, etc..), there are none, except for the obvious :

-the compo entry shall fit a 512 bytes binary single file
-it must be bootable by an x86 compatible BIOS + CPU in real mode
-it's a damn plus if we can quick test it with qemu, bochs, etc..

other than that, everything is allowed !
(8086, pentium 4 instructions sets; BIOS interrupts, etc...)


I assume that 64bit is allowed also then(if someone dares to tackle that in 512 bytes)

and yea, a little update to my project..

My forth OS so far is going pretty well but running out of space fast(now at 470 bytes)..
It will print `ok` at the end of commands. It supports a stack of 4096 bytes. It supports the standard +,-,@,and ! words/operators. Also, I put in 2 extensions for `^` and `&` for writing and reading the current segment data will be writtent o(respectively)

My next task will be implementing the do while word, which could make it sorta close to turning complete(if you double the while structure as an if structure)

_________________
My new NEW blag


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Sat Jan 02, 2010 9:26 pm 
Offline
Member
Member

Joined: Thu Feb 26, 2009 1:45 am
Posts: 38
A byte is a byte...

Here's a hack for the gamers in you.

To understand / use such a thing, you need a twisted mind -- but I guess anybody trying to write a 512-byte demo has one.

It increments / decrements two registers representing x and y position when you press left/right/up/down arrowed keys. And it's only 28 bytes, including jumping back to the main loop at the end of the work, and not blocking if no key was pressed (so you can continue redrawing the screen while no key is pressed). I included a few pieces of code to make a mini-demo out of it, but that's not counted in the 28 bytes.

It works by building an inc/dec bx/dx opcode from scratch into ax, moving this value just before the main loop (overwriting the initialization stuff you left there) and jumping to that location.

If somebody knows a smaller hack to achieve the same result, I *really* am interested.

Have fun !

Note: If you can't download the attachments, I've stored them here too : http://jahvascriptmaniac.free.fr/2010/p ... tkey-hack/


Attachments:
File comment: Compiled bootsector image
getkey-28-bytes-cleaned.img.asm [512 Bytes]
Downloaded 125 times
File comment: Assembly source code
getkey-28-bytes-cleaned.asm [2.95 KiB]
Downloaded 181 times
Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Sat Jan 02, 2010 9:40 pm 
Offline
Member
Member
User avatar

Joined: Tue Dec 25, 2007 6:03 am
Posts: 734
Location: Perth, Western Australia
My friend, this is one of the most clever tricks I have seen for quite a while!
We could do with a size hacks wiki page or something like that for these things.

_________________
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Sat Jan 02, 2010 10:45 pm 
Offline
Member
Member

Joined: Thu Feb 26, 2009 1:45 am
Posts: 38
[font=small]Note : if this is too much off topic, please tell me, I'll move it into a new topic.[/font]

thepowersgang wrote:
My friend, this is one of the most clever tricks I have seen for quite a while!
We could do with a size hacks wiki page or something like that for these things.


Thanks ;)

I actually spent a whole day on it, maybe two...
I investigated the following possibilities, in approx. order of size, decreasing :

Trivial, unoptimized, but you can easily change the keycodes

Code:
cmp ah,KEYCODE_UP
jne .1
    inc dx
.1
cmp ah,KEYCODE_DOWN
jne .2
    dec dx
.2
cmp ah,KEYCODE_RIGHT
jne .3
    inc bx
.3
cmp ah,KEYCODE_LEFT
jne .4
    dec bx
.4


A "tree" of bit-testing hacks
Choose HACK1 so that :
Code:
    0 == (HACK1 & KEYCODE_UP) == (HACK1 & KEYCODE_DOWN)
    1 == (HACK1 & KEYCODE_LEFT) == (HACK1 & KEYCODE_RIGHT)

Choose HACK2 so that :
Code:
    0 == (HACK2 & KEYCODE_UP)
    1 == (HACK2 & KEYCODE_DOWN)

Choose HACK3 so that :
Code:
    0 == (HACK3 & KEYCODE_LEFT)
    1 == (HACK2 & KEYCODE_RIGHT)


Code:
mov al,ah
and al,HACK1
jnz .horizontal
    and ah,HACK2
    jnz .down
        inc dx
    .down
        dec dx
.horizontal
    and ah,HACK3
    jnz .right
        dec bx
    .right
        inc bx


Choose jump adress hack
The arrow keys scancodes have the following property : if you zero out their least significant bit, then they each have their first bit counting from the right in a different position. Luckily, the 'bsf' (bit search forward) instruction returns the position of the rightmost set bit.

0101 0000 DOWN
0100 1000 UP
0100 1101 RIGHT
0100 1011 LEFT

Code:
mainloop:
    ; Do something
   
    ; Check for next key
    mov ah, 0x01
    int 16h
    jz mainloop
        ; Manage pressed key and jump back to mainloop
        xor ax,ax
        int 16h

        and ax, 0x1e00    ; keep bits 1,2,3 and 4
        bsf ax, ax    ; see top of the file to see why this works...
        shl ax,1    ; each case takes two opcodes (inc/dec, ret)
        add ax, .do_movements - 16 - 2
        call ax

        jmp short mainloop

        ; the 'call' just above will call one of these.
        .do_movements:
        dec bx
        ret
        inc bx
        ret
        dec dx
        ret
        inc dx
        ret


Dynamic code generation
The hack I used

Code as data hack
I didn't try this one.

Principle : when you have some random data, say the adress of your back buffer, you can actually put a value that represents one or severall opcodes. Then, at some point, you jump onto those opcodes. better be a jump you must do anyway, cause otherwise you'll use up two bytes for the extra jump.

It's even better if you can dynamically generate an opcode just before those data-code bytes ;)


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Sun Jan 03, 2010 4:50 pm 
Offline
Member
Member

Joined: Sun Mar 15, 2009 9:45 pm
Posts: 40
@js: nice job !

I'm sure it can help some guys to shrink bytes and improve their 512 asm compo !

Maybe you can even participate yourself ?

What about choosing a deadline ?

Are there more people interested, or should we keep the 15th januray 2010 ?


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Sun Jan 03, 2010 6:19 pm 
Offline
Member
Member

Joined: Thu Feb 26, 2009 1:45 am
Posts: 38
a427 wrote:
I'm sure it can help some guys to shrink bytes and improve their 512 asm compo !

That's why I posted it ;-)

a427 wrote:
Maybe you can even participate yourself ?

Of course I am participating...

a427 wrote:
Are there more people interested, or should we keep the 15th januray 2010 ?

I'm ok with that deadline. I discovered this thread on december 30, (when this deadline was suggested), and started coding immediately...


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Mon Jan 04, 2010 1:38 pm 
Offline
Member
Member

Joined: Thu May 28, 2009 2:41 pm
Posts: 70
Location: Germany
Hi,

Here's my 512 Byte OS. It's the well known game "Snake". You've to compile it with FASM. NASM will create a file which is a little bit larger than 512 bytes.


Attachments:
File comment: The source code. Comments are only german.
snake.asm [5.96 KiB]
Downloaded 367 times
File comment: The game OS
snake.zip [595 Bytes]
Downloaded 244 times
Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Mon Jan 04, 2010 3:00 pm 
Offline
Member
Member
User avatar

Joined: Fri Jan 27, 2006 12:00 am
Posts: 1444
earlz wrote:
Yea, I think I know what I'm going to do now.. I'm thinking I could make an at least partial FORTH interpreter... that would be pretty neat and the syntax is easy enough to parse in assembly(without tearing my hair out)

There was a FORTH interpreter in the first 512b compo, so it can be done.


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Mon Jan 04, 2010 8:49 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
Dex wrote:
earlz wrote:
Yea, I think I know what I'm going to do now.. I'm thinking I could make an at least partial FORTH interpreter... that would be pretty neat and the syntax is easy enough to parse in assembly(without tearing my hair out)

There was a FORTH interpreter in the first 512b compo, so it can be done.


Was it a complete enough Forth implementation to be turing complete? Cause I'm seriously giving up if so lol

_________________
My new NEW blag


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Tue Jan 05, 2010 7:17 am 
Offline
Member
Member

Joined: Sun Mar 15, 2009 9:45 pm
Posts: 40
Wow, we have now quite a pretty amount of entries !

Thank you all for your enthusiasm !!

I edited the main post to list the already submitted entries, with proper links..

The deadline for the compo has been accepted as January 15th 2010 (friday)

Yet I'm not too sure how we will process the votes...

Can somebody with previous experience give some hints how to set up the votes ?


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Tue Jan 05, 2010 7:19 am 
Offline
Member
Member
User avatar

Joined: Thu Jun 04, 2009 11:12 pm
Posts: 281
Hi,
I am in this time.But I am in the middle do lot many things :).I am not sure,whether I will be able to make it.I am writing a small speaker piano :).You press some buttons and you hear music from the pc speaker :) .

--Thomas


Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Tue Jan 05, 2010 11:26 am 
Offline
Member
Member
User avatar

Joined: Wed Feb 13, 2008 9:38 am
Posts: 138
Hi,

This is my contribution to this contest. It's an OS running in real mode which is capable of sending an ARP network packet over an RTL8139 network card. That means you can resolve IP addresses to MAC addresses in the current LAN. Once it's started, you enter your IP and the IP to be resolved. Then it'll print your MAC and (hopefully :wink:) the destination's MAC address.

You need to assemble it with FASM, maybe it also works with NASM, some adjustment and -O99.

There's a constant in the code called "Os_level". You can choose a level to reduce the size of the binary (though it's always 512 bytes if you don't remove the padding at the end). The code contains detailed explanations of all five levels. Here are the resulting sizes (with "times 510-($-$$) db 0" commented out):
Os =
  • 0: 507 bytes
  • 1: 441 bytes
  • 2: 414 bytes
  • 3: 388 bytes
  • 4: 312 bytes

PS: If you don't have an RTL8139 card available, you can test it with qemu and:
Code:
qemu -fda arp.img -net user -net nic,model=rtl8139

Qemu won't care about your IP (as far as I know), though only values between 10.0.2.15 and 10.0.2.254 are in the narrow sense correct. As a destination you may try 10.0.2.2 (the gateway and DHCP server) or 10.0.2.3 (the DNS server). There should also be another server on 10.0.2.4, but I didn't find anything.


Attachments:
File comment: Compiled source code, padded to 1474560 Bytes
arp.img.bz2 [622 Bytes]
Downloaded 205 times
File comment: Compiled source code (Os_level = 0)
arp.bin.gz [525 Bytes]
Downloaded 203 times
File comment: Source code
arp.asm [14.25 KiB]
Downloaded 387 times
Top
 Profile  
 
 Post subject: Re: The Fourth 512-byte OS Contest!
PostPosted: Tue Jan 05, 2010 4:26 pm 
Offline
Member
Member

Joined: Sun Mar 15, 2009 9:45 pm
Posts: 40
@XanClic: amazing !!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 72 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 47 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group