flat assembler
Message board for the users of flat assembler.
Index
> DOS > Smallest DOS hello world? ASCII CODE Goto page 1, 2 Next |
Author |
|
edfed 15 Nov 2009, 11:23
yep, it is the smallest DOS hello world possible. juste you don't need ot add 100h to .msg label.
|
|||
15 Nov 2009, 11:23 |
|
LocoDelAssembly 15 Nov 2009, 18:05
Quote:
Yes, although he needs to add "org 100h" after "format binary as 'com'" before removing the addition. |
|||
15 Nov 2009, 18:05 |
|
Dex4u 15 Nov 2009, 18:49
There is a way to make it smaller, by using command line parameters, first leave out
Code: .msg: db 'Hello World!$' instead of Code: mov dx,.msg+100h use Code: mov dx,81h Then when you run the program type hello Hello World!$ <enter> It should than print out 'Hello World!' It should be smaller by a number of bytes |
|||
15 Nov 2009, 18:49 |
|
edfed 17 Nov 2009, 02:13
speaking about command line, i meet a problem with it currentlly.
i test for empty params at 80h, if it is 0, then, there is nothing, then, the filename pointer will be default one. else, it will be set to 81h. i should forget something because this part don't work at all. Code: .nameptr dd .filename .filename db 'c:\file.ext',0 .check: Asm @f @@: push eax ebx mov eax,[.nameptr] cmp byte[80h],0 je @f mov eax,81h @@: mov [.nameptr],eax mov bl,[eax] cmp bl,0 je @f cmp bl,10 je @f cmp bl,13 je @f inc eax jmp @b @@: mov byte[eax],0 mov eax,[.nameptr] mov [.disp+txt.txt],eax pop ebx eax ret [edit] problem solved ... but how? only need a @@: label somewhere. contest only for beginners. |
|||
17 Nov 2009, 02:13 |
|
Alphonso 17 Nov 2009, 11:30
^^ I'm not sure if that includes me or not.
wht36 compiles hello.com to 21 bytes - no command line (works on VHP 32 ). Dex compiles hello.com to 8 bytes and uses command line (might want to use 82h to get rid of the whitespace). Here's mine. The executable hello.com compiles to 2 bytes. Code: org 100h jmp short 82h And the command line to be used with it. Code: hello T]hffX-feP\h!$hldhorh Whlohel50p-m(P-@05N9P5y(P-4y- -moP-9FPU\x( My command line is messy and could be done a lot nicer I think. Better cut & paste. |
|||
17 Nov 2009, 11:30 |
|
edfed 17 Nov 2009, 17:58
DOS is really a stupid systeme.
why? because parameters from the comand line cannot be used directlly to open file using handle. why? because of ' 'char at the begining of the string. isn't it dumb? |
|||
17 Nov 2009, 17:58 |
|
f0dder 17 Nov 2009, 18:15
edfed: just skip one char ahead, space gone, problem solved?
If you think that's the biggest reason for DOS being a stupid system, then oh boy |
|||
17 Nov 2009, 18:15 |
|
Japheth 17 Nov 2009, 18:55
Alphonso wrote:
It works. Very cool program! Congrats! |
|||
17 Nov 2009, 18:55 |
|
Dex4u 17 Nov 2009, 21:21
Cool code Alphonso, you win the smallest Dos 'hello world!' compo .
|
|||
17 Nov 2009, 21:21 |
|
rugxulo 18 Nov 2009, 04:13
f0dder wrote: If you think that's the biggest reason for DOS being a stupid system, then oh boy A poor carpenter blames his tools. (Then again, I whine all the time about Windows, so meh.) And yes, kudos to Alphonso the cheate^H^H^H^H^H^H winner. |
|||
18 Nov 2009, 04:13 |
|
rCX 18 Nov 2009, 05:01
Alphonso. You Win.
|
|||
18 Nov 2009, 05:01 |
|
edfed 18 Nov 2009, 13:32
f0dder wrote:
yep, and better, i copy the parameters somewhere else while cleaning it. and it works. later i will post a sort of rawwrite. but this one will be exclusivelly dos based for file loading, and will be able to copy to any BIOS drive, using a custom CHS/LBA localisation. win98 & dos compatible. |
|||
18 Nov 2009, 13:32 |
|
sinsi 19 Nov 2009, 07:53
Wasn't that how you did code obfuscation? I remember an entire .com program that was a text file - almost 1Kb. Nice!
Quote: Below works under XP |
|||
19 Nov 2009, 07:53 |
|
Alphonso 25 Nov 2009, 12:58
Yeah, I kinda remember something like that from long ago which is where the idea came from and using Dex's clever command line trick. I'm sure the ascii code was done a lot better than my simple implementation too.
|
|||
25 Nov 2009, 12:58 |
|
espartano 12 Dec 2009, 19:28
Alphonso wrote: ^^ I'm not sure if that includes me or not. I'm quit a while programming in assembly but this is the trickiest I ever saw; congratulations. |
|||
12 Dec 2009, 19:28 |
|
Tomasz Grysztar 12 Dec 2009, 20:04
sinsi wrote: Wasn't that how you did code obfuscation? I remember an entire .com program that was a text file - almost 1Kb. Nice! As I recall, the XPack for DOS was made this way. Almost 50 KB executable being a pure ASCII text, even formatted with lines of equal length. |
|||
12 Dec 2009, 20:04 |
|
windwakr 12 Dec 2009, 20:05
Alphonso wrote: ^^ I'm not sure if that includes me or not. I saw a list somewhere of all the instructions you could make with just ASCII, I'll have to find it. I'd like to see if it could be made any smaller. EDIT: Ugh, this is gonna take forever. My backup discs have like 20,000+ files I've archived over the years. I have a habit of downloading and storing everything I see..... And Google searches aren't bringing anything up either. EDIT: Here's the list. I don't know what the "Eb"s and the "Gb"s and stuff mean though. Code: 20 AND Eb, Gb 21 ! AND Ev,Gv 22 " AND Gb, Eb 23 # AND Gv, Ev 24 $ AND AL, Ib 25 % AND eAX, Iv 26 & ES: 27 ' DAA 28 ( SUB Eb, Gb 29 ) SUB Ev, Gv 2A * SUB Gb, Eb 2B + SUB Gv, Ev 2C , SUB AL, Ib 2D - SUB eAX, Iv 2E . CS: 2F / DAS 30 0 XOR Eb, Gb 31 1 XOR Ev, Gv 32 2 XOR Gb, Eb 33 3 XOR Gv, Ev 34 4 XOR AL, Ib 35 5 XOR eAX, Iv 36 6 SS: 37 7 AAA 38 8 CMP Eb, Gb 39 9 CMP Ev, Gv 3A : CMP Gb, Eb 3B ; CMP Gv, Ev 3C < CMP AL, Ib 3D = CMP eAX, Iv 3E > DS: 3F ? AAS 40 @ INC eAX 41 A INC eCX 42 B INC eDX 43 C INC eBX 44 D INC eSP 45 E INC eBP 46 F INC eSI 47 G INC eDI 48 H DEC eAX 49 I DEC eCX 4A J DEC eDX 4B K DEC eBX 4C L DEC eSP 4D M DEC sBP 4E N DEC eSI 4F O DEC eDI 50 P PUSH eAX 51 Q PUSH eCX 52 R PUSH eDC 53 S PUSH eBX 54 T PUSH eSP 55 U PUSH eBP 56 V PUSH eSI 57 W PUSH eDI 58 X POP eAX 59 Y POP eCX 5A Z POP eDX 5B [ POP eBX 5C \ POP eSP 5D ] POP eBP 5E ^ POP eSI 5F _ POP eDI 60 ` PUSHA 61 a POPA 62 b BOUND Gv, Ma 63 c ARPL Ew, Rw 64 d FS: 65 e GS: 66 f OPSIZE: 67 g ADSIZE: 68 h PUSH Iv 69 i IMUL Gv, Ev, Iv 6A j PUSH Ib 6B k IMUL Gv, Ev, Ib 6C l INSB Yb, DX 6D m INSW/D Yv, DX 6E n OUTSB DX, Xb 6F o OUTSW/D DX, Xb 70 p JO Jb 71 q JNO Jb 72 r JB Jb 73 s JNB Jb 74 t JZ Jb 75 u JNZ Jb 76 v JBE Jb 77 w JNBE Jb 78 x JS Jb 79 y JNS Jb 7A z JP Jb 7B { JNP Jb 7C | JL Jb 7D } JNL Jb 7E ~ JLE Jb EDIT: I manually disassembled your code using that list, it worked very good. It comes out with the exact same output through FASM.(I know the org and js are wrong, but it still outputs the same thing) Code: use16 org 80h push sp pop bp push 6666h pop ax sub ax, 6566h push ax pop sp push 2421h push 646ch push 726fh push 5720h push 6f6ch push 6c65h xor ax, 7030h sub ax, 286dh push ax sub ax, 3040h xor ax, 394eh push ax xor ax, 2879h push ax sub ax, 7934h sub ax, 2020h sub ax, 6f6dh push ax sub ax, 4639h push ax push bp pop sp js -87 |
|||
12 Dec 2009, 20:05 |
|
Alphonso 13 Dec 2009, 08:48
windwakr wrote: I have a habit of downloading and storing everything I see..... windwakr wrote: I don't know what the "Eb"s and the "Gb"s and stuff mean though. b=byte v=word or dword G=GP Register I=Immediate E=Everything, could be a register, or word or dword windwakr wrote: I manually disassembled your code using that list Code: format binary as 'txt' org 82h push sp pop bp push 6666h pop ax sub ax,6666h - 100h ;offset to end push ax ;ax =0100h pop sp ;Stack pointer at 0100 push 2421h ;start from the end of code and work back to start, push 646ch ;begining with 'hello world!' push 726fh push 5720h push 6f6ch push 6c65h xor ax,7030h ;7130 sub ax,286dh ;48c3 push ax ;48c3 -> sub ax,3040h ;1883 xor ax,394eh ;21cd push ax ;21cd -> xor ax,2879h ;09b4 push ax ;09b4 -> sub ax,7934h ;9080 sub ax,2020h ;7060 sub ax,6f6dh ;00f3 push ax ;00f3 -> (message pointer) sub ax,4639h ;baba push ax ;baba -> push bp pop sp ;restore original stack pointer js 0ebh ;jump to start of code (sign set from previous subtract) Which as you know basically pushes the following code from end to start (00FF to 00EB) Code: mov dx,message mov ah,09 int 21 ret message db 'Hello World!$' We could just have 'Hello World!$' in the command line and point to it to make the command line smaller rather than pushing it but IMO somehow it would seem less 'magical'. I can't help thinking I read something on comp.lang.asm.x86 along time ago that using ascii had been taken one or two steps further than the simple method above. |
|||
13 Dec 2009, 08:48 |
|
f0dder 13 Dec 2009, 08:51
Alphonso wrote: I can't help thinking I read something on comp.lang.asm.x86 along time ago that using ascii had been taken one or two steps further than the simple method above. _________________ - carpe noctem |
|||
13 Dec 2009, 08:51 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.