Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Demobomb for Windows

216 views
Skip to first unread message

Charles A. Crayne

unread,
Feb 4, 2007, 7:44:03 PM2/4/07
to
I decided to play around with generating executables for multiple
platforms from the same Fasm source file, but although I have
successfully tested a Windows version of demobomb using WINE, I would
appreciate it if some kind soul would test it for me on an actual
Windows system.

http://www.pacificsites.com/~ccrayne/clax86/demobomb1.exe

No need to play with it, if you don't want to. As long as it issues a
prompt; accepts an input; and shuts down cleanly, then all of the Window's
specific code is working.

-- Chuck

Benjamin David Lunt

unread,
Feb 4, 2007, 9:04:29 PM2/4/07
to

"Charles A. Crayne" <ccr...@crayne.org> wrote in message
news:20070204164...@heimdall.crayne.org...

Works here on a WinXP SP2 box in a full screen DOS window.
Well at least the prompt and the KABOOM!!!.

Ben


Charles A. Crayne

unread,
Feb 4, 2007, 10:48:12 PM2/4/07
to
On Mon, 05 Feb 2007 02:04:29 GMT
"Benjamin David Lunt" <zf...@frontiernet.net> wrote:

:Works here on a WinXP SP2 box in a full screen DOS window.


:Well at least the prompt and the KABOOM!!!.

That is enough to give me a strong feeling of confidence that the rest of
the program will work as well. Thank you.

-- Chuck

//\\o//\\annabee <Free"

unread,
Feb 5, 2007, 2:12:38 AM2/5/07
to
På Mon, 05 Feb 2007 01:44:03 +0100, skrev Charles A. Crayne
<ccr...@crayne.org>:

It works fine, even after disassembly. And the code is much nicer to look
at in the RosAsm editor :)


>
> -- Chuck

Dunny

unread,
Feb 5, 2007, 7:12:51 AM2/5/07
to
In news:20070204164...@heimdall.crayne.org,
Charles A. Crayne <ccr...@crayne.org> typed:

It's not working *quite* as you'd hoped.

Launching from Explorer, it accepts and input and then closes the window.
However, using the download manager in Firefox ("Download Statusbar" add-on)
to download the file, and then launching the file from the status bar...
When the app closes it takes the current Firefox tab with it. Fairly certain
that's not meant to happen.

D.


Jim Carlock

unread,
Feb 5, 2007, 9:15:27 AM2/5/07
to
"Dunny" <paul....@ntlworld.com> commented...
: It's not working *quite* as you'd hoped.

:
: Launching from Explorer, it accepts and input and then closes
: the window.

Launching from a cmd.exe prompt works as expected. Launching
from Windows, it would be more convenient to keep the cmd.exe
prompt open displaying the "KABOOM!!!". I'm guessing that the
easy way around that involves a second input prompt. A better
way, although I'm not quite sure how to get there, would be to
launch a cmd.exe prompt via the following line...

%systemroot%\system32\cmd.exe /K demobomb1.exe

The /K switch keeps the cmd prompt open when the app inside it
closes. There might be away to configure the cmd.exe to stay
open. Someone else needs to help out in that regards.

