Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.msdos.programmer > #4320
| From | Mateusz Viste <mateusz@x.invalid> |
|---|---|
| Newsgroups | comp.os.msdos.programmer |
| Subject | Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library |
| Date | 2023-11-10 00:19 +0100 |
| Organization | ... |
| Message-ID | <20231110001940.4a91a71b@mateusz> (permalink) |
| References | <20230731172858.11ce54d9@mateusz> |
dn. Mon, 31 Jul 2023 17:28:58 +0200, Mateusz Viste napisał:
> It appears that the COM file is not being originated at offset 0x100,
> despite the "FORMAT DOS COM" wlink directive. It's also not
> 0-originated, so I am not sure how the offsets are calculated exactly.
> Once I fix them with a hex editor, the executable works.
>
> What am I missing here?
Hello all,
I talked with Bernd Böckmann today and I was surprised to learn that
he tackled this very same problem recently. He was, however, far more
successful than me and kindly shared the piece of information that I
have missed all along.
Bernd said:
"Because in tiny memory model the code is in the same segment as the
data, the linker must be told to merge these segments to a single one
while linking, otherwise the addresses are messed up. This is done by
the GROUP directive in startup.asm, which includes _TEXT (as opposed to
the .EXE version)."
The need of a custom startup code was already hinted in this thread by
Alexei A. Frounze, and I did attempt to create such startup back then,
but the necessity of grouping segments was lost on me.
Bernd provided me with a working example of his startup code. With this
new bit of information I was able to adapt my proof of concept project
- and this time, it works! The resulting executable size is 45 bytes.
I am pasting here below all the files for posterity.
Mateusz
--- HELLO.LNK ---------------------------------------------
name hello
system dos com
option map
option nodefaultlibs
file startup
file hello
--- HELLO.C -----------------------------------------------
void main(void) {
char *hello = "Hello$";
_asm {
mov ah, 9
mov dx, hello
int 0x21
}
}
--- STARTUP.ASM -------------------------------------------
.8086
dgroup group _TEXT,_DATA,CONST,CONST2,_BSS,
extrn "C",main : near
; public _cstart_, _small_code_, __STK
public _cstart_, _small_code_
_TEXT segment word public 'CODE'
org 100h
_small_code_ label near
_cstart_:
call main
mov ah, 4ch
int 21h
; Stack overflow checking routine is absent. Remember to compile your
; programs with the -s option to avoid referencing __STK
;__STK:
; ret
_DATA segment word public 'DATA'
_DATA ends
CONST segment word public 'DATA'
CONST ends
CONST2 segment word public 'DATA'
CONST2 ends
_BSS segment word public 'BSS'
_BSS ends
_TEXT ends
end _cstart_
--- BUILD.BAT ---------------------------------------------
wasm startup.asm
wcc -os -zl -ms -s -bt=dos hello.c
wlink @hello.lnk
-----------------------------------------------------------
Back to comp.os.msdos.programmer | Previous | Next — Previous in thread | Find similar
[OpenWatcom] building a COM file without pulling in the Watcom standard library Mateusz Viste <mateusz@x.invalid> - 2023-07-31 17:28 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library JJ <jj4public@outlook.com> - 2023-08-01 18:38 +0700
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library Mateusz Viste <mateusz@x.invalid> - 2023-08-01 14:50 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library T. Ment <t.ment@protocol.invalid> - 2023-08-01 15:23 +0100
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library "Alexei A. Frounze" <alexfrunews@gmail.com> - 2023-08-02 20:28 -0700
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library Mateusz Viste <mateusz@x.invalid> - 2023-08-03 10:21 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library "Alexei A. Frounze" <alexfrunews@gmail.com> - 2023-08-03 19:41 -0700
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library Mateusz Viste <mateusz@x.invalid> - 2023-08-04 14:03 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library "R.Wieser" <address@is.invalid> - 2023-08-03 10:39 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library Mateusz Viste <mateusz@x.invalid> - 2023-08-03 12:07 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library "R.Wieser" <address@is.invalid> - 2023-08-03 14:35 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library "R.Wieser" <address@is.invalid> - 2023-08-04 08:31 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library Mateusz Viste <mateusz@x.invalid> - 2023-08-04 14:03 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library "R.Wieser" <address@is.invalid> - 2023-08-04 16:29 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library Mateusz Viste <mateusz@x.invalid> - 2023-08-04 16:56 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library "R.Wieser" <address@is.invalid> - 2023-08-04 19:02 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library Mateusz Viste <mateusz@x.invalid> - 2023-08-04 21:18 +0200
Re: [OpenWatcom] building a COM file without pulling in the Watcom standard library Mateusz Viste <mateusz@x.invalid> - 2023-11-10 00:19 +0100
csiph-web