Low-Level I/O Primitives for GFORTH (for DOS) 
Author Message
 Low-Level I/O Primitives for GFORTH (for DOS)

What is the simplest way to implement words for I/O in GFORTH for DOS?

I understand that you can create code words using , and C, -- does
this assume that I have included CODE.FS -- and does GFORTH for DOS
use BX for TOS.?  (I see the target compiler model does, as in
my directory C:/GFORTH.040/ARCH/8086/PRIM.FS )

I think I have two words, but not sure how to load the assembler.
Even if I did load the assembler, I'd rather not have to if I can
code the words using , and C,

But if I need to, (assuming I figure out how to load the assembler,)
I can code them once, then DUMP the word, then recode using C, entering
hexadecimal bytes of machine code.

My best guess for these words (not tested), assuming BX=TOS is:


    TOS DX MOV,
    AL DX IN,
    0 # AH MOV,
    AX TOS MOV,
    NEXT,
END-CODE

CODE P!  ( n p -- )
    TOS DX MOV,
    AX POP,
    AL DX OUT,
    TOS POP,
    NEXT,
END-CODE

To translate to pure machine code (if necessary), I would need to
know for sure if BX is in fact TOS in GFORTH for DOS.

Do you think the code shown above will work?  And how can I load
the assembler in GFORTH for DOS, or what would be the best way to
code these words?  All comments are welcome.

--
Douglas Beattie Jr.       http://www.*-*-*.com/ ~beattidp/



Thu, 01 Aug 2002 03:00:00 GMT  
 Low-Level I/O Primitives for GFORTH (for DOS)


Quote:
>What is the simplest way to implement words for I/O in GFORTH for DOS?

>I understand that you can create code words using , and C, -- does
>this assume that I have included CODE.FS -- and does GFORTH for DOS
>use BX for TOS.?  (I see the target compiler model does, as in
>my directory C:/GFORTH.040/ARCH/8086/PRIM.FS )

Gforth for DOS is a 32-bit system running on top of a DOS-extender
(GO32 in the binary distribution).  The actual register allocation
depends on the compiler and configuration options used when building
Gforth.  Disassemble some words to see what's happening.  AFAIK the
binary distribution of gforth-0.4.0 for DOS does not keep the TOS is a
register.  If the distribution was build with -enable-force-reg, you
can find the allocation of some registers at the end of
arch/386/machine.h.

Quote:
>I think I have two words, but not sure how to load the assembler.
>Even if I did load the assembler, I'd rather not have to if I can
>code the words using , and C,

code.fs is not the assembler, it contains just CODE, END-CODE etc.
Laying down the machine code with , and C, works.

You can use Jim Schneider's or Andrew McKewan's 386 assembler (I hope
to integrate the latter for the next release), but they need some
tweaking to work.  For a disassembler try Andrew McKewan's.

Quote:
>My best guess for these words (not tested), assuming BX=TOS is:


>    TOS DX MOV,
>    AL DX IN,
>    0 # AH MOV,
>    AX TOS MOV,
>    NEXT,
>END-CODE

You will certainly need 386 code.

- anton
--
M. Anton Ertl                    Some things have to be seen to be believed

http://www.complang.tuwien.ac.at/anton/home.html



Sat, 03 Aug 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Really Low Low Low Level Stuff.

2. os low-level question

3. books dealing with low level I/Os?

4. Low-level programming, non-DOS?

5. PC Non-DOS low-level programming?

6. Low-level disk i/o in DOS

7. Low level features in GNAT on DOS?

8. High Level ASM and Low Level ASM

9. os.popen results differ when run in browser and DOS level

10. Gate level primitives in IEEE 1364 Verilog standard...

11. Primitives and structural level modeling qn!

12. GForth On Mac OS-X

 

 
Powered by phpBB® Forum Software