you'll think I'm crazy, but...
[1/3] from: rishi::picostar::com at: 29-Oct-2000 12:33
I was wondering if it would be possible to create a sparc assemby dialect for rebol.
It would be useful for prototyping assembly code for my assembly class (without need
a sparc machine or assembler).
Rishi
[2/3] from: al:bri:xtra at: 30-Oct-2000 9:10
Rishi Oswal wrote:
> I was wondering if it would be possible to create a sparc assemby dialect for rebol.
It would be useful for prototyping assembly code for my assembly class (without need
a sparc machine or assembler).
That would definitely be possible in Rebol. You can even create the binary file to directly
run the code, or even create an emulator to run the assembler code. It would be a lot
of work, though, but would mean you'll get top marks for your class.
Andrew Martin
[3/3] from: chaz:innocent at: 29-Oct-2000 13:45
Not a crazy thing at all.
A person (Marcus Petersson <[d4marcus--dtek--chalmers--se]>) on another mailing
list that I subscribed to (KOSH - Kommunity Operation System and Hardware)
has created an implementation of the KOSH Simple Virtual Machine (SVM) in
REBOL. Its "assembly language" is a REBOL dialect.
This is from his readme
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
Installation
------------
Put the files wherever you want. Start Rebol.
Type "do %svm.r" including
relative path to load svm.r.
Usage
-----
There
are (ATM) four user functions. Although nothing stops you from
accessing
other functions or variables, you shouldn't need to. Since
everything is packed
within one large object, you will have to precede
every command by "svm/".
- svm/regs:
Prints a nice table showing the
contents of all registers.
- svm/clear-regs:
Reset all registers to
zero.
- svm/parse-i:
The main function. Trims the code and parses it. It
is used by parse-file, but
you can use it directly. The input should be a
string containing at least one
correct instruction. If parse-i finds a bad
instruction, it stops and reports
the name. Not very helpful I guess, but
it will do for now. Otherwise it runs
until the end and says ok.
The
syntax of the instructions (Rebol is case-insensitive by default):
name
operands (opt data)
Operands are on the form $0 up to $f. Data is
on the form #0123cdef for hex, or
19123695 for integer. For example:
inc
$0
ori $4, #00000066
xori $5,
100
notand $9, $6
addi $1, $0, 20
shifti
$e, $e, #00000002
mod $4, $b, $0
-
svm/parse-file:
Wants a filename as argument. This file is read and passed
as a string to
parse-i. Example: "svm/parse-file
%svm1"
svm/clone-file:
Wants two filenames (infile outfile) and an integer
(times) as argument. The
infile is read and copied times times to a buffer,
which is then written to the
outfile. A large file of code can be useful to
test the speed.
Todo
----
There are 7 instructions that aren't handled:
tls and tlsi: Because implementing binary data types in Rebol is
complicated.
tls, loadi, load, storei, store: Needs some form of simulated
memory. It would
be cool to read instructions (in binary form) from the
memory as well. This
also require a pc and an instruction fetcher and
decoder.
branch: Also require memory and pc.
The memory concept is
interesting. The parse function would, instead of running
the instructions
directly for asm, translate them from asm to binary format.
Another
function, possibly the memory handler, would load the code into the
memory.
Then a decode function would fetch and decode the binaries from the
adress
which is pc's value. One function could run the code continously,
yet
another could step through it. Supposedly you could read and write
binary code
to disk too.
After all the above works, perhaps we could
simulate cacheing, virtual memory,
interrupts and timers. Then we could
build a bus, and hook some simulated
hardware to it. Maybe we could let a
Rebol/View window change colors according
to the data in the "graphics
card". :-)
Bugs
----
Plenty. If you follow the usage guide, I hope you
won't trip over too many.
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
Here's his response to my suggestion that he post it here.
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
on Sat, 28 Oct 2000, chaz wrote:
> This is great! Makes one wonder what would happen if you added a little
> introduction to the aims of kosh, and crossposted this to
[rebol-list--rebol--com]
Uhmm no. This certainly isn't anything that would interest people in
general. Not to metion I would get bashed, first for crossposting, then
for writing lousy Rebol code. :-(
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
If you're interested, you can contact him directly or subscribe to the KOSH
list.
To subscribe to the mailing list, send a mail to
[MDaemon--chaossolutions--org]
with:
subscribe kosh
as the only line in the body. You will then receive an authorisation mail -
reply without changing it. You're subscribed when you receive the list
welcome mail.
chaz
At 12:33 PM 10/29/00 +0000, you wrote:
>I was wondering if it would be possible to create a sparc assemby dialect
for rebol. It would be useful for prototyping assembly code for my assembly
class (without need a sparc machine or assembler).