nuclear war (Miscellaneous)
Hello kerravon,
> > wut? "Figure out" an API for an existing system "from first principles"?
> > How? And why?
> To understand and find out anything I am missing.
> E.g. it was only recently that I found out that
> people normally develop new systems using an
> emulator on an existing system, but DOS was instead
> developed with the aid of a "monitor". Apparently
> use of a monitor is a lost art, but I was previously
> unaware that the art even existed.
Yes, indeed, it is a good idea to find out about prior art(s). Please continue to do that.
(In contrast, it is usually not a good idea to deduce facts about the real world from "Pure Thought" or "Pure Wisdom". That way madness lies.)
> And only about 24 hours ago (part of the delay here)
> I realized I didn't know (and still don't know) how
> it is technically possible for compilers to support
> the small memory model, given that a buffer can
> reside on either the stack or in the data segment.
"Small model" in x86-16 coding simply means that there are two program segments, one for code, and one for data — and stack! So within the program you have cs
≠ ds
= ss
: the stack segment is the same as the data segment.
If you run a debugger on a small model program compiled by Turbo C++ or Open Watcom or some other 16-bit compiler, you will find that ds
= ss
by the time you reach main ()
. So there you go.
This is straightforward for the compiler to implement in most cases.
(*** begin long aside ***)
However, a problem arises when compiling an interrupt handler routine (via a compiler-specific interrupt
or _interrupt
keyword). The interrupt handler might be called in the middle of some BIOS or DOS routine which sets ss
to point outside the program: then you have ss
≠ program's data segment (let us call it .data
).
The interrupt handler can easily set ds
:= .data
, but temporarily moving the stack pointer ss:sp
into the program data segment is not easy, and not always possible.
It turns out that Turbo C++ (version 2, at least) kind of glosses over this issue. It assumes ss
= ds
= .data
, without setting ss
(!). But it will normally access automatic stack variables via (ss:
)bp
and static storage variables via other registers or addressing modes, i.e. via ds
. This happens to work most of the time if you do not happen to mix stack addresses and static storage addresses. But it may fail.
Open Watcom in contrast explicitly handles this case, and will compile the interrupt handler in a special mode which takes into account that we might have ss
≠ ds
:= .data
.
Bart Oldeman, myself, and a few other folks, had a discussion about this case (among other matters) back in 2018, when I was trying to add far function support to Andrew Jenner's gcc-ia16
toolchain: https://github.com/tkchia/gcc-ia16/issues/19#issuecomment-367183866 .
(*** end long aside ***)
Thank you!
---
https://gitlab.com/tkchia · https://codeberg.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"
Complete thread:
- nuclear war - kerravon, 07.11.2022, 00:31
- nuclear war - Rugxulo, 07.11.2022, 09:55
- nuclear war - kerravon, 09.11.2022, 07:35
- nuclear war - marcov, 07.11.2022, 13:28
- nuclear war - kerravon, 09.11.2022, 07:43
- nuclear war - marcov, 09.11.2022, 20:18
- nuclear war - kerravon, 09.11.2022, 23:25
- nuclear war - marcov, 10.11.2022, 11:19
- nuclear war - kerravon, 10.11.2022, 13:33
- nuclear war - tom, 10.11.2022, 14:50
- nuclear war - kerravon, 10.11.2022, 15:13
- nuclear war - tom, 10.11.2022, 15:55
- nuclear war - kerravon, 10.11.2022, 15:27
- nuclear war - tom, 10.11.2022, 15:58
- nuclear war - kerravon, 10.11.2022, 16:22
- nuclear war - tom, 10.11.2022, 15:58
- nuclear war - kerravon, 10.11.2022, 15:13
- nuclear war - marcov, 11.11.2022, 11:09
- nuclear war - kerravon, 12.11.2022, 07:11
- nuclear war - tom, 10.11.2022, 14:50
- nuclear war - kerravon, 10.11.2022, 13:33
- nuclear war - marcov, 10.11.2022, 11:19
- nuclear war - tkchia, 10.11.2022, 00:25
- nuclear war - kerravon, 09.11.2022, 23:25
- nuclear war - marcov, 09.11.2022, 20:18
- nuclear war - kerravon, 09.11.2022, 07:43
- nuclear war - DosWorld, 07.11.2022, 13:54
- nuclear war - tkchia, 07.11.2022, 15:33
- nuclear war - kerravon, 09.11.2022, 07:50
- nuclear war - tkchia, 09.11.2022, 17:55
- nuclear war - kerravon, 09.11.2022, 18:15
- nuclear war - tkchia, 09.11.2022, 18:35
- nuclear war - kerravon, 09.11.2022, 23:10
- nuclear war - tkchia, 10.11.2022, 00:07
- nuclear war - kerravon, 10.11.2022, 01:16
- nuclear war - marcov, 10.11.2022, 11:28
- nuclear war - tkchia, 10.11.2022, 17:51
- nuclear war - kerravon, 10.11.2022, 23:45
- nuclear war - Rugxulo, 11.11.2022, 09:18
- nuclear war - marcov, 11.11.2022, 13:12
- nuclear war - kerravon, 12.11.2022, 08:48
- nuclear war - tkchia, 12.11.2022, 08:20
- nuclear war - kerravon, 12.11.2022, 08:43
- nuclear war - tkchia, 12.11.2022, 08:56
- nuclear war - kerravon, 12.11.2022, 09:16
- nuclear war - tkchia, 12.11.2022, 09:39
- nuclear war - kerravon, 12.11.2022, 09:59
- nuclear war - tkchia, 12.11.2022, 10:20
- nuclear war - kerravon, 12.11.2022, 10:29
- nuclear war - glennmcc, 13.11.2022, 18:24
- nuclear war - DosWorld, 16.11.2022, 00:03
- nuclear war - kerravon, 16.11.2022, 03:24
- nuclear war - glennmcc, 13.11.2022, 18:24
- nuclear war - kerravon, 12.11.2022, 10:29
- nuclear war - marcov, 13.11.2022, 12:02
- nuclear war - kerravon, 16.11.2022, 03:19
- nuclear war - marcov, 16.11.2022, 21:52
- nuclear war - kerravon, 16.11.2022, 23:54
- nuclear war - tkchia, 17.11.2022, 00:52
- nuclear war - glennmcc, 17.11.2022, 18:42
- nuclear war - kerravon, 17.11.2022, 23:45
- nuclear war - kerravon, 17.11.2022, 23:51
- nuclear war - glennmcc, 17.11.2022, 18:42
- nuclear war - tom, 17.11.2022, 11:10
- nuclear war - kerravon, 17.11.2022, 23:55
- nuclear war - tkchia, 17.11.2022, 00:52
- nuclear war - kerravon, 16.11.2022, 23:54
- nuclear war - marcov, 16.11.2022, 21:52
- nuclear war - kerravon, 16.11.2022, 03:19
- nuclear war - tkchia, 12.11.2022, 10:20
- nuclear war - kerravon, 12.11.2022, 09:59
- nuclear war - tkchia, 12.11.2022, 09:39
- nuclear war - kerravon, 12.11.2022, 09:16
- nuclear war - tkchia, 12.11.2022, 08:56
- nuclear war - kerravon, 12.11.2022, 08:43
- nuclear war - Rugxulo, 11.11.2022, 09:18
- nuclear war - kerravon, 10.11.2022, 23:45
- nuclear war - tkchia, 10.11.2022, 18:06
- nuclear war - kerravon, 10.11.2022, 01:16
- nuclear war - tkchia, 10.11.2022, 00:07
- nuclear war - kerravon, 09.11.2022, 23:10
- nuclear war - tkchia, 09.11.2022, 18:35
- nuclear war - kerravon, 09.11.2022, 18:15
- nuclear war - tkchia, 09.11.2022, 17:55
- nuclear war - kerravon, 09.11.2022, 07:50
- nuclear war - glennmcc, 07.11.2022, 20:47
- nuclear war - kerravon, 09.11.2022, 07:58
- nuclear war - glennmcc, 09.11.2022, 16:06
- nuclear war - kerravon, 09.11.2022, 17:58
- nuclear war - glennmcc, 10.11.2022, 16:55
- nuclear war - kerravon, 10.11.2022, 17:18
- nuclear war - glennmcc, 10.11.2022, 20:58
- nuclear war - kerravon, 10.11.2022, 23:23
- nuclear war - glennmcc, 10.11.2022, 20:58
- nuclear war - kerravon, 10.11.2022, 17:18
- nuclear war - tkchia, 12.11.2022, 10:10
- nuclear war - kerravon, 12.11.2022, 10:25
- nuclear war - tkchia, 12.11.2022, 11:13
- nuclear war - kerravon, 12.11.2022, 11:30
- nuclear war - tkchia, 16.11.2022, 16:23
- nuclear war - kerravon, 16.11.2022, 17:26
- nuclear war - tkchia, 16.11.2022, 18:16
- nuclear war - kerravon, 17.11.2022, 23:40
- nuclear war - tkchia, 18.11.2022, 00:38
- nuclear war - kerravon, 18.11.2022, 01:33
- nuclear war - kerravon, 18.11.2022, 02:56
- nuclear war - kerravon, 21.11.2022, 13:49
- nuclear war - DosWorld, 21.11.2022, 16:40
- nuclear war - glennmcc, 21.11.2022, 17:41
- nuclear war - DosWorld, 21.11.2022, 19:09
- nuclear war - kerravon, 21.11.2022, 23:38
- nuclear war - DosWorld, 22.11.2022, 19:19
- nuclear war - kerravon, 23.11.2022, 01:10
- nuclear war - DosWorld, 23.11.2022, 12:00
- nuclear war - kerravon, 23.11.2022, 12:28
- nuclear war - DosWorld, 25.11.2022, 18:20
- nuclear war - kerravon, 25.11.2022, 19:38
- nuclear war - DosWorld, 25.11.2022, 22:27
- nuclear war - kerravon, 25.11.2022, 22:34
- nuclear war - DosWorld, 25.11.2022, 22:39
- nuclear war - kerravon, 26.11.2022, 09:31
- nuclear war - glennmcc, 26.11.2022, 17:24
- nuclear war - DosWorld, 26.11.2022, 22:53
- nuclear war - kerravon, 26.11.2022, 09:31
- nuclear war - DosWorld, 25.11.2022, 22:39
- nuclear war - kerravon, 25.11.2022, 22:34
- nuclear war - DosWorld, 25.11.2022, 22:27
- nuclear war - kerravon, 10.12.2022, 05:54
- nuclear war - kerravon, 25.11.2022, 19:38
- nuclear war - DosWorld, 25.11.2022, 18:20
- nuclear war - kerravon, 23.11.2022, 12:28
- nuclear war - DosWorld, 23.11.2022, 12:00
- nuclear war - kerravon, 23.11.2022, 01:10
- nuclear war - DosWorld, 22.11.2022, 19:19
- nuclear war - kerravon, 21.11.2022, 23:38
- nuclear war - DosWorld, 21.11.2022, 16:40
- nuclear war - kerravon, 18.11.2022, 01:33
- nuclear war - tkchia, 18.11.2022, 00:38
- nuclear war - kerravon, 17.11.2022, 23:40
- nuclear war - tkchia, 16.11.2022, 18:16
- nuclear war - kerravon, 16.11.2022, 17:26
- nuclear war - tkchia, 16.11.2022, 16:23
- nuclear war - kerravon, 12.11.2022, 11:34
- nuclear war - kerravon, 12.11.2022, 11:38
- nuclear war - kerravon, 12.11.2022, 11:43
- nuclear war - kerravon, 12.11.2022, 11:38
- nuclear war - kerravon, 12.11.2022, 11:30
- nuclear war - tkchia, 12.11.2022, 11:13
- nuclear war - DosWorld, 12.11.2022, 11:35
- nuclear war - kerravon, 12.11.2022, 10:25
- nuclear war - glennmcc, 10.11.2022, 16:55
- nuclear war - kerravon, 09.11.2022, 17:58
- nuclear war - glennmcc, 09.11.2022, 16:06
- nuclear war - kerravon, 09.11.2022, 07:58
- nuclear war - DosWorld, 10.11.2022, 19:43
- nuclear war - kerravon, 10.11.2022, 23:25
- nuclear war - Rugxulo, 07.11.2022, 09:55