: However, using the download manager in Firefox ("Download


: Statusbar" add-on) to download the file, and then launching the
: file from the status bar... When the app closes it takes the current
: Firefox tab with it. Fairly certain that's not meant to happen.

That sounds like a FireFox issue/bug. The FireFox groups will
probably tell you that that is by design and the way around it
involves setting one of the about:config options to open all new
downloads in a new tab. Just a guess.

--
Jim Carlock
Post replies to the group.


Herbert Kleebauer

unread,
Feb 5, 2007, 12:14:27 PM2/5/07
to

"Charles A. Crayne" wrote:
>
> I decided to play around with generating executables for multiple
> platforms from the same Fasm source file, but although I have
> successfully tested a Windows version of demobomb using WINE, I would
> appreciate it if some kind soul would test it for me on an actual
> Windows system.
>
> http://www.pacificsites.com/~ccrayne/clax86/demobomb1.exe

Wouldn't call this a multi-platform program. Here a binary
which can be executed in Linux and Windows (at least on my
XP version):

7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 02 00 03 00
01 00 00 00 e8 80 04 08 a8 00 00 00 00 00 00 00 00 00 00 00
34 00 20 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 b4 09 ba 67 01 cd 21 4a fe
c4 cd 21 fe cc 81 3e 68 01 34 32 ba 8f 01 74 03 ba 9d 01 cd
21 c3 03 0d 0a 57 68 61 74 20 69 73 20 74 68 65 20 61 6e 73
77 65 72 20 74 6f 20 61 6c 6c 20 71 75 65 73 74 69 6f 6e 73
3f 20 24 0d 0a 56 65 72 79 20 67 6f 6f 64 0a 0a 24 0d 0a 4b
61 62 6f 6f 6d 0a 0a 24 01 00 00 00 00 00 00 00 00 80 04 08
00 80 04 08 4b 01 00 00 4b 01 00 00 05 00 00 00 00 10 00 00
01 00 00 00 4c 01 00 00 4c 91 04 08 4c 91 04 08 00 00 00 00
04 00 00 00 06 00 00 00 00 10 00 00 bb 01 00 00 00 b9 68 80
04 08 ba 26 00 00 00 b8 04 00 00 00 cd 80 bb 00 00 00 00 b9
4c 91 04 08 ba 02 00 00 00 b8 03 00 00 00 cd 80 66 81 3d 4c
91 04 08 34 32 bb 01 00 00 00 b9 90 80 04 08 ba 0c 00 00 00
74 0a b9 9e 80 04 08 ba 09 00 00 00 b8 04 00 00 00 cd 80 bb
00 00 00 00 b8 01 00 00 00 cd 80 00

Jim Carlock

unread,
Feb 5, 2007, 3:18:57 PM2/5/07
to
"Herbert Kleebauer" wrote:
: Wouldn't call this a multi-platform program. Here a binary

: which can be executed in Linux and Windows (at least on
: my XP version):

<snip>...</snip>

I through that into a text editor and prefixed each line with "db ".
I then started up grdb and typed in the following...

a 100

and pasted the following glob of lines into it. GRDB handled it
quite well. And so I saved the file, 0x246 bytes worth, and added
the 100 byte header for the .com file to get a filesize of 0x346.

Not quite sure if I'm going about this in the right way.

w @100 demobomb.com 346

It wrote 844 (0x346) bytes to the file.

db 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 02 00 03 00
db 01 00 00 00 e8 80 04 08 a8 00 00 00 00 00 00 00 00 00 00 00
db 34 00 20 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
db 00 00 00 00 00 00 00 00 00 00 00 b4 09 ba 67 01 cd 21 4a fe
db c4 cd 21 fe cc 81 3e 68 01 34 32 ba 8f 01 74 03 ba 9d 01 cd
db 21 c3 03 0d 0a 57 68 61 74 20 69 73 20 74 68 65 20 61 6e 73
db 77 65 72 20 74 6f 20 61 6c 6c 20 71 75 65 73 74 69 6f 6e 73
db 3f 20 24 0d 0a 56 65 72 79 20 67 6f 6f 64 0a 0a 24 0d 0a 4b
db 61 62 6f 6f 6d 0a 0a 24 01 00 00 00 00 00 00 00 00 80 04 08
db 00 80 04 08 4b 01 00 00 4b 01 00 00 05 00 00 00 00 10 00 00
db 01 00 00 00 4c 01 00 00 4c 91 04 08 4c 91 04 08 00 00 00 00
db 04 00 00 00 06 00 00 00 00 10 00 00 bb 01 00 00 00 b9 68 80
db 04 08 ba 26 00 00 00 b8 04 00 00 00 cd 80 bb 00 00 00 00 b9
db 4c 91 04 08 ba 02 00 00 00 b8 03 00 00 00 cd 80 66 81 3d 4c
db 91 04 08 34 32 bb 01 00 00 00 b9 90 80 04 08 ba 0c 00 00 00
db 74 0a b9 9e 80 04 08 ba 09 00 00 00 b8 04 00 00 00 cd 80 bb
db 00 00 00 00 b8 01 00 00 00 cd 80 00

There another way to get the byte codes into the app?

Frank Kotler

unread,
Feb 5, 2007, 4:27:51 PM2/5/07
to

Shit. Now I've *gotta* get that damn "dmp2bin" working! Okay, a little
sharper today, and working in Linux... There we go! Very nice, Herbert!
Now *that's* what I call portable! Works in dosemu, too! I got the
answer wrong, I thought it was "assembly language" (the fact that
"extra" shows up on the command-line is a "clue" to the length of the
"answer" could be considered a "bug" - possible to flush input, but it's
a PITA). Disassembling it is kind of a "challenge", due to the mixed
16-32-bit code, but it isn't hard to find the relevant test. Very nice
example of the genre!

Best,
Frank

Herbert Kleebauer

unread,
Feb 5, 2007, 4:36:28 PM2/5/07
to
Jim Carlock wrote:

> Not quite sure if I'm going about this in the right way.

I'm not sure what you have done. The binary file has 332 bytes.
I posted the hex dump of this file (16 lines with 20 bytes and
the last line with 12 bytes = 332 bytes). Use any hex2bin
converter to convert the hex dump back to the binary 332 byte
file.

The following batch will generate such a simple hex2bin
DOS program ( usage: h2b.com <infile >outfile )

@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>h2b.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>h2b.com
echo ~~=}p~sA@xZJXy?w`L@KH}q@Fs?V@X_Mqo{Ox{fBkCv@KjoK{_K?Xq`tve>>h2b.com
echo {SVkTRw\v1_?G{YaCwFj@{YE?o?s@W?@zA?@xA@YyMr`LR?ssY?AzA?FxA>>h2b.com
echo @ZyMw`LbLK?s??`?qqdTLqnDLqIC0x>>h2b.com

The source code:

@=$100

move.w #-1,r4
_20: move.b #$3f,m0
eor.w r3,r3
move.w #1,r2
move.w #buf1,r1
trap #$21
bcs.b _200

or.w r0,r0
beq.b _100

move.b buf1,r0
cmp.b #'0',r0
blo.b _20
cmp.b #'9',r0
bhi.b _30
sub.b #'0',r0
br.b _50
_30: or.b #$20,r0
cmp.b #'a',r0
blo.b _20
cmp.b #'f',r0
bhi.b _20
sub.b #'a'-10,r0
_50: neg.w r4
bmi.b _60
lsl.b #4,r0
move.b r0,buf2
br.b _20
_60: add.b r0,buf2

move.b #$40,m0
move.w #1,r3
move.w #1,r2
move.w #buf2,r1
trap #$21
bcc.b _20

_200: move.b #$40,m0
move.w #2,r3
move.w #textlang,r2
move.w #text,r1
trap #$21

_100: move.w #$4c00,r0
trap #$21

buf1: dc.b 0
buf2: dc.b 0
text: dc.b 'error',13,10
textlang=@-text

Herbert Kleebauer

unread,
Feb 5, 2007, 4:47:45 PM2/5/07
to

Frank Kotler wrote:

> a PITA). Disassembling it is kind of a "challenge", due to the mixed
> 16-32-bit code, but it isn't hard to find the relevant test. Very nice
> example of the genre!

Here the source:

;===========================================================================

seg32
@=$08048000
code_offset=@@
code_addr:

;--------------------------- ELF header -----------------------------------

00000000: 08048000: 464c457f 00010101
00000008: 08048008: 00000000 00000000
00000010: 08048010: 00030002 00000001
00000018: 08048018: 080480e8 000000a8
00000020: 08048020: 00000000 00000000
00000028: 08048028: 00200034 00000002
00000030: 08048030: 00000000 dc.l $464c457f,$00010101,0,0,$00030002,1,main,@3,0,0,$00200034,2,0

@1=@
@2=@@
@=$100+@@
seg16
00000034: 00000134: 00 00 00 00 00 00
0000003a: 0000013a: 00 00 00 00 00 00
00000040: 00000140: 00 00 00 00 00 00
00000046: 00000146: 00 blk.b 19,0
00000047: 00000147: b4 09 move.b #9,m0
00000049: 00000149: ba 0167 move.w #text1,r1
0000004c: 0000014c: cd 21 trap #$21
0000004e: 0000014e: 4a dec.w r1
0000004f: 0000014f: fe c4 inc.b m0
00000051: 00000151: cd 21 trap #$21
00000053: 00000153: fe cc dec.b m0
00000055: 00000155: 81 3e 0168 3234 cmp.w #'24',text1+1
0000005b: 0000015b: ba 018f move.w #text2,r1
0000005e: 0000015e: 74 03 beq.b _10
00000060: 00000160: ba 019d move.w #text3,r1
00000063: 00000163: cd 21 _10: trap #$21
00000065: 00000165: c3 rts.w

00000066: 00000166: 03 dc.b 3
text1u=@1+@@-@2+1
00000067: 00000167: 0d 0a 57 68 61 74
0000006d: 0000016d: 20 69 73 20 74 68
00000073: 00000173: 65 20 61 6e 73 77
00000079: 00000179: 65 72 20 74 6f 20
0000007f: 0000017f: 61 6c 6c 20 71 75
00000085: 00000185: 65 73 74 69 6f 6e
0000008b: 0000018b: 73 3f 20 24 text1: dc.b 13,10,"What is the answer to all questions? $"
text1l=@-text1-2
text2u=@1+@@-@2+1
0000008f: 0000018f: 0d 0a 56 65 72 79
00000095: 00000195: 20 67 6f 6f 64 0a
0000009b: 0000019b: 0a 24 text2: dc.b 13,10,"Very good",10,10,"$"
text2l=@-text2-2
text3u=@1+@@-@2+1
0000009d: 0000019d: 0d 0a 4b 61 62 6f
000000a3: 000001a3: 6f 6d 0a 0a 24 text3: dc.b 13,10,"Kaboom",10,10,"$"
text3l=@-text3-2

@3=@@
@=@1+@@-@2
seg32
000000a8: 080480a8: 00000001 00000000
000000b0: 080480b0: 08048000 08048000
000000b8: 080480b8: 0000014b 0000014b
000000c0: 080480c0: 00000005 00001000 dc.l 1,code_offset,code_addr,code_addr,code_filez,code_memsz,5,4096
000000c8: 080480c8: 00000001 0000014c
000000d0: 080480d0: 0804914c 0804914c
000000d8: 080480d8: 00000000 00000004
000000e0: 080480e0: 00000006 00001000 dc.l 1,data_offset,data_addr,data_addr,data_filez,data_memsz,6,4096

;--------------------------- code ------------------------------------------

main:

000000e8: 080480e8: bb 00000001 move.l #1,r3 ; stdout
000000ed: 080480ed: b9 08048068 move.l #text1u,r2
000000f2: 080480f2: ba 00000026 move.l #text1l,r1 ; length
000000f7: 080480f7: b8 00000004 move.l #4,r0 ; write
000000fc: 080480fc: cd 80 trap #$80

000000fe: 080480fe: bb 00000000 move.l #0,r3 ; stdin
00000103: 08048103: b9 0804914c move.l #buf,r2
00000108: 08048108: ba 00000002 move.l #2,r1 ; 1 byte
0000010d: 0804810d: b8 00000003 move.l #3,r0 ; read
00000112: 08048112: cd 80 trap #$80

00000114: 08048114: 66 81 3d 0804914c
0000011b: 0804811b: 3234 cmp.w #'24',buf
0000011d: 0804811d: bb 00000001 move.l #1,r3 ; stdout
00000122: 08048122: b9 08048090 move.l #text2u,r2
00000127: 08048127: ba 0000000c move.l #text2l,r1 ; length
0000012c: 0804812c: 74 0a beq.b _10
0000012e: 0804812e: b9 0804809e move.l #text3u,r2
00000133: 08048133: ba 00000009 move.l #text3l,r1 ; length
00000138: 08048138: b8 00000004 _10: move.l #4,r0 ; write
0000013d: 0804813d: cd 80 trap #$80

0000013f: 0804813f: bb 00000000 move.l #0,r3 ; return code
00000144: 08048144: b8 00000001 move.l #1,r0 ; exit
00000149: 08048149: cd 80 trap #$80


;--------------------------- constant data ---------------------------------


;---------------------------------------------------------------------------

code_filez=@@-code_offset
code_memsz= @-code_addr
0000014b: 0804814b: 00 even 4
@=(@+4095)/4096*4096+(@@\4096)
data_offset=@@
data_addr:

;--------------------------- initialized data ------------------------------

;var1: dc.l 1
;var2: dc.l 11

;--------------------------- uninitialized data ----------------------------

buf: blk.b 4

;---------------------------------------------------------------------------

data_filez=@@-data_offset
data_memsz= @-data_addr

;===========================================================================


code_offset.... 00000000 code_addr...... 08048000 text1u......... 08048068
text1.......... 00000167 text1l......... 00000026 text2u......... 08048090
text2.......... 0000018f text2l......... 0000000c text3u......... 0804809e
text3.......... 0000019d text3l......... 00000009 main........... 080480e8
code_filez..... 0000014b code_memsz..... 0000014b data_offset.... 0000014c
data_addr...... 0804914c buf............ 0804914c data_filez..... 00000000
data_memsz..... 00000004

Evenbit

unread,
Feb 5, 2007, 5:03:29 PM2/5/07
to
On Feb 5, 4:36 pm, Herbert Kleebauer <k...@unibwm.de> wrote:
> Jim Carlock wrote:
> > Not quite sure if I'm going about this in the right way.
>
> I'm not sure what you have done. The binary file has 332 bytes.
> I posted the hex dump of this file (16 lines with 20 bytes and
> the last line with 12 bytes = 332 bytes). Use any hex2bin
> converter to convert the hex dump back to the binary 332 byte
> file.
>
> The following batch will generate such a simple hex2bin
> DOS program ( usage: h2b.com <infile >outfile )

How is Jim going to learn anything if *you* keep doing his "homework"
for him???

;-)

Nathan.

//\\o//\\annabee <Free"

unread,
Feb 5, 2007, 5:04:58 PM2/5/07
to
På Mon, 05 Feb 2007 22:47:45 +0100, skrev Herbert Kleebauer
<kl...@unibwm.de>:

This may seem like a strange question.
But why not allow windela to do this:

echo DemoBomb.txt|windela
pause

since *.mac files are textfiles anyway?

another thing. Is | and > equivalent?

vid...@gmail.com

unread,
Feb 5, 2007, 5:38:48 PM2/5/07
to
just a general programming note: ReadFile, even when from console, can
return 0 bytes readen. So your "number of bytes readen minus 1" is
not really a best idea. In this particular example it doesn't cause
any bug however.

Herbert Kleebauer

unread,
Feb 5, 2007, 5:47:16 PM2/5/07
to
"//\\\\o//\\\\annabee

> På Mon, 05 Feb 2007 22:47:45 +0100, skrev Herbert Kleebauer
> <kl...@unibwm.de>:
>
> This may seem like a strange question.
> But why not allow windela to do this:
>
> echo DemoBomb.txt|windela

You have to pipe the filename only (without the extension
which must be .mac):

echo DemoBomb|windela

But DemoBomb.mac must be a valid assembler source file and
not a hex dump of a binary.

> another thing. Is | and > equivalent?

| is the pipe symbol which means to forward stdout of the
left side program to stdin of the right side program.
> redirects stdout to a file or device.

type hex.txt | hex2bin.com > binary.com

"type" writes the file content of hex.txt to stdout which
is forwarded to stdin of "hex2bin". The binary written to stdout
by hex2bin is written into the file binary.com

//\\o//\\annabee <Free"

unread,
Feb 5, 2007, 5:57:17 PM2/5/07
to
På Mon, 05 Feb 2007 23:38:48 +0100, skrev vid...@gmail.com
<vid...@gmail.com>:

imo, thats one of the diffrences between asm and hll. Asmers doesnt need
to check for bugs that cant exists. On the other hand, this way of
thinking does not scale well, when making code for "library" reuse.

And maybe that the whole diffrence.

//\\o//\\annabee <Free"

unread,
Feb 5, 2007, 6:11:28 PM2/5/07
to
På Mon, 05 Feb 2007 23:47:16 +0100, skrev Herbert Kleebauer
<kl...@unibwm.de>:

> "//\\\\o//\\\\annabee
>> På Mon, 05 Feb 2007 22:47:45 +0100, skrev Herbert Kleebauer
>> <kl...@unibwm.de>:
>>
>> This may seem like a strange question.
>> But why not allow windela to do this:
>>
>> echo DemoBomb.txt|windela
>
> You have to pipe the filename only (without the extension
> which must be .mac):
>
> echo DemoBomb|windela
>
> But DemoBomb.mac must be a valid assembler source file and
> not a hex dump of a binary.

echo DemoBomb.txt|windela
pause

This works, as long as DemoBomb.mac exists.
This is not a critisism or anything. Just an observation.

>> another thing. Is | and > equivalent?
>
> | is the pipe symbol which means to forward stdout of the
> left side program to stdin of the right side program.
>> redirects stdout to a file or device.
>
> type hex.txt | hex2bin.com > binary.com
>
> "type" writes the file content of hex.txt to stdout which
> is forwarded to stdin of "hex2bin". The binary written to stdout
> by hex2bin is written into the file binary.com

ok.


Jim Carlock

unread,
Feb 5, 2007, 6:29:15 PM2/5/07
to
"Herbert Kleebauer" <kl...@unibwm.de> wrote:
: I'm not sure what you have done. The binary file has 332 bytes.

: I posted the hex dump of this file (16 lines with 20 bytes and
: the last line with 12 bytes = 332 bytes).

Good catch. I was adding 100 bytes for the 100 byte offset when
I didn't need to (0x14C == 332).

Even assembling at byte 0, the environment automatically places
the code at 0x100 when it runs it.

So the previous commands I changed, "a 100" to "a 0" and that
worked fine.

Then I changed the write line inside GRDB from,

w @100 demobomb.com 24C

to:

w @0 demobomb.com 14C

and that works well.

Thanks for catching that and pointing it out, Herbert.

Frank Kotler

unread,
Feb 5, 2007, 6:30:45 PM2/5/07
to
Jim Carlock wrote:
...

> and added
> the 100 byte header for the .com file

You shouldn't need to add the 100*h* byte header. It doesn't appear in
the .com file. The required "org 100h" should be encoded in "the bytes".

[snip]
Looks pretty good. The .com version executes the ELF header first, so
don't expect the disassembly to "make sense".

...


> There another way to get the byte codes into the app?

Herbert's posted a "better" one, probably. As an alternative to the
"dump" solution, we could post "obfuscated source" in a form like...

db 0B4h, 009h, ...

Which Nasm would assemble... In the presently posted format... Here's my
dos "undump" solution which is *not* working in dosemu. The damn 9s are
converted to spaces! I haven't tried Herbert's code in dosemu - possible
dosemu gets int 21h/40h right, but screws up on int 21h/6 and /2. I'm
not hopeful - I think I'm going to have to write to a "real file" to
have the damn TABs not expanded! Easy enough to do, but not a high
priority, and I was looking for something super-short to "kick ass" on
Nathan's "Hella" version. This isn't it. There's a shorter way to
convert hex ascii to a number - I can't remember it, and haven't taken
the time to "work it out". This is not well tested. The intended input
is "uppercase hex", but I *think* it'll handle lowercase too. Invalid
characters will produce invalid results. Might be some use, if it works
in "real dos" or "as emulated by XP". No use to me! (is Public Bitbucket
a license? :)

Best,
Frank

; nasm -f bin -o undump.com undump.asm
;
; doesn't even need "org 100h" - position independent code!

mov ah, 6
top:
mov cl, 0
getc:
mov dl, 0FFh
int 21h
jz exit

sub al, '0'
jc top
cmp al, 10
jc skip
sub al, 7
and al, 0Fh
skip:
cmp cl, 0
jnz second
mov bl, al
shl bl, 4
inc cl
jmp short getc
second:
or bl, al
mov dl, bl
int 21h
jmp short top
exit:
ret


Frank Kotler

unread,
Feb 5, 2007, 7:08:11 PM2/5/07
to
vid...@gmail.com wrote:
> just a general programming note: ReadFile, even when from console, can
> return 0 bytes readen. So your "number of bytes readen minus 1" is
> not really a best idea.

Good catch!

> In this particular example it doesn't cause
> any bug however.

No, but the "original homework assignment", in some versions, required
that a "solution" file to be redirected into the "bomb" be handed in. If
an existing, but zero-length file were redirected... I guess it would
just go KABOOM...

Best,
Frank

Jim Carlock

unread,
Feb 5, 2007, 8:17:57 PM2/5/07
to
"//\\o//\\annabee <Free" " posted...
: type hex.txt | hex2bin.com > binary.com
:
: | is the pipe symbol which means to forward stdout of the

: left side program to stdin of the right side program.
: redirects stdout to a file or device.

You can't have two redirects on a line...

Redirect creates or appends to a file or device.

For instance, if you had a file that Herbert gave you named,
h2b.bat which contained...

@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>h2b.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>h2b.com
echo ~~=}p~sA@xZJXy?w`L@KH}q@Fs?V@X_Mqo{Ox{fBkCv@KjoK{_K?Xq`tve>>h2b.com
echo {SVkTRw\v1_?G{YaCwFj@{YE?o?s@W?@zA?@xA@YyMr`LR?ssY?AzA?FxA>>h2b.com
echo @ZyMw`LbLK?s??`?qqdTLqnDLqIC0x>>h2b.com

and then you typed the following into the command prompt...

type h2b.bat > garbage.txt > garbage.asc

only the garbage.asc file gets created. (Tested on WinXPSP2).

The pipe command does not create a file, it pipes the content
from one app to another app running the first app first, piping
and buffering STDOUT, then starts up the app getting piped
to and feeds the buffered content into the second app as input.

I hope I'm correct in my description of how that works. I've
not used pipes all that much. And since it's been around since
early DOS and UNIX days, and I don't see both apps running
concurrently from the command line, thus the buffering. I could
be wrong.

Does it pipe a line at a time or a session/file at a time? I'll guess
it's a file/session/stream at a time. Perhaps way back when,
when memory was limited to 64KB it might have piped a
character (or line) at a time?

Herbert Kleebauer

unread,
Feb 6, 2007, 3:44:56 AM2/6/07
to
Frank Kotler wrote:

> Which Nasm would assemble... In the presently posted format... Here's my
> dos "undump" solution which is *not* working in dosemu. The damn 9s are
> converted to spaces! I haven't tried Herbert's code in dosemu - possible
> dosemu gets int 21h/40h right, but screws up on int 21h/6 and /2.

Have tried 21h/2 in XP and it also replaces TAB by spaces. I think
Laura once posted an article about this here (if I remember correctly,
21h/2 even update the cursor position on the screen when the output
is redirected to a file).

Frank Kotler

unread,
Feb 6, 2007, 5:06:40 AM2/6/07
to

Bingo! Int 21h/40h does the right thing. "It's times like these I wish
I'd listened to what Laura told me!" Thanks, Herbert! That was driving
me crazy. Now that I've got something that works, I can concentrate on
making it small - if I bother. Not really that interested in working in
dos, these days, but it's good to exercise my memory, I guess. It needs it!

Best,
Frank

0 new messages