flat assembler
Message board for the users of flat assembler.
Index
> Windows > Question: win16 application |
Author |
|
tutenhamon 22 Sep 2010, 17:21
How I create win16 application using a FASM ?
I must use a format MZ directive and I ... ? (what's next?) |
|||
22 Sep 2010, 17:21 |
|
LocoDelAssembly 22 Sep 2010, 17:44
You can't actually, fasm has no support for Win16 (NE format?). MZ format is for MS-DOS executables.
|
|||
22 Sep 2010, 17:44 |
|
mindcooler 23 Sep 2010, 11:58
Code: format binary as 'exe' _________________ This is a block of text that can be added to posts you make. |
|||
23 Sep 2010, 11:58 |
|
revolution 23 Sep 2010, 12:15
mindcooler wrote:
Code: format binary as 'exe' db 'NE' ;... |
|||
23 Sep 2010, 12:15 |
|
tutenhamon 24 Sep 2010, 22:01
Code: format binary as 'exe' use16 db 'MZ' ;dos header db 'NE' ;ID='NE' db 0 ;Linker major version db 0 ;Linker minor version dw entry_table ;Offset of entry table (see below) dw end_entry_table - entry_table ;Length of entry table in bytes dd 0 ;File load CRC (0 in Borland's TPW) db 0b ;Program flags, bitmapped : ;0-1 - DGroup type : ;0 - none ;1 - single shared ;2 - multiple ;3 - (null) ;2 - Global initialization ;3 - Protected mode only ;4 - 8086 instructions ;5 - 80286 instructions ;6 - 80386 instructions ;7 - 80x87 instructions db 0b ;Application flags, bitmapped ;0-2 - Application type ;1 - Full screen (not aware of Windows/P.M. API) ;2 - Compatible with Windows/P.M. API ;3 - Uses Windows/P.M. API ;3 - OS/2 family application ;4 - reserved? ;5 - Errors in image/executable ;6 - "non-conforming program" whatever ;7 - DLL or driver (SS:SP info invalid, CS:IP points at FAR init routine called with ;AX=module handle which returns AX=0000h on failure, AX nonzero on successful initialization) db 0 ;Auto data segment index dw 0 ;Initial local heap size dw 0 ;Initial stack size dd start ;Entry point (CS:IP), CS is index into segment table dd 0 ;Initial stack pointer (SS:SP) SS is index into segment table dw 0 ;Segment count dw 0 ;Module reference count dw 0 ;Size of nonresident names table in bytes dw 0 ;Offset of segment table (see below) dw resource ;Offset of resource table dw 0 ;Offset of resident names table dw 0 ;Offset of module reference table dw 0 ;Offset of imported names table ;(array of counted strings, terminated with a ;string of length 00h) dd 0 ;Offset from start of file to nonresident names table dw 0 ;Count of moveable entry point listed in entry table dw 0 ;File alignment size shift count 0 is equivalent to 9 (default 512-byte pages) dw 0 ;Number of resource table entries db 0 ;Target operating system ;0 - unknown ;1 - OS/2 ;2 - Windows ;3 - European MS-DOS 4.x ;4 - Windows 386 ;5 - BOSS (Borland Operating System Services) db 0b ;Other OS/2 EXE flags, bitmapped ;0 - Long filename support ;1 - 2.x protected mode ;2 - 2.x proportional fonts ;3 - Executable has gangload area dw 0 ;Offset to return thunks or start of gangload area - whatever that means. dw 0 ;offset to segment reference thunks or length of gangload area. dw 0 ;Minimum code swap area size db 0,1 ;Expected Windows version (minor version first) start: ret entry_table: end_entry_table: resource: what's next? dos header? entry table? resource? |
|||
24 Sep 2010, 22:01 |
|
baldr 25 Sep 2010, 05:02
tutenhamon,
You've forgot about IMAGE_DOS_HEADER.e_lfanew. That's how loader finds New Executable (and LE/LX/PE too). There was something with .e_lfarlc but I don't remember correctly what it was (.e_lfarlc > 0x1C, probably). I've made simple NE in fasm as a container for .Fon font libraries (resource-only DLL); if you're interested, I can post it. |
|||
25 Sep 2010, 05:02 |
|
tutenhamon 25 Sep 2010, 13:54
baldr Yes I'am interested this code.
|
|||
25 Sep 2010, 13:54 |
|
baldr 25 Sep 2010, 13:58
tutenhamon,
Remember, this is not supposed to do anything: it was written as a container for bitmap font resources. Code: use16 format binary as "Fon" ..fileoffset = 0 mz.header: .magic dw 'MZ' ;00 .cblp dw mz.size mod 512 ;02 .cp dw (mz.size-1)/512 + 1 ;04 .crlc dw 0 ;06 .cparhdr dw mz.header.size shr 4 ;08 .minalloc dw 8 ;0a .maxalloc dw 8 ;0c .ss dw 0 ;0e .sp dw 160 ;10 .csum dw 0 ;12 .ip dw mz.image.entry ;14 .cs dw 0 ;16 .lfarlc dw mz.size ;18 .ovno dw 0 ;1a .res rd 1 ;1c align 16 ;padding ..fileoffset = ..fileoffset+$-$$ .size = ..fileoffset mz.image: org 0 .message db 'Font library.',13,10,'$' .entry: mov ah, 9 mov dx, .message+0x100 int 0x21 mov ah, 0x4c int 0x21 rb 0x3c-(mz.image+$-$$) ;padding .e_lfanew dd ne.header ..fileoffset = ..fileoffset+$-$$ mz.size = ..fileoffset ne.header = ..fileoffset org 0 .magic dw 'NE' .ver db 5 .rev db 1 .enttab dw ne.enttab .cbenttab dw ne.enttab.size .crc dd 0 .flags dw 0x8000 .autodata dw 0 .heap dw 0 .stack dw 0 .csip dd 0 .sssp dd 0 .cseg dw 0 .cmodref dw 0 .cbnrestab dw ne.nresnametab.size .segtab dw ne.segtab .rsrctab dw ne.rsrctab .resnametab dw ne.resnametab .modreftab dw ne.modreftab .impnametab dw ne.impnametab .nresnametab dd ..nresnametab .cmovent dw 0 .align dw 4 .cres dw 0 .exetyp db 2 .flagsother db 0 .pretthunks dw 0 .psegrefbytes dw 0 .swaparea dw 0 .expver dw 0x030a ne: .segtab: .segtab.size = $-.segtab .rsrctab: dw 4 dw 0 .rsrctab.size = $-.rsrctab struc cstr [data] { local ..end db ..end-($+1),data ..end: } .resnametab: .modname cstr "72DPI" dw 0 .last cstr "" .resnametab.size = $-.resnametab .modreftab: .modreftab.size = $-.modreftab .impnametab: .impnametab.size = $-.impnametab .enttab: db 0 .enttab.size = $-ne.enttab ..nresnametab = ..fileoffset+$-$$ .nresnametab: .fontname cstr "FONTRES 100,72,72:72DPI (16)" dw 0 db 0 .nresnametab.size = $-.nresnametab |
|||
25 Sep 2010, 13:58 |
|
rugxulo 05 Oct 2010, 04:50
OpenWatcom supports Win16 code, so you could take a look there for more details.
|
|||
05 Oct 2010, 04:50 |
|
Kenneth Zheng 07 Oct 2010, 14:29
objconv can covert 16bit and 32bit COFF format.
You can use below weblink to find it: http://www.agner.org/optimize [/url] _________________ Pure Assembly Language Funs |
|||
07 Oct 2010, 14:29 |
|
rugxulo 11 Oct 2010, 20:04
Kenneth, you keep calling it COFF, which is confusing. Unless I'm mistaken, COFF doesn't support 16-bit (maybe GNU extensions, I dunno). Are you talking about OMF/OBJ or COFF as in DJGPP?
|
|||
11 Oct 2010, 20:04 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.