home .. forth .. colorforth mail list archive ..

[colorforth] Back and forth to machine code in blocks.


Hoy all,
In behalf of retroforth I have made a tool (parse/unparse)
that converts machine code in blocks (actually linux files)
into assembler code and back.

A similar tool could be had for colorforth, if there is interest.
An other option is to port the miniassembler to colorforth.
(it is 6 screens for a 386 assembler without the sib stuff,
7 screens with sib.) Then the machine code could be replaced
in  the colorforth screens by assembler code.

I think it will not be necessary to have the assembler permanently 
loaded. It could be used at startup to copy screens with 
assembler code to screens with machine code. So actual usage 
would be the same as in the current situation. This is assuming
sufficient screens are present. With the switch from floppies to
USB sticks that should not be a problem.

Example: screen 0 of retroforth
---------------------------------------------

forth : swap [ $0687 2, ] ;
: drop [ $ad 1, ] ;
: dup [ $fc4689 3, $fc768d 3, ] ;
: nip swap drop ;
: and [ $0623 2, ] nip ;
: or [ $060b 2, ] nip ;
: xor [ $0633 2, ] nip ;
: >> [ $c189 2, $ad 1, $e8d3 2, ] ;
: not -1 xor ;
: @ [ $008b 2, ] ;
: ! [ $c289 2, $ad 1, $0289 2, $ad 1, ] ;
: c@ @ $ff and ;
: c! [ $c289 2, ] drop [ $0288 2, ] drop ;
: + [ $0603 2, ] nip ;
: * [ $26f7 2, ] nip ;
: negate -1 * ;
: - negate + ;
: / [ $c389 2, $ad 1, $99 1, $fbf7 2, ] ;
: mod / [ $d089 2, ] ;
-------------------------------------------------

forth : swap [ { 
   XCHG, X| AX'| ZO| [SI] 
} ] ;
: drop [ { 
   LODS, X'| 
} ] ;
: dup [ { 
   MOV, X| F| AX'| BO| [SI] 0000,00FC B, 
   LEA, SI'| BO| [SI] 0000,00FC B, 
} ] ;
: nip swap drop ;
: and [ { 
   AND, X| T| AX'| ZO| [SI] 
} ] nip ;
: or [ { 
   OR, X| T| AX'| ZO| [SI] 
} ] nip ;
: xor [ { 
   XOR, X| T| AX'| ZO| [SI] 
} ] nip ;
: >> [ { 
   MOV, X| F| AX'| R| CX| 
   LODS, X'| 
   SHR, V| X| R| AX| 
} ] ;
: not -1 xor ;
: @ [ { 
   MOV, X| T| AX'| ZO| [AX] 
} ] ;
: ! [ { 
   MOV, X| F| AX'| R| DX| 
   LODS, X'| 
   MOV, X| F| AX'| ZO| [DX] 
   LODS, X'| 
} ] ;
: c@ @ $ff and ;
: c! [ { 
   MOV, X| F| AX'| R| DX| 
} ] drop [ { 
   MOV, B| F| AL'| ZO| [DX] 
} ] drop ;
: + [ { 
   ADD, X| T| AX'| ZO| [SI] 
} ] nip ;
: * [ { 
   MUL|AD, X| ZO| [SI] 
} ] nip ;
: negate -1 * ;
: - negate + ;
: / [ { 
   MOV, X| F| AX'| R| BX| 
   LODS, X'| 
   CWD, 
   IDIV|AD, X| R| BX| 
} ] ;
: mod / [ { 
   MOV, X| F| DX'| R| AX| 
} ] ;
---------------------------------------------------------------
X| w/l   F| T| from/to primed register
R| register  ZO| BO| XO| zero byte w/l offset

More information in forthassembler.html at the url in my signature.

-- 
Albert van der Horst,Oranjestr 8,3511 RA UTRECHT,THE NETHERLANDS
        One man-hour to invent,
                One man-week to implement,
                        One lawyer-year to patent.
albert@xxxxxxxxxxxxxxxxxx http://home.hccnet.nl/a.w.m.van.der.horst

---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com