• reading a file from disk

    From luser...@nospicedham.gmail.com@luser.droog@nospicedham.gmail.com to comp.lang.asm.x86 on Sat May 15 22:39:02 2021
    From Newsgroup: comp.lang.asm.x86

    Hello all,

    I'm planning to resume work on my partly written 8086 emulator after a
    long hiatus. I want to add the ability to read a file, but I'm having some difficulty
    understanding how it's supposed to work under MS-DOS. I've found the
    listing of int 13h in Ralf Brown's Interrupt List (http://www.ctyme.com/intr/cat-003.htm)
    but it all seems very complicated and perhaps unnecessary.

    For the simplest working test, I think I can skip the CHS addressing and
    just use Logical Block Addressing with a single "disk" file on the host.
    Is there a good resource to understand how this all should work?

    I need to implement the BIOS routines and call host functions, probably
    just mmap'ing the file and using memcpy for both read and write.
    I have this sort of thing partly working for keyboard read and and screen
    write by using ESC instructions in the BIOS routines. The emulator
    implements the ESC instructions to call host functions getchar() and
    putchar().

    My emulator code is at https://github.com/luser-dr00g/8086
    with some overview and explanations in https://github.com/luser-dr00g/8086/pres

    TIA
    --
    droog

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From luser...@nospicedham.gmail.com@luser.droog@nospicedham.gmail.com to comp.lang.asm.x86 on Sun May 23 23:15:23 2021
    From Newsgroup: comp.lang.asm.x86

    On Sunday, May 16, 2021 at 3:48:21 PM UTC-5, luser...@nospicedham.gmail.com wrote:
    Hello all,

    I'm planning to resume work on my partly written 8086 emulator after a
    long hiatus. I want to add the ability to read a file, but I'm having some difficulty
    [...]
    Is there a good resource to understand how this all should work?

    I suppose this isn't really related to assembly language. I've ordered Peter Norton's
    Guide to the IBM PC. I guess I'll post in comp.os.msdos.programmer if I run into
    trouble.

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From antispam@antispam@nospicedham.math.uni.wroc.pl to comp.lang.asm.x86 on Tue May 25 01:26:11 2021
    From Newsgroup: comp.lang.asm.x86

    luser...@nospicedham.gmail.com <luser.droog@nospicedham.gmail.com> wrote:
    Hello all,

    I'm planning to resume work on my partly written 8086 emulator after a
    long hiatus. I want to add the ability to read a file, but I'm having some difficulty
    understanding how it's supposed to work under MS-DOS. I've found the
    listing of int 13h in Ralf Brown's Interrupt List (http://www.ctyme.com/intr/cat-003.htm)
    but it all seems very complicated and perhaps unnecessary.

    For the simplest working test, I think I can skip the CHS addressing and
    just use Logical Block Addressing with a single "disk" file on the host.
    Is there a good resource to understand how this all should work?

    I need to implement the BIOS routines and call host functions, probably
    just mmap'ing the file and using memcpy for both read and write.
    I have this sort of thing partly working for keyboard read and and screen write by using ESC instructions in the BIOS routines. The emulator
    implements the ESC instructions to call host functions getchar() and putchar().

    Basic question is what do you want to emulate? 8086 by itself can not
    do file I/O. You may do PC emulator in style of Bochs, that is
    emulate common hardware. You may do BIOS emulator. You may
    do DOS emulator, that is emulate file I/O at DOS level. Or
    you may emulate different system. For example QEMU 386 emulates
    Linux system calls. If you want your emulator to be simple,
    you may define your own system calls (say using something like INT 0x80h), thing like open, close, read, write. Advantage is simplicity.
    Disadvantage is that large body of existing 8086 assembler programs
    assumes DOS environment and will not work with different system.
    --
    Waldek Hebisch

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From luser...@nospicedham.gmail.com@luser.droog@nospicedham.gmail.com to comp.lang.asm.x86 on Wed May 26 15:33:53 2021
    From Newsgroup: comp.lang.asm.x86

    On Monday, May 24, 2021 at 8:40:27 PM UTC-5, anti...@nospicedham.math.uni.wroc.pl wrote:
    luser...@nospicedham.gmail.com <luser...@nospicedham.gmail.com> wrote:
    Hello all,

    I'm planning to resume work on my partly written 8086 emulator after a long hiatus. I want to add the ability to read a file, but I'm having some difficulty
    understanding how it's supposed to work under MS-DOS. I've found the listing of int 13h in Ralf Brown's Interrupt List (http://www.ctyme.com/intr/cat-003.htm)
    but it all seems very complicated and perhaps unnecessary.

    For the simplest working test, I think I can skip the CHS addressing and just use Logical Block Addressing with a single "disk" file on the host. Is there a good resource to understand how this all should work?

    I need to implement the BIOS routines and call host functions, probably just mmap'ing the file and using memcpy for both read and write.
    I have this sort of thing partly working for keyboard read and and screen write by using ESC instructions in the BIOS routines. The emulator implements the ESC instructions to call host functions getchar() and putchar().
    Basic question is what do you want to emulate? 8086 by itself can not
    do file I/O. You may do PC emulator in style of Bochs, that is
    emulate common hardware. You may do BIOS emulator. You may
    do DOS emulator, that is emulate file I/O at DOS level. Or
    you may emulate different system. For example QEMU 386 emulates
    Linux system calls. If you want your emulator to be simple,
    you may define your own system calls (say using something like INT 0x80h), thing like open, close, read, write. Advantage is simplicity.
    Disadvantage is that large body of existing 8086 assembler programs
    assumes DOS environment and will not work with different system.


    Very good points. Thanks. You're right that the 8086 by itself only has
    in/out instructions, ESC instructions, and memory mapped IO, all of which depend on the rest of the system. It appears that the IBM BIOS operates
    at the very low level of clusters, heads, and sectors. But the DOS functions appear to map pretty closely to stdio.h functions. So that seems to be
    the easiest path forward.

    My goal at this stage is just to get some kind of read/write ability so the Forth interpreter can read Forth source from a file. So far, all my Forth code is written in a sort of "pre-compiled" form directly in the C code that implements the CPU emulator.

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Rod Pemberton@nomailings@nospicedham.trgzxcqvbe.cpm to comp.lang.asm.x86 on Thu May 27 02:07:55 2021
    From Newsgroup: comp.lang.asm.x86

    On Wed, 26 May 2021 15:33:53 -0700 (PDT)
    "luser...@nospicedham.gmail.com" <luser.droog@nospicedham.gmail.com>
    wrote:

    <follow ups set to comp.lang.forth, from comp.lang.asm.x86>

    My goal at this stage is just to get some kind of read/write ability
    so the Forth interpreter can read Forth source from a file. So far,
    all my Forth code is written in a sort of "pre-compiled" form
    directly in the C code that implements the CPU emulator.

    Since your Forth interpreter is coded in C, you might start by using
    custom Forth words for standard C file I/O functions. Over time, you
    could implement modern standard Forth words for loading a file, by
    transforming and rewriting the custom words, as these mostly match C's functionality. Personally, I'd avoid loading blocks of ancient text
    screens like fig-Forth, unless you already have the functionality.
    E.g., set an ANS Forth word like OPEN-FILE to C's fopen() so you can
    build other ANS Forth file I/O words like INCLUDED INCLUDE-FILE etc.
    You might be able to do this by setting the CFA for a primitive (or
    low-level Forth word) with the address of the C function E.g., if you
    have some Forth words coded in C (or assembly), you should be able to
    do this.

    http://lars.nocrew.org/dpans/dpans11.htm#11.6.1.1718
    --
    The SALT deduction is a kickback of taxes to wealthy people in wealthy
    states.

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From James Harris@james.harris.1@nospicedham.gmail.com to comp.lang.asm.x86 on Thu May 27 07:48:55 2021
    From Newsgroup: comp.lang.asm.x86

    On 26/05/2021 23:33, luser...@nospicedham.gmail.com wrote:
    On Monday, May 24, 2021 at 8:40:27 PM UTC-5, anti...@nospicedham.math.uni.wroc.pl wrote:
    luser...@nospicedham.gmail.com <luser...@nospicedham.gmail.com> wrote:

    ...

    Basic question is what do you want to emulate? 8086 by itself can not
    do file I/O. You may do PC emulator in style of Bochs, that is
    emulate common hardware. You may do BIOS emulator. You may
    do DOS emulator, that is emulate file I/O at DOS level. Or
    you may emulate different system. For example QEMU 386 emulates
    Linux system calls. If you want your emulator to be simple,
    you may define your own system calls (say using something like INT 0x80h), >> thing like open, close, read, write. Advantage is simplicity.
    Disadvantage is that large body of existing 8086 assembler programs
    assumes DOS environment and will not work with different system.


    Very good points. Thanks. You're right that the 8086 by itself only has in/out instructions, ESC instructions, and memory mapped IO, all of which depend on the rest of the system. It appears that the IBM BIOS operates
    at the very low level of clusters, heads, and sectors. But the DOS functions appear to map pretty closely to stdio.h functions. So that seems to be
    the easiest path forward.

    There's a guy on alt.os.development who has been posting about very much
    the same sorts of thing. Maybe there's value in the two of you getting
    in touch, if you aren't already.
    --
    James Harris

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From luser...@nospicedham.gmail.com@luser.droog@nospicedham.gmail.com to comp.lang.asm.x86 on Sat May 29 12:19:08 2021
    From Newsgroup: comp.lang.asm.x86

    On Thursday, May 27, 2021 at 2:02:52 AM UTC-5, James Harris wrote:
    On 26/05/2021 23:33, luser...@nospicedham.gmail.com wrote:

    Very good points. Thanks. You're right that the 8086 by itself only has in/out instructions, ESC instructions, and memory mapped IO, all of which depend on the rest of the system. It appears that the IBM BIOS operates
    at the very low level of clusters, heads, and sectors. But the DOS functions
    appear to map pretty closely to stdio.h functions. So that seems to be
    the easiest path forward.
    There's a guy on alt.os.development who has been posting about very much
    the same sorts of thing. Maybe there's value in the two of you getting
    in touch, if you aren't already.


    Thanks. I have read some of his postings in comp.lang.c and have just
    now started to browse some in AOD. We have a similar set of interests
    but diverge on many of the details. Eg. I'm using C99 tools[1] rather than C90 and targeting just 8086 for now. I still haven't implemented the full instruction set, just the ones initially required for the codegolf.stackexchange.com
    challenge and additional ones needed to get the Forth up and running.
    So, while we're both working in the same sort of space we're on different
    peaks of the mountain range.

    [1] I'm pretty much addicted to the C99 designated initializers and variable argument macros. I can't really imagine doing without those for hobby work.

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From luser...@nospicedham.gmail.com@luser.droog@nospicedham.gmail.com to comp.lang.asm.x86 on Thu Jun 17 18:35:40 2021
    From Newsgroup: comp.lang.asm.x86

    On Monday, May 24, 2021 at 1:22:49 AM UTC-5, luser...@nospicedham.gmail.com wrote:
    On Sunday, May 16, 2021 at 3:48:21 PM UTC-5, luser...@nospicedham.gmail.com wrote:
    Hello all,

    I'm planning to resume work on my partly written 8086 emulator after a long hiatus. I want to add the ability to read a file, but I'm having some difficulty
    [...]
    Is there a good resource to understand how this all should work?
    I suppose this isn't really related to assembly language. I've ordered Peter Norton's
    Guide to the IBM PC. I guess I'll post in comp.os.msdos.programmer if I run into
    trouble.

    For posterity, Norton's Guide really seems to be the perfect book to learn all about
    this stuff. It looks like I want to bypass DOS 1.0 stuff, too, and go straight for the DOS 2.0
    additions to have a file handle and less fiddly business.

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Frank Kotler@fbkotler@nospicedham.myfairpoint.net to comp.lang.asm.x86 on Sun Jul 4 01:11:10 2021
    From Newsgroup: comp.lang.asm.x86

    On 07/04/2021 12:17 AM, luser...@nospicedham.gmail.com wrote:
    ...
    I suppose this isn't really related to assembly language.

    No...

    I hate to chase you away, where you're doing low level stuff, but keep
    it in assembly, okay?

    If you post to multiple groups and I reject it, it won't post at all, so don't...

    Best,
    Frank
    {moderator}

    --- Synchronet 3.21d-Linux NewsLink 1.2