• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Onemind

Hello World in 28 bytes

18 posts in this topic

I'm taking an Assembly language (x86) class this semester, and the professor said he wrote a Hello World program in 28 bytes. I'm wondering exactly how he got the exe so small. My programs are never smaller than 5kb!
0

Share this post


Link to post
Share on other sites
have you tried it writing in DOS assembler and as a .com ? this should do the trick... there are many tutorials on Hello World in 386 asm on the internet. try google.

regards,
m.
0

Share this post


Link to post
Share on other sites
Keep in mind once you compile and link your asm's the program gets byte-padded so it's appropriate to the OS. When he said he did it in so few bytes, I'm willing to bet that he meant his source code was only that big. Remember, before the byte-padding comes, each instruction maps to a machine instruction.*

* - don't burn me about different instruction sets. =) I know that some RISC psuedo ops and CISC instructions span out to two or more instructions when they get translated.
0

Share this post


Link to post
Share on other sites
It's really not that hard. COM programs don't require any header or padding.
Here's my version (21 bytes). Just paste this into a DOS prompt.

debug
a 100
mov ah,09
mov dx,109
int 21h
int 20h
db "Hello World$"

rcx
15
n hello.com
w
q

0

Share this post


Link to post
Share on other sites
Depends on how we're defining a 'program'. And did your professor say the program was actually in assembler? For instance, this batch file is even shorter than the (correct) 21-byte program above:

<<<
@ECHO Hello, world!
>>>


The above is only 19 bytes. You can even tell your professor you've "optimized" his version. [grin]
0

Share this post


Link to post
Share on other sites
Quote:
Original post by doynax
It's really not that hard. COM programs don't require any header or padding.
Here's my version (21 bytes). Just paste this into a DOS prompt.

debug
a 100
mov ah,09
mov dx,109
int 21h
int 20h
db "Hello World$"

rcx
15
n hello.com
w
q



I don't know ASM, but that was FUN! I wasn't aware that you just type it into the prompt!
0

Share this post


Link to post
Share on other sites
Would the instruction size of the computer make this easier? Ie, could you do it on an 8-bit machine?

edit: never mind, the example above does it in 21 bytes.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Rhaal
Quote:
Original post by doynax
It's really not that hard. COM programs don't require any header or padding.
Here's my version (21 bytes). Just paste this into a DOS prompt.

debug
a 100
mov ah,09
mov dx,109
int 21h
int 20h
db "Hello World$"

rcx
15
n hello.com
w
q



I don't know ASM, but that was FUN! I wasn't aware that you just type it into the prompt!


Agreed (Although I know asm a bit) that was new to me!

Cool stuff!!!

/MindWipe
0

Share this post


Link to post
Share on other sites
Nice! I didn't now that 'int 20h' is sufficient to exit.
My version would like like this:

debug
a 100
mov ah, 09
mov dx, 10b
int 21h
mov ah, 4c
int 21h
db "Hello World!$"

rcx
18
n hello.com
w
q
hello.com

Resulting in 24 bytes. I don't get how the prof could get 28 bytes...

0

Share this post


Link to post
Share on other sites
This is depressing ....

I used to think VB was a cool language ....
Then I though I should learn something C based, so I started C# ...
But the .NET framework was too slow, so now C++ .....
But now I have just found out how easy it is to code stuff like this right into the command prompt ! bah, it just keeps betting better :)
0

Share this post


Link to post
Share on other sites
Quote:
Original post by xyuri
But now I have just found out how easy it is to code stuff like this right into the command prompt ! bah, it just keeps betting better :)


Note that Assembly sure isnt the fastest code in the world, and that some (or rather most) programmers litterally run if you ask them to code assembly. assembly is only good for routines that are called 100ths of time a second (not so much, but u get the point) you can make games with assembly however (Rollercoaster tycoon was writen in it) but i guess u rather learn C (or c++) to keep you from getting mad from assebly :)
0

Share this post


Link to post
Share on other sites
Quote:
Original post by xyuri
But now I have just found out how easy it is to code stuff like this right into the command prompt ! bah, it just keeps betting better :)


Note that Assembly sure isnt the fastest code in the world, and that some (or rather most) programmers litterally run if you ask them to code assembly. assembly is only good for routines that are called 100ths of time a second (not so much, but u get the point) you can make games with assembly however (Rollercoaster tycoon was writen in it) but i guess u rather learn C (or c++) to keep you from getting mad from assembly :)

also a prob: assembly is processor dependent... what u write fot a pentioum, isnt guaranteed to wotk on, lets say, athlon
0

Share this post


Link to post
Share on other sites
Just for the record for budding asm programmers: the asm code snippets above aren't really being entered directly at the command prompt. If you'll notice, the first line given is 'debug', which fires up the debugger. Subsequent asm code and other instructions are then passed to debug, which has a small capability for editing and writing assembly language programs. In these examples, debug is writing the program to the file hello.com, which is then being executed after the 'q' command exits debug. It's not the best way for creating extensive assembly, but it is sufficient for testing out small things such as this. For large asm apps you'll want an actual assembler which takes text files as input much like any other kind of compiler or language translator. These more powerful asm tools (such as MASM) include more powerful macros and methods for structuring applications and dealing with data.

Assembly! Yays!! [smile]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0