Smallest Executable to write "Hello World" to the screen

Started by Prince Wotoshi, November 01, 2008, 08:09:19 PM

Previous topic - Next topic

dedndave

i think you need the 8th byte...
mov ah,9
mov dx,82h
int 21h
ret

as for relying on DH=0, not sure that is a valid assumption under NTVDM

xandaz

   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

dedndave

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)

xandaz

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

call PrintHelloWorldAndExit

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

Antariy

Did you talk about 16 programs only, or for Win32, too?

xandaz


Antariy

Quote from: xandaz on November 20, 2010, 12:51:02 AM
   i think its DOS only antariy

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

jj2007

It's .com, actually... and it's 8 bytes short:
.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:
.model tiny
.code
dq 0C321CD0082BA09B4h
end


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

Quote from: Antariy on November 20, 2010, 12:53:52 AM
Well, if it been Win32, then I can suggest a candidate...

Which one?

Antariy

Quote from: jj2007 on November 20, 2010, 12:55:31 AM
Quote from: Antariy on November 20, 2010, 12:53:52 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

Antariy

Quote from: jj2007 on November 20, 2010, 12:55:31 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.


Antariy

Command line is something like (in hex, convert it to dec and enter it with Alt codes):

B4 09 31 D2 B2 8B CD 21 C3 48 65 6C 6C 6F 2C 57 6F 72 6C 64 24


The program is:

jmp 82


jj2007

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

Antariy

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

jj2007

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

.model tiny
.code
dw 080EBh
end


Antariy