flat assembler
Message board for the users of flat assembler.

Index > Main > Interesting task

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 28 Dec 2004, 12:21
Successfully compiled a 16-byte-program that greets:"Hello W!" --- and crashes Very Happy
Maybe we should agree on the fact that W means World Wink like in W(orld)W(ar) II or sth Razz

With that crashing I was able to accomplish this mission in Estonian:
it greets: "Tere,Maa" 8 letters, but there's a slight change - "Tere" means "Hello" or "Hi", but "Maa" == "Earth" not World Sad

But that's a big relief for aliens wanting to learn Estonian Cool they'd take that .com file and run it on some 386 Twisted Evil but what the heck - the file takes 32KB anyway on a FAT32 HDD Razz
Post 28 Dec 2004, 12:21
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach 28 Dec 2004, 12:36
what about mov:es to es=0xb800? but maybe it takes two bytes for each mov?
Post 28 Dec 2004, 12:36
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 28 Dec 2004, 15:11
ok, Matrix we cry for help Very Happy
I know you can DO it (I mean optimize it Wink )

_________________
My updated idol Very Happy http://www.agner.org/optimize/
Post 28 Dec 2004, 15:11
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach 28 Dec 2004, 15:56
Code:
org 256
push 0xb800
pop es
mov [es], 'H'
mov [es+2], 'e'
; etc? is it to big? as far as i can remember a mov is 1 byte..
    

[edit] or not, as the char itself takes one byte and the address 1.. Sad
Post 28 Dec 2004, 15:56
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 28 Dec 2004, 20:58
Quote:

mov [es+2], 'e'
; etc? is it to big? as far as i can remember a mov is 1 byte..

surely not this case "mov" itself takes one byte, one byte for arguments, one byte for diplsacement, one for 'e' constant.
Post 28 Dec 2004, 20:58
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 29 Dec 2004, 18:42
it's a funy Smile
some small - 21 bytes:
Code:
org 256
  mov dx,mess; 3 bytes
  mov ah,9      ; 2 bytes
  int 0x21        ; 2 bytes
  ret                ; 1 bytes
mess db "Hello World!$" ; 13 bytes    

23 bytes
Code:
org 256
  mov si,mess
@@:
  lodsb
  int 0x29
  cmp al,0x21
  jne @r
  ret
mess db "Hello World!"    

program name must be hello - 22 bytes
Code:
org 256
  mov ah,2
  mov dx,??? ;dh=row; dl=column
  int 0x10
  mov dx,mess
  mov ah,9
  int 0x21
  ret
mess db 'World!$'    

16 bytes
Code:
;if computer name is hello world!
org 256
  mov ax,0x5e00
  int 0x21
  mov si,dx
  mov cx,12; computer name - max 15 bytes
@@:
  lodsb
  int 0x29
  loop @r
  ret    

i don't check if the programe downloaded the text "Hello World!" from somewhere Wink
Post 29 Dec 2004, 18:42
View user's profile Send private message Reply with quote
jorom



Joined: 12 Dec 2004
Posts: 8
Location: Russia
jorom 01 Jan 2005, 23:11
The professor has agreed to accept this version:

hello.com:
Code:
  mov ah,0Ah
  int 21h
    

4 bytes

in command string: hello.com < text.txt

There is the line "Hello World!" in the file text.txt (12 bytes)

text.txt + hello.com = 16 bytes Smile

The version is odd, but I've not invented another Smile
Post 01 Jan 2005, 23:11
View user's profile Send private message Reply with quote
fasm9



Joined: 19 Jun 2003
Posts: 439
fasm9 02 Jan 2005, 01:28
Code:
echo hello world!    


--
Post 02 Jan 2005, 01:28
View user's profile Send private message Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 08 Feb 2005, 19:59
AFAIK 21 bytes is the smallest you can get in DOS... if it weren't for that "$" you could do 20... IMHO DOS should have had a PRINT string with null-terminator option... then it would be 20, because (hopefully) we can assume that after the program code will be all nulls.
Post 08 Feb 2005, 19:59
View user's profile Send private message AIM Address Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 11 Feb 2005, 08:28
thanks mike.dld i've just found out that you don't have to use GetCommandLine for getting the command line, but you can use 82h / 0x82 / $82 instead Very Happy thanks!!
Post 11 Feb 2005, 08:28
View user's profile Send private message Reply with quote
fasm9



Joined: 19 Jun 2003
Posts: 439
fasm9 20 Feb 2005, 02:45
polygon7 wrote:
fasm9 wrote:
hello.exe written in c(dev-cpp 4.9.9.1) with upx is 3kb, which is less than 4kb.

so what's different 12byte and 4kb??


For simple "hello world" 4kb is too large.

With MSVC 6.0 you can make it in 1kb (without exe compression,
src in attachement). I think that is possible to make 1kb "Hello World"
in Dev-cpp too. For compresion such small files best compressor is FSG 2.0


http://fabrice.bellard.free.fr/otcc/
Quote:

You can use OTCCELF by typing:

otccelf prog.c prog
chmod 755 prog

'prog' is the name of the ELF file you want to generate.

Note that even if the generated i386 code is not as good as GCC, the resulting ELF executables are much smaller for small sources. Try this program:

#include <stdio.h>

main()
{
printf("Hello World\n");
return 0;
}

Results:
Compiler Executable size (in bytes)
OTCCELF 424
GCC (stripped) 2448
Post 20 Feb 2005, 02:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.