Skip to content

Commit

Permalink
[Regression] Explicitly request 16-bit default segments when using .M…
Browse files Browse the repository at this point in the history
…ODEL

Whoops, turns out that the build has been broken on TASM32 version 5.3
(the one in the DevKit) ever since 7897bf1. In contrast to version 5.0
(which I use for my development), 5.3 actually defines 32-bit segments
if you specify a .386 CPU before using .MODEL.

That might have been the reason for the .286 workaround all along?
Turns out there's the USE16 modifier, which makes this much more
explicit than switching CPUs.
  • Loading branch information
nmlgc committed Mar 29, 2021
1 parent 7b9194a commit 8bcf5d7
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 70 deletions.
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -79,6 +79,21 @@ C++, Open Watcom, and Visual C++, which will ease future third-party ports.
* Documenting function comments exclusively go into C/C++ header files, right
above the corresponding function prototype, *not* into ASM slices.

* If an ASM translation unit requires the `.MODEL` directive *and* uses 32-bit
80386 instructions via `.386`, make sure to specify the `USE16` model
modifier, as in

```asm
.model use16 large
```

Otherwise, some TASM versions might create 32-bit segments if `.386` is
specified before `.MODEL`, causing all sorts of issues and messing up
segment alignments. (TASM32 version 5.3 is known to do this, for example.)
Specifying `USE16` is a lot more understandable than switching back and
forth between CPUs, or relying on the order of the `.MODEL` and `.386`
directives to imply the default 16-bit behavior.

* Newly named symbols in ASM land (functions, global variables, `struc`ts, and
"sequence of numeric equate" enums) should immediately be reflected in C/C++
land, with the correct types and calling conventions. Typically, these
Expand Down
6 changes: 2 additions & 4 deletions libs/sprite16/sprite16.asm
Expand Up @@ -15,10 +15,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model tiny
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 tiny

include libs/master.lib/macros.inc
include th01/hardware/egc.inc
Expand Down
6 changes: 2 additions & 4 deletions th01_fuuin.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large _TEXT
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large _TEXT

BINARY = 'E'

Expand Down
6 changes: 2 additions & 4 deletions th01_op.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

BINARY = 'O'

Expand Down
6 changes: 2 additions & 4 deletions th01_reiiden.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

BINARY = 'M'

Expand Down
2 changes: 1 addition & 1 deletion th02/snd_mmdr.asm
@@ -1,5 +1,5 @@
.386
.model large SHARED
.model use16 large SHARED
locals

include libs/kaja/kaja.inc
Expand Down
6 changes: 2 additions & 4 deletions th02_main.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

include ReC98.inc
include th02/th02.inc
Expand Down
6 changes: 2 additions & 4 deletions th02_maine.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large _TEXT
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large _TEXT

include ReC98.inc
include th01/hardware/grppsafx.inc
Expand Down
6 changes: 2 additions & 4 deletions th02_op.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large _TEXT
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large _TEXT

include ReC98.inc
include th02/th02.inc
Expand Down
6 changes: 2 additions & 4 deletions th03_main.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

include ReC98.inc
include th03/arg_bx.inc
Expand Down
6 changes: 2 additions & 4 deletions th03_mainl.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

include ReC98.inc
include th03/th03.inc
Expand Down
6 changes: 2 additions & 4 deletions th03_op.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

include ReC98.inc
include th03/th03.inc
Expand Down
2 changes: 1 addition & 1 deletion th04/formats/cdg_load.asm
@@ -1,5 +1,5 @@
.386
.model large SHARED_
.model use16 large SHARED_
locals

include th03/arg_bx.inc
Expand Down
2 changes: 1 addition & 1 deletion th04/hardware/input_s.asm
@@ -1,5 +1,5 @@
.386
.model large SHARED_
.model use16 large SHARED_
locals

include pc98kbd.inc
Expand Down
6 changes: 2 additions & 4 deletions th04_main.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

BINARY = 'M'

Expand Down
6 changes: 2 additions & 4 deletions th04_maine.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

BINARY = 'E'

Expand Down
6 changes: 2 additions & 4 deletions th04_op.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large SHARED
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large SHARED

BINARY = 'O'

Expand Down
2 changes: 1 addition & 1 deletion th05/formats/pi_asm_1.asm
@@ -1,7 +1,7 @@
; First TH05 .PI assembly translation unit.

.386
.model large
.model use16 large
locals

include pc98.inc
Expand Down
2 changes: 1 addition & 1 deletion th05/formats/pi_asm_2.asm
@@ -1,7 +1,7 @@
; Second TH05 .PI assembly translation unit.

.386
.model large
.model use16 large
locals

include pc98.inc
Expand Down
6 changes: 2 additions & 4 deletions th05_main.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

BINARY = 'M'

Expand Down
6 changes: 2 additions & 4 deletions th05_maine.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

BINARY = 'E'

Expand Down
6 changes: 2 additions & 4 deletions th05_op.asm
Expand Up @@ -13,10 +13,8 @@
; OS type : MS DOS
; Application type: Executable 16bit

.286 ; Force the .model directive to create 16-bit default segments...
.model large
.386 ; ... then switch to what we actually need.
; And yes, we can't move this to an include file for some reason.
.386
.model use16 large

BINARY = 'O'

Expand Down
2 changes: 1 addition & 1 deletion th05_zuninit.asm
Expand Up @@ -13,7 +13,7 @@
; Application type: Executable 16bit

.386
.model tiny
.model use16 tiny
.code
org 100h

Expand Down

0 comments on commit 8bcf5d7

Please sign in to comment.