The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
March 23, 2023, 08:49:39 AM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  Miscellaneous Forums
| |-+  16 bit DOS Programming
| | |-+  Smallest Executable to write "Hello World" to the screen
« previous next »
Pages: 1 [2] 3 4 Print
Author Topic: Smallest Executable to write "Hello World" to the screen  (Read 36511 times)
dedndave
Member
*****
Posts: 12523


Re: Smallest Executable to write "Hello World" to the screen
« Reply #15 on: October 08, 2010, 01:16:20 AM »

i think you need the 8th byte...
Code:
mov ah,9
mov dx,82h
int 21h
ret
as for relying on DH=0, not sure that is a valid assumption under NTVDM
Logged
xandaz
http://morethangeeks.orgfree.com
Member
*****
Gender: Male
Posts: 543


I'm me again.


Re: Smallest Executable to write "Hello World" to the screen
« Reply #16 on: November 19, 2010, 02:59:26 PM »

   yeah,... well lets not forget that int 21h is a far call. So there's code beneath the instruction... Is it smaller? Don't know....
    bye
Logged

dedndave
Member
*****
Posts: 12523


Re: Smallest Executable to write "Hello World" to the screen
« Reply #17 on: November 19, 2010, 03:52:12 PM »

that is true however, .COM programs are executed similar to a NEAR CALL
the reason a RETN instruction exits is that an INT 20h instruction is at CS:0000 and a 0000 pushed on the stack at program entry
(CS = PSP)
Logged
xandaz
http://morethangeeks.orgfree.com
Member
*****
Gender: Male
Posts: 543


I'm me again.


Re: Smallest Executable to write "Hello World" to the screen
« Reply #18 on: November 20, 2010, 12:44:58 AM »

   ok ... i'm not sure we're understanding each other. If i do this...

Code:
call PrintHelloWorldAndExit

...is everyone going to disregard the code parts in this procedure call?
   No? Yay, ive won!!!
   LMAO :)
Logged

Antariy
Member
*****
Gender: Male
Posts: 1041


Re: Smallest Executable to write "Hello World" to the screen
« Reply #19 on: November 20, 2010, 12:48:31 AM »

Did you talk about 16 programs only, or for Win32, too?
Logged
xandaz
http://morethangeeks.orgfree.com
Member
*****
Gender: Male
Posts: 543


I'm me again.


Re: Smallest Executable to write "Hello World" to the screen
« Reply #20 on: November 20, 2010, 12:51:02 AM »

   i think its DOS only antariy
Logged

Antariy
Member
*****
Gender: Male
Posts: 1041


Re: Smallest Executable to write "Hello World" to the screen
« Reply #21 on: November 20, 2010, 12:53:52 AM »

   i think its DOS only antariy

Well, if it been Win32, then I can suggest a candidate...
Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: Smallest Executable to write "Hello World" to the screen
« Reply #22 on: November 20, 2010, 12:55:31 AM »

It's .com, actually... and it's 8 bytes short:
Code:
.model tiny

.code
org 100h
start:
mov ah, 09h ; write string to STDOUT
mov dx, 82h ; get command line
int 21h ; show it... ;-)
ret
end start

If that looks too complex, try this:
Code:
.model tiny
.code
dq 0C321CD0082BA09B4h
end

Batch file for testing:
Quote
@ECHO OFF
HelloWorldDOS.com Hellooo... world of Masm!$
echo.
echo.
echo.
echo.
pause

Well, if it been Win32, then I can suggest a candidate...

Which one?
Logged

Antariy
Member
*****
Gender: Male
Posts: 1041


Re: Smallest Executable to write "Hello World" to the screen
« Reply #23 on: November 20, 2010, 01:12:12 AM »

Well, if it been Win32, then I can suggest a candidate...

Which one?

You are know   lol
But it not only print HelloWorld  wink
Logged
Antariy
Member
*****
Gender: Male
Posts: 1041


Re: Smallest Executable to write "Hello World" to the screen
« Reply #24 on: November 20, 2010, 01:17:55 AM »

It's .com, actually... and it's 8 bytes short:

I can suggest to put code into command line specification, and at start of the program put the 2 byte jump to the command line  wink

So, you just needed to avoid binary null in the code (this is easy), and enter the code as command line for the 2 bytes program, which just jump to command line.

But I must warn that under Windows this is a bit tricky due to encodings difference. So, this is reliablest from DOS.

Logged
Antariy
Member
*****
Gender: Male
Posts: 1041


Re: Smallest Executable to write "Hello World" to the screen
« Reply #25 on: November 20, 2010, 01:24:00 AM »

Command line is something like (in hex, convert it to dec and enter it with Alt codes):
Code:
B4 09 31 D2 B2 8B CD 21 C3 48 65 6C 6C 6F 2C 57 6F 72 6C 64 24

The program is:
Code:
jmp 82
Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: Smallest Executable to write "Hello World" to the screen
« Reply #26 on: November 20, 2010, 01:30:46 AM »

jmp 82h but...:
Code:
error A2076: jump destination must specify a label
Logged

Antariy
Member
*****
Gender: Male
Posts: 1041


Re: Smallest Executable to write "Hello World" to the screen
« Reply #27 on: November 20, 2010, 01:35:34 AM »

There is a test with 2 byte program which print HelloWorld.
To simplify things with different encodings, is written an .BAT file.
On my system it works.


Alex

* 2byteHelloWorld.zip (0.25 KB - downloaded 417 times.)
Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: Smallest Executable to write "Hello World" to the screen
« Reply #28 on: November 20, 2010, 01:45:18 AM »

Thanks, Alex - works like a charm on Win XP SP2...

Code:
.model tiny
.code
dw 080EBh
end
Logged

Antariy
Member
*****
Gender: Male
Posts: 1041


Re: Smallest Executable to write "Hello World" to the screen
« Reply #29 on: November 20, 2010, 01:46:52 AM »

Update in .BAT file - pause>nul

* 2byteHelloWorld.zip (0.26 KB - downloaded 385 times.)
Logged
Pages: 1 [2] 3 4 Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!