OkadWork.cf disassembled

View: New views
3 Messages — Rating Filter:   Alert me  

OkadWork.cf disassembled

by John Comeau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For those of you itching to get a native-booting version of
OkadWork.cf, and haven't been able to make a disassembly that reliably
reassembles back to the boot code of OkadWork, check out
http://unternet.net/cf2/. I'm not sure I got the non-code sections all
separated out, but I've verified that the disassembly made with
Albert's cidis compiles to an identical binary (.bin vs .cfboot) using
cias. So as long as you change code in such a way as not to mess up
any offsets, by making your changes fit the same space as the original
code (check with cmp -l, as in the Makefile), you can test different
video modes and such. Thanks to Albert van der Horst for the new
release of ciasdis!

For those to whom all of this is gobbledygook: OkadWork.cf is the
latest version of ColorForth, released by Intellasys in 2008,
superceding the 2001 binary from colorforth.com and the 2005 binary
contributed by Jeff Fox. The programs "cias" and "cidis" are the
"computer intelligence" tools from Albert van der Horst, symlinks to
ciasdis. They assemble and disassemble 80x86 code in a symmetric
manner, such that what you disassemble can be reliably reassembled to
every exact bit and byte. The syntax takes some getting used to, but
is well documented in the Lina (ciforth for linux) postscript and PDF
docfiles.

If you're still lost: make some effort to see what's going on, then
reply to me or to the list with specific questions. Thanks!
--
John Comeau <jc@...> http://jc.unternet.net/
"A place for everything, and everything
all over the place"

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


Re: OkadWork.cf disassembled

by Nick Maroudas-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Many thanks, John.
Baie dankies, Albert.

Caritas,

Nick



Quoting John Comeau <jc@...>:

>... " For those of you itching to get a native-booting version
>... " of
>... " OkadWork.cf, and haven't been able to make a disassembly
>... " that reliably
>... " reassembles back to the boot code of OkadWork, check
>... " out
>... " http://unternet.net/cf2/. I'm not sure I got the
>... " non-code sections all
>... " separated out, but I've verified that the disassembly
>... " made with
>... " Albert's cidis compiles to an identical binary (.bin vs
>... " .cfboot) using
>... " cias. So as long as you change code in such a way as not
>... " to mess up
>... " any offsets, by making your changes fit the same space
>... " as the original
>... " code (check with cmp -l, as in the Makefile), you can
>... " test different
>... " video modes and such. Thanks to Albert van der Horst for
>... " the new
>... " release of ciasdis!
>... "
>... " For those to whom all of this is gobbledygook:
>... " OkadWork.cf is the
>... " latest version of ColorForth, released by Intellasys in
>... " 2008,
>... " superceding the 2001 binary from colorforth.com and the
>... " 2005 binary
>... " contributed by Jeff Fox. The programs "cias" and "cidis"
>... " are the
>... " "computer intelligence" tools from Albert van der Horst,
>... " symlinks to
>... " ciasdis. They assemble and disassemble 80x86 code in a
>... " symmetric
>... " manner, such that what you disassemble can be reliably
>... " reassembled to
>... " every exact bit and byte. The syntax takes some getting
>... " used to, but
>... " is well documented in the Lina (ciforth for linux)
>... " postscript and PDF
>... " docfiles.
>... "
>... " If you're still lost: make some effort to see what's
>... " going on, then
>... " reply to me or to the list with specific questions.
>... " Thanks!
>... " --
>... " John Comeau <jc@...> http://jc.unternet.net/
>... " "A place for everything, and everything
>... " all over the place"
>... "
>... " ... " Main web page - http://www.colorforth.com
>... "
>... "


--
Dr Nicolas George Maroudas
Avigdor Meiri 9/1
Sea View
Haifa 3 55 00
Israel
Tel +972 048 337 315

****************************

Capital stocks dip to record lows. Sales of Das Kapital zoom to
all time high. Economists change paradigm. - News

****

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


Re: OkadWork.cf disassembled

by Albert van der Horst :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Mar 04, 2009 at 04:03:03PM -0700, John Comeau wrote:

> For those of you itching to get a native-booting version of
> OkadWork.cf, and haven't been able to make a disassembly that reliably
> reassembles back to the boot code of OkadWork, check out
> http://unternet.net/cf2/. I'm not sure I got the non-code sections all
> separated out, but I've verified that the disassembly made with
> Albert's cidis compiles to an identical binary (.bin vs .cfboot) using
> cias. So as long as you change code in such a way as not to mess up
> any offsets, by making your changes fit the same space as the original
> code (check with cmp -l, as in the Makefile), you can test different
> video modes and such. Thanks to Albert van der Horst for the new
> release of ciasdis!
>

Maybe I should elaborate a bit more about how I disassembled colorforth.
(It is based on a table driven Forth assembler using my PostIt FixUp
principle. The tables are reused to disassemble).

I had added a special disassembler for the table ForthHuff.
It takes a 32-bit cell, interpret it as a colorword string.
Then reassemblable code is to be read as
  ( lay down longs: ) dl  ( Get a string: )       S" boot"
( "boot" is ciforth idiom)
      ( adr len -- cw ) (convert it to a colorword.) >CN

The ForthXT must be analysed in parallel.
It contains execution addresses, and they are added as labels with names
derived from the colornames.

A third thing is done. The execution addresses are executable code.
So we can "crawl" from that address until an unconditional transfer is
done (jump or return).

So this is how it looked, a long time ago.

colorcm-1.41.dis

( 0000,09E0 )   :ForthHuff   dl "boot" >CN "warm" >CN "pause" >CN "macro" >CN
( 0000,09F0 )                 dl "forth" >CN "c" >CN "stop" >CN "read" >CN
( 0000,0A00 )                 dl "write" >CN "nc" >CN "comman" >CN "seek" >CN

...

( 0000,14E4 )   :ForthXT   dl X_boot X_warm X_pause X_macro
(                           0,1DD0 L, ......)
( 0000,14F4 )                 dl X_forth X_c X_stop X_read
( 0000,1504 )                 dl X_write X_nc X_comman X_seek

...

( 0000,1DD0 )   :X_boot    MOVI|B, AL| L0000,00F6 8 + IB,
( 0000,1DD2 )                  OUT|P, B'| #CHARS 4 + P,
( 0000,1DD4 )   :L0000,1DD4    JMPS, L0000,1DD4 RB,
( 0000,1DD6 )   :X_erase    MOV, X| T| CX'| R| AX|
( 0000,1DD8 )                  SHLI, X| R| CX| 8 IS,
( 0000,1DDB )                  LODS, X'|
( 0000,1DDC )                  PUSH|X, DI|
( 0000,1DDD )                  MOV, X| T| DI'| R| AX|
( 0000,1DDF )                  SHLI, X| R| DI| 0A IS,
( 0000,1DE2 )                  XOR, X| T| AX'| R| AX|
( 0000,1DE4 )                  REPZ,
( 0000,1DE5 )                  STOS, X'|
( 0000,1DE6 )                  POP|X, DI|
( 0000,1DE7 )                  LODS, X'|
( 0000,1DE8 )                  RET,


Now in colorcm-1.58.dis the disassembly is more advanced and the casual
observer may think that both tables have disappeared because they are no
no longer apparent in the disassembly.
Instead the tables are generated as separate sections.

This is done by the word : HEADER .

\ Forth header for "name".
\ Add execution address and colorname to appropriate segments.^H^H^Hsection.
: HEADER   _AP_ ForthXT: AS-,   (WORD) >CN ForthHuff: AS-,   DEFAULT: ;

...

HEADER boot
( 0000,1DD0 )   :X_boot    MOVI|B, AL| -2 IB,
( 0000,1DD2 )                  OUT|P, B'| +64 P,
( 0000,1DD4 )   :L0000,1DD4    JMPS, L0000,1DD4 RB,

...

HEADER erase
( 0000,1DD6 )   :X_erase    MOV, X| T| CX'| R| AX|
( 0000,1DD8 )                  SHLI, X| R| CX| +8 IS,
( 0000,1DDB )                  LODS, X'|
( 0000,1DDC )                  PUSH|X, DI|


HEADER is to be read as follows:

Get the current code pointer
switch to the execution table (a section)
Comma the address into that assembler section

Get a name from the input stream
Make it into a Hufman name
switch to the Huffman table (a section)
Comma the H-name into that assembler section

Switch back to the default (code) section.

o-O-o

It is clear that it now becomes impossible to have the
parallel tables misaligned. Furthermore the code can
be rearranged with impunity.

(With a    2DUP _AP_ LABELED   I could have eliminated
even the  :X_boot   labels, but it is not clear whether
that would be an improvement. One might want to look for
:X_boot to find where the label is defined.)


--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

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