none albert
unread,Mar 28, 2023, 9:52:02 AM3/28/23You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Going from an arm source file to a risc source file,
a lot of changes can be made automatically. This is on top
of changes that are taken care of by the macro processor m4.
ciforth/lina supports interpretation, compilation and scripting.
A compiled lina with facilities inherits the scripting
capabilities from lina itself. Think of refilter as a
fat Forth.
No explanation, but here is an impression of how it looks like.
In furderance of a discussion about the usability of reg. expr.
Also to make an argument that if you can't use it to replace
reg. expr. become virtually useless.
Note: GLOBAL replaces the first string constant (interpreted
as regexp) for the second string constant (where \# denotes
arguments found in the first.
" is a collated S"
--------------------------------------------
#!/home/albert/bin/refilter -s
\ $Id: blocksfilter,v 1.7 2014/11/14 20:13:06 albert Exp albert $
\ Migrate from ARM to riscv.
\
CREATE BUFFIE 1,000,000 ALLOT
BUFFIE FAR-DP !
ARGC 3 <> IF
"
Filter to get ARM->RISCV names as used in the ciforth system.
The names to replace them into are had from the m4 macro's.
Two arguments are needed:
1. input file
2. output file
" ETYPE BYE
THEN
\ The characters that can be part of an assembler "word".
\ Associated with < > pairs.
&n CHAR-SET \n
&Z 1+ &A DO I OVER SET-BIT LOOP
&z 1+ &a DO I OVER SET-BIT LOOP
&9 1+ &0 DO I OVER SET-BIT LOOP
\w COPY-SET
WANT DUMP
\w 100 DUMP
: GLOBAL GLOBAL .S ; \ If you want to debug
1 ARG[] GET-FILE
\ These mnemonic are to be changed.
"<LDR>(.*)\[(.*)\]" "LD\10(\2)" GLOBAL
"<LDR>" "LD" GLOBAL
"<STR>(.*)\[(.*)\]" "SD\10(\2)" GLOBAL
"<STR>" "SD" GLOBAL
"<ADD>(.*#.*)" "ADDI\1" GLOBAL
"<ORR>(.*#.*)" "ORI\1" GLOBAL
"<ORR>([^#]*)" "OR\1" GLOBAL
"<EOR>(.*#.*)" "XORI\1" GLOBAL
"<EOR>([^#]*)" "XOR\1" GLOBAL
"<BX>" "JALR" GLOBAL
"<ADR>" "LA" GLOBAL
"<ANDS>" "AND" GLOBAL
"#[^\n""]*" "" GLOBAL
\ Approved:
"#[^""\n]*\n" "\n" GLOBAL
" *\n" "\n" GLOBAL
"[\n]+" "\n" GLOBAL
"/\*[^\*]*\n" "/\*" GLOBAL
"/\*.* \*/" "" GLOBAL
"<MOV>" "MV" GLOBAL
"<MOVI>([^#]*)#" "LI\1" GLOBAL
2 ARG[] PUT-FILE
--------------------------------------------
Enjoy!
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -