• OT: horrible 8086 segmentation

    From mm0fmf@3:770/3 to All on Mon Nov 25 17:33:36 2024
    Raspberry Pi relevance : I'm writing some Pi Pico code


    I was doing some head scratching when I remembered I'd written something
    very similar in the distant past to what I was doing. I had to dig
    through piles of CD-Rs to find the one with the backups on from all
    those years back. It still reads fine, 21st July 1998 is the date on the
    CD. 26 years old.

    Anyway, I've pulled the files from it on to the wee Linux machine for
    updating and use in the project. There's a date in the header saying
    "created 1993" and last changes were "16th July 1996". I was just
    starting to go bald then!

    I've been rummaging through this old CD-R looking at what I was up to
    all those years ago and found all sorts of horrible 8086 segmentation management in the C code

    e.g.
    "
    // start of barrel
    EventRec far* searchp = (EventRec far*) work.bufs;

    "


    My eyes! My eyes! That was COMPACT model code, so 64k of code and 1MB of
    data, code addresses were 16bit offsets to the CS reg and data was far
    so 32 bits of segment and offset of DS or ES. And of course you had to
    be extra careful of any pointer arithmetic as a far pointer wrapped
    after 64k. You had to use slower HUGE pointers to get automatic
    normalisation. God it was shit.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From =?UTF-8?Q?Josef_M=C3=B6llers?=@3:770/3 to All on Tue Nov 26 18:37:02 2024
    On 25.11.24 18:33, mm0fmf wrote:
    [...]

    e.g.
    "
        // start of barrel
        EventRec far* searchp = (EventRec far*) work.bufs;

    "


    My eyes! My eyes! That was COMPACT model code, so 64k of code and 1MB of data, code addresses were 16bit offsets to the CS reg and data was far
    so 32 bits of segment and offset of DS or ES. And of course you had to
    be extra careful of any pointer arithmetic as a far pointer wrapped
    after 64k. You had to use slower HUGE pointers to get automatic normalisation. God it was shit.


    And to consider that, at that time, processors like MC68000 or NS32016
    were readily available.

    Josef

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Charlie Gibbs@3:770/3 to josef@invalid.invalid on Tue Nov 26 18:50:24 2024
    On 2024-11-26, Josef Möllers <josef@invalid.invalid> wrote:

    On 25.11.24 18:33, mm0fmf wrote:

    My eyes! My eyes! That was COMPACT model code, so 64k of code and 1MB of
    data, code addresses were 16bit offsets to the CS reg and data was far
    so 32 bits of segment and offset of DS or ES. And of course you had to
    be extra careful of any pointer arithmetic as a far pointer wrapped
    after 64k. You had to use slower HUGE pointers to get automatic
    normalisation. God it was shit.

    And to consider that, at that time, processors like MC68000 or NS32016
    were readily available.

    Which proves once again that a shitty design beats a good one
    if it's released first.

    Everybody was yapping about the 640K barrier. I was more concerned
    with the 64K barrier. I remember manually normalizing pointers
    everywhere, and if I wanted to work with a large arrays of structures
    I'd copy individual structures to a work area byte by byte so I
    didn't get bitten by segment wrap-around in the middle of a structure.

    As the joke goes, aren't you glad the iAPX432 died out?
    Otherwise a truly horrible Intel architecture might have
    taken over the world.

    --
    /~\ Charlie Gibbs | Growth for the sake of
    \ / <cgibbs@kltpzyxm.invalid> | growth is the ideology
    X I'm really at ac.dekanfrus | of the cancer cell.
    / \ if you read it the right way. | -- Edward Abbey

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From mm0fmf@3:770/3 to Charlie Gibbs on Tue Nov 26 22:03:48 2024
    On 26/11/2024 18:50, Charlie Gibbs wrote:
    On 2024-11-26, Josef Möllers <josef@invalid.invalid> wrote:

    On 25.11.24 18:33, mm0fmf wrote:

    My eyes! My eyes! That was COMPACT model code, so 64k of code and 1MB of >>> data, code addresses were 16bit offsets to the CS reg and data was far
    so 32 bits of segment and offset of DS or ES. And of course you had to
    be extra careful of any pointer arithmetic as a far pointer wrapped
    after 64k. You had to use slower HUGE pointers to get automatic
    normalisation. God it was shit.

    And to consider that, at that time, processors like MC68000 or NS32016
    were readily available.

    Which proves once again that a shitty design beats a good one
    if it's released first.

    Everybody was yapping about the 640K barrier. I was more concerned
    with the 64K barrier. I remember manually normalizing pointers
    everywhere, and if I wanted to work with a large arrays of structures
    I'd copy individual structures to a work area byte by byte so I
    didn't get bitten by segment wrap-around in the middle of a structure.

    As the joke goes, aren't you glad the iAPX432 died out?
    Otherwise a truly horrible Intel architecture might have
    taken over the world.


    I found this when digging around...

    "void KERNELsetvect(unsigned wVec, void far *pVect)
    {
    void far * far *pPtr ;

    pPtr = (void far * far *) MK_FP(0x0000, wVec << 2) ;
    *pPtr = pVect ;
    }"

    It simply looks so ugly.

    ISTR trying to push to use 68000 or even 68E020 but 80186EB became the
    CPU of choice. It had lots of nice embedded features on chip and ran at
    20MHz. And you could use PC development tools.

    It's 26 years since I had to deal with this segmented rubbish and a lot
    of it I had forgotten or repressed!

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to All on Wed Nov 27 11:40:06 2024
    On 26/11/2024 17:37, Josef Möllers wrote:
    On 25.11.24 18:33, mm0fmf wrote:
    [...]

    e.g.
    "
         // start of barrel
         EventRec far* searchp = (EventRec far*) work.bufs;

    "


    My eyes! My eyes! That was COMPACT model code, so 64k of code and 1MB
    of data, code addresses were 16bit offsets to the CS reg and data was
    far so 32 bits of segment and offset of DS or ES. And of course you
    had to be extra careful of any pointer arithmetic as a far pointer
    wrapped after 64k. You had to use slower HUGE pointers to get
    automatic normalisation. God it was shit.


    And to consider that, at that time, processors like MC68000 or NS32016
    were readily available.

    Backwards compatibility.
    DOS came from 8080 based CP/M , to run on an 8086, to where 8 bit code
    could be easily ported.

    And so we were stick with that architecture.

    A prime example off 'mass marketing always wins over excellence'

    and
    'nothing succeeds like success'



    --
    Labour - a bunch of rich people convincing poor people to vote for rich
    people by telling poor people that "other" rich people are the reason
    they are poor.

    Peter Thompson

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Charlie Gibbs@3:770/3 to The Natural Philosopher on Thu Nov 28 19:42:18 2024
    On 2024-11-27, The Natural Philosopher <tnp@invalid.invalid> wrote:

    On 26/11/2024 17:37, Josef Möllers wrote:

    On 25.11.24 18:33, mm0fmf wrote:

    My eyes! My eyes! That was COMPACT model code, so 64k of code and 1MB
    of data, code addresses were 16bit offsets to the CS reg and data was
    far so 32 bits of segment and offset of DS or ES. And of course you
    had to be extra careful of any pointer arithmetic as a far pointer
    wrapped after 64k. You had to use slower HUGE pointers to get
    automatic normalisation. God it was shit.

    And to consider that, at that time, processors like MC68000 or NS32016
    were readily available.

    Backwards compatibility.
    DOS came from 8080 based CP/M , to run on an 8086, to where 8 bit code
    could be easily ported.

    And so we were stick with that architecture.

    Intel put the "backward" in "backward compatible".

    --
    /~\ Charlie Gibbs | Growth for the sake of
    \ / <cgibbs@kltpzyxm.invalid> | growth is the ideology
    X I'm really at ac.dekanfrus | of the cancer cell.
    / \ if you read it the right way. | -- Edward Abbey

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Robert Roland@3:770/3 to josef@invalid.invalid on Sun Dec 1 14:29:00 2024
    On Tue, 26 Nov 2024 18:37:02 +0100, Josef Mllers
    <josef@invalid.invalid> wrote:

    And to consider that, at that time, processors like MC68000 or NS32016
    were readily available.

    At the time when the design decision was made, the Motorola 68000 was
    not ready for production.

    From https://en.wikipedia.org/wiki/IBM_Personal_Computer :

    "The 68000 was considered the best choice,[19] but was not
    production-ready like the others."
    --
    RoRo

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From The Natural Philosopher@3:770/3 to Robert Roland on Sun Dec 1 13:57:00 2024
    On 01/12/2024 13:29, Robert Roland wrote:
    On Tue, 26 Nov 2024 18:37:02 +0100, Josef Möllers
    <josef@invalid.invalid> wrote:

    And to consider that, at that time, processors like MC68000 or NS32016
    were readily available.

    At the time when the design decision was made, the Motorola 68000 was
    not ready for production.

    From https://en.wikipedia.org/wiki/IBM_Personal_Computer :

    "The 68000 was considered the best choice,[19] but was not
    production-ready like the others."

    I also remember a zilog Z8000?


    --
    “The ultimate result of shielding men from the effects of folly is to
    fill the world with fools.”

    Herbert Spencer

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Richard Kettlewell@3:770/3 to The Natural Philosopher on Sun Dec 1 15:11:04 2024
    The Natural Philosopher <tnp@invalid.invalid> writes:
    Robert Roland wrote:
    On Tue, 26 Nov 2024 18:37:02 +0100, Josef Möllers
    <josef@invalid.invalid> wrote:
    And to consider that, at that time, processors like MC68000 or NS32016
    were readily available.
    At the time when the design decision was made, the Motorola 68000 was
    not ready for production.
    From https://en.wikipedia.org/wiki/IBM_Personal_Computer :
    "The 68000 was considered the best choice,[19] but was not
    production-ready like the others."

    I also remember a zilog Z8000?

    Yes, although also with a segmented memory model.

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Lawrence D'Oliveiro@3:770/3 to Richard Kettlewell on Wed Dec 18 06:22:56 2024
    On Sun, 01 Dec 2024 15:11:05 +0000, Richard Kettlewell wrote:

    The Natural Philosopher <tnp@invalid.invalid> writes:

    I also remember a zilog Z8000?

    Yes, although also with a segmented memory model.

    Its segmentation scheme made Intel x86 look good.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Lawrence D'Oliveiro@3:770/3 to Charlie Gibbs on Wed Dec 18 06:24:00 2024
    On Thu, 28 Nov 2024 19:42:18 GMT, Charlie Gibbs wrote:

    Intel put the "backward" in "backward compatible".

    I recall the term “backward combatible” used to describe the feelings of violence some people had towards the requirement for backward
    compatibility with certain kinds of brain death ...

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Charlie Gibbs@3:770/3 to Lawrence D'Oliveiro on Wed Dec 18 18:02:34 2024
    On 2024-12-18, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On Thu, 28 Nov 2024 19:42:18 GMT, Charlie Gibbs wrote:

    Intel put the "backward" in "backward compatible".

    I recall the term “backward combatible” used to describe the feelings of violence some people had towards the requirement for backward
    compatibility with certain kinds of brain death ...

    Then there's "bug-compatible", where so many people and systems
    have adapted to an existing bug that you can't fix it without
    breaking just about everything - so any future versions have
    to also contain the bug, or at least a good emulation of it.

    If at first you don't succeed, you might as well forget it.

    --
    /~\ Charlie Gibbs | Growth for the sake of
    \ / <cgibbs@kltpzyxm.invalid> | growth is the ideology
    X I'm really at ac.dekanfrus | of the cancer cell.
    / \ if you read it the right way. | -- Edward Abbey

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Lawrence D'Oliveiro@3:770/3 to John on Thu Dec 19 19:57:30 2024
    On Wed, 18 Dec 2024 20:33:27 +0000, Kerr-Mudd, John wrote:

    Qwerty keyboards being a prime example.

    I remember Byte magazine did an in-depth study of typing speed, involving
    both theoretical analyses and actual measurements using video cameras on
    the hands of people as they typed, comparing QWERTY and Dvorak layouts.

    Their conclusion: there was no significant efficiency improvement in
    switching to Dvorak.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Brian Gregory@3:770/3 to Lawrence D'Oliveiro on Mon Dec 23 03:26:10 2024
    On 18/12/2024 06:22, Lawrence D'Oliveiro wrote:
    On Sun, 01 Dec 2024 15:11:05 +0000, Richard Kettlewell wrote:

    The Natural Philosopher <tnp@invalid.invalid> writes:

    I also remember a zilog Z8000?

    Yes, although also with a segmented memory model.

    Its segmentation scheme made Intel x86 look good.

    Not that unusual. Compare to some of the Microchip PICs. Some have
    really bizarre bank switching arrangements and so on.

    --
    Brian Gregory (in England).

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Lawrence D'Oliveiro@3:770/3 to Brian Gregory on Mon Dec 23 22:55:52 2024
    On Mon, 23 Dec 2024 03:26:11 +0000, Brian Gregory wrote:

    On 18/12/2024 06:22, Lawrence D'Oliveiro wrote:

    On Sun, 01 Dec 2024 15:11:05 +0000, Richard Kettlewell wrote:

    The Natural Philosopher <tnp@invalid.invalid> writes:

    I also remember a zilog Z8000?

    Yes, although also with a segmented memory model.

    Its segmentation scheme made Intel x86 look good.

    Not that unusual. Compare to some of the Microchip PICs. Some have
    really bizarre bank switching arrangements and so on.

    I think the Apple II RAM expansion card worked by switching to a different
    bank (48K each?) every time a particular control register byte was
    written. You couldn’t just write a bank number: instead, you had to repeat the write N number of times, and I guess remember where you started from,
    to get to the right bank.

    But this was because the CPU itself only supported 16-bit addressing. What
    was Zilog’s excuse?

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Michael J. Mahon@3:770/3 to Lawrence D'Oliveiro on Tue Dec 24 08:24:08 2024
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Mon, 23 Dec 2024 03:26:11 +0000, Brian Gregory wrote:

    On 18/12/2024 06:22, Lawrence D'Oliveiro wrote:

    On Sun, 01 Dec 2024 15:11:05 +0000, Richard Kettlewell wrote:

    The Natural Philosopher <tnp@invalid.invalid> writes:

    I also remember a zilog Z8000?

    Yes, although also with a segmented memory model.

    Its segmentation scheme made Intel x86 look good.

    Not that unusual. Compare to some of the Microchip PICs. Some have
    really bizarre bank switching arrangements and so on.

    I think the Apple II RAM expansion card worked by switching to a different bank (48K each?) every time a particular control register byte was
    written. You couldn’t just write a bank number: instead, you had to repeat the write N number of times, and I guess remember where you started from,
    to get to the right bank.

    But this was because the CPU itself only supported 16-bit addressing. What was Zilog’s excuse?


    Apple sold three memory expansion cards for the (8-bit) Apple II’s: the
    16KB Language card that allowed bank switching RAM in place of the built-in BASIC ROM, and (later for the Apple IIe) the 64KB Memory Expansion card for
    the Apple IIe that allowed bank switching in a second 64KB of RAM bank
    switched over the built-in 64KB (both were further bank switched the same
    way as a 48KB Apple II equipped with a Language Card), and finally, the “slinky”-style 256KB - 1 MB card that was not bank switched, but supported sequential reads or writes through an autoincremented register set up by
    the programmer (used primarily as a RAM disk).

    Many other manufacturers offered cards of various capacities emulating the architecture of each of Apple’s cards.

    I know of no expansion card that required multiple control byte accesses to select a particular bank.

    Instead the bank value was stored in a control register, but this was only
    for third-party cards with more than one additional bank. Since Apple never shipped such a card, different manufacturers did not all choose the same control byte address, nor did they interpret the control value the same
    way.

    Apple set the standard and a large number of applications used it. The third-party extensions were supported by a smaller group of applications, sometimes by design and sometimes by patches to applications.

    BTW, banks were switched in selectively for reading or writing, so copying
    data from one bank to another or executing code that wrote to another bank
    was quite easy.

    --
    -michael - NadaNet 3.1 and AppleCrate II: http://michaeljmahon.com

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From mm0fmf@3:770/3 to Michael J. Mahon on Tue Dec 24 11:39:36 2024
    On 24/12/2024 08:24, Michael J. Mahon wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Mon, 23 Dec 2024 03:26:11 +0000, Brian Gregory wrote:

    On 18/12/2024 06:22, Lawrence D'Oliveiro wrote:

    On Sun, 01 Dec 2024 15:11:05 +0000, Richard Kettlewell wrote:

    The Natural Philosopher <tnp@invalid.invalid> writes:

    I also remember a zilog Z8000?

    Yes, although also with a segmented memory model.

    Its segmentation scheme made Intel x86 look good.

    Not that unusual. Compare to some of the Microchip PICs. Some have
    really bizarre bank switching arrangements and so on.

    I think the Apple II RAM expansion card worked by switching to a different >> bank (48K each?) every time a particular control register byte was
    written. You couldn’t just write a bank number: instead, you had to repeat >> the write N number of times, and I guess remember where you started from,
    to get to the right bank.

    But this was because the CPU itself only supported 16-bit addressing. What >> was Zilog’s excuse?


    Apple sold three memory expansion cards for the (8-bit) Apple II’s: the 16KB Language card that allowed bank switching RAM in place of the built-in BASIC ROM, and (later for the Apple IIe) the 64KB Memory Expansion card for the Apple IIe that allowed bank switching in a second 64KB of RAM bank switched over the built-in 64KB (both were further bank switched the same
    way as a 48KB Apple II equipped with a Language Card), and finally, the “slinky”-style 256KB - 1 MB card that was not bank switched, but supported
    sequential reads or writes through an autoincremented register set up by
    the programmer (used primarily as a RAM disk).

    Many other manufacturers offered cards of various capacities emulating the architecture of each of Apple’s cards.

    I know of no expansion card that required multiple control byte accesses to select a particular bank.

    Instead the bank value was stored in a control register, but this was only for third-party cards with more than one additional bank. Since Apple never shipped such a card, different manufacturers did not all choose the same control byte address, nor did they interpret the control value the same
    way.

    Apple set the standard and a large number of applications used it. The third-party extensions were supported by a smaller group of applications, sometimes by design and sometimes by patches to applications.

    BTW, banks were switched in selectively for reading or writing, so copying data from one bank to another or executing code that wrote to another bank was quite easy.


    Some of the Z80 CPM cards for the Apple II had memory. Some had just 64k
    and the II's RAM was used for disk buffers and such. I'm sure my CPM 3
    card had a 6MHz Z80 and 192k of RAM but it's 41 years ago since I last
    used one and my memory is vague now.

    The Atari 7800 console did bank switching on the ROM cartridge as there
    was only 4K memory space. You hit the bank switch register and the next
    4K chunk of ROM was mapped and you continued executing at the next
    address in the ROM. You had to remember which bank was mapped and you
    could only move forward 1 bank at a time. Cue interesting routines to
    switch to an arbitrary bank. 1988 when I last wrote stuff for one of them.

    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)