Very nice Vortex, I've never managed to get Win9x running without a section. I'll take a look at it, later on, tnx.
Vortex, very nice.
You can reduce the NE tweaking a little more. For eample, you can short more the DOS stub and cut out some strings.
You can reduce the NE tweaking a little more. For eample, you can short more the DOS stub and cut out some strings.
The second one reduced to 400 bytes. :)
hmm, why isn't the NE format used more like this? :) hmm, nice, i gotta look more into NE!
i know NE is ran from emulation, but it seems to support APIs, but it seems they're not 32bit, or am i wrong? what's the difference?
hmm, few more questions, what's INITTASK/WAITEVENT/INITAPP, i've never seen such apis :)
are you nice enough to provide some info/examples? :D
i know NE is ran from emulation, but it seems to support APIs, but it seems they're not 32bit, or am i wrong? what's the difference?
hmm, few more questions, what's INITTASK/WAITEVENT/INITAPP, i've never seen such apis :)
are you nice enough to provide some info/examples? :D
NE works with 32-bit Windows.... very interesting. I never thought of that. Smart.
i found a version of Turbo Pascal for Windows, and the outputted executables were NE, but i didn't know you could trim down a NE that much. interesting stuff
INITTASK sets up the local heap, and initializes DLLs.
AX=0 for failure, 1 for success
CX=lower bound of stack
DX=display flags (for SHOWWINDOW)
BX=offset of command line (0 terminated!)
SI=other instance
DI=current instance (set equal to (DS&0xfffc)|2)
ES=Current PSP
I have no idea about WAITEVENT, it takes one parameter which seems to always be 0, and it most applications call this right before INITAPP.
INITAPP creates a message queue and initializes a few things. It should be called before any other UI function.
The file Vortex posted looks quite sloppy and unoptimized, though.
First off, DS already contains the selector of the automatic data segment at startup, no need to set it again. Jnz $+02h / jmp $+29h is quite bad... And why are you saving everything returned by INITTASK when you're only using DI anyway? xor ax,ax / push ax should be changed to push 0. mov ax,[16h] should be changed to push di. The rest is so bad, I don't even know where to start... It looks like it was written in C! :eek:
Let's see if you won't save a number of bytes fixing this comparable to the number of bytes you saved by reducing header size.
AX=0 for failure, 1 for success
CX=lower bound of stack
DX=display flags (for SHOWWINDOW)
BX=offset of command line (0 terminated!)
SI=other instance
DI=current instance (set equal to (DS&0xfffc)|2)
ES=Current PSP
I have no idea about WAITEVENT, it takes one parameter which seems to always be 0, and it most applications call this right before INITAPP.
INITAPP creates a message queue and initializes a few things. It should be called before any other UI function.
The file Vortex posted looks quite sloppy and unoptimized, though.
First off, DS already contains the selector of the automatic data segment at startup, no need to set it again. Jnz $+02h / jmp $+29h is quite bad... And why are you saving everything returned by INITTASK when you're only using DI anyway? xor ax,ax / push ax should be changed to push 0. mov ax,[16h] should be changed to push di. The rest is so bad, I don't even know where to start... It looks like it was written in C! :eek:
Let's see if you won't save a number of bytes fixing this comparable to the number of bytes you saved by reducing header size.
Here is my third example of 334 bytes. :)
Sephiroth3, before making strong comments like,
The rest is so bad, I don't even know where to start... It looks like it was written in C!
you should permit me to say that my code is just only a tiny example coded in C :)
Now here is the equivalent code in asm:
The code is assembled with 32-bit Macro Assembler and linked with Digital Mars linker
The initialization code taken from old Tasm and Masm examples.
Sephiroth3, before making strong comments like,
The rest is so bad, I don't even know where to start... It looks like it was written in C!
you should permit me to say that my code is just only a tiny example coded in C :)
Now here is the equivalent code in asm:
.MODEL LARGE,PASCAL
.286
MB_OK = 0
INITTASK proto
WAITEVENT proto :word
INITAPP proto :word
MESSAGEBOX proto :word,:word,:word,:word,:word,:word
.DATA
db 16 dup( 0 ) ; Required for Task Header!!
szMsg db 'Hello!',0
hInstance dw ?
.CODE
start:
;Windows initialization. Sets up registers and stack.
;INITTASK returns:
; 'Failure:
; AX = zero if it failed
; Success:
; AX = 1
; CX = stack limit
; DX = cmdShow parameter to CreateWindow
; ES:BX = -> DOS format command line (ES = PSP address)
; SI = hPrevinstance
; DI = hinstance
invoke INITTASK
or ax,ax
jnz OK
jmp terminate
OK:
mov hInstance, di
;Initialize the Windows App
invoke WAITEVENT,0
invoke INITAPP,hInstance
or ax,ax
jz terminate
invoke MESSAGEBOX,0,ds,offset szMsg,ds,offset szMsg,MB_OK
terminate:
mov ax, 4CFFh
int 21h ; terminate program
END start
The code is assembled with 32-bit Macro Assembler and linked with Digital Mars linker
\masm32\bin\ml -c Hello.asm
\dm\bin\link -alignment:2 -stub:stub.exe Hello.obj,Hello.exe,,libw.lib,win16.def
The initialization code taken from old Tasm and Masm examples.
Why isn't NE used more? Because it's 16bit protected mode, perhaps? ^_^
Why isn't NE used more? Because it's 16bit protected mode, perhaps? ^_^
Yeah, one can tell by the register sizes. However, I didn't realize those can still be run with Win9x and WinNt+.
Ah, ok :P Well, this is 264 bytes, but I'm sure it won't be too hard to beat.
What's your technique to reduce the file to 264 bytes?
9x and NT still has more or less full support for the win16 subsystems (and 9x is based partially on it, very ugly). And of course you can still use 32bit registers in win16 apps, they'll just generate pesky prefix bytes.
Curiously enough, Solitaire, Minesweeper and probably a bunch of other programs came in 32-bit versions with Windows NT, although the old versions worked just fine :P The new Minesweeper is nearly 4 times as large as the old one. I wonder what they were on? Or was this a publicity trick?
To reduce the file size, I reduced the size of the horribly overbloated code and set the name and description of the program both to "A". I shrunk the space before the NE header and put the message at 0x18, and put the DOS program to display the message in the task header.
To reduce the file size, I reduced the size of the horribly overbloated code and set the name and description of the program both to "A". I shrunk the space before the NE header and put the message at 0x18, and put the DOS program to display the message in the task header.
How to shrink the space before the NE header?
I got 242, but I'm sure some more shrinking is possible.
Pelaillo,
How you shrinked the executable? Can you post your method?
How you shrinked the executable? Can you post your method?
He put the data segment in the header and removed the stub. Anyway there is plenty of unused space in the header now.
Okay, I got it down to 225 bytes and at the same time, restored the stub. This might be the absolute minimum, short of hard-coding the API addresses.
Okay, I got it down to 225 bytes and at the same time, restored the stub. This might be the absolute minimum, short of hard-coding the API addresses.
Oops, forgot the file! Why will the board only allow you to upload a new attachment if the post already has one? :confused: