\ scasm32.f ... \ assembler for SC32 in JForth \ 1989 jack j. woehr \ permission to distribute and use freely granted \ to Forth Interest Group MEMBERS ONLY !!! \ pay yer dues, cheapskate! \ and attend your local FIG Chapter regularly! \ jax@well.UUCP JAX on GEnie \ Minimal instruction assembler written in JForth for the Johns Hopkins \ JPL 32-bit stack machine known as the SC32. \ references: \ 3m SC32 Prelim Silicon Composers, Inc., 32-Bit \ Stack-Chip Microprocessor Preliminary, \ 4/12/89. \ 1989, Silicon Composers, Palo Alto, CA \ 24 April 1989 \ \ Dr. George Nichol \ Silicon Composers, Inc. \ 210 California Ave., \ Suite K \ Palo Alto, CA 94306 \ \ \ Dear George, \ \ Thank you for the prompt delivery of the preliminary document \ on the SC32, dated 4/12/89. On the basis of this document, this \ weekend I tossed together a minimal but complete instruction \ cross-assembler for the SC32 in JForth ( A JSR-Threaded Forth \ running on the Amiga), a printout of which I enclose for your \ amusement. Its "Forthish" assembly syntax basically runs like this: \ \ ... \ \ followed by a comma ( , ) which is redefined to compile to the target \ buffer, which latter may be saved to a file. \ \ [ Examples: \ \ CALL 1234567 ADDRESS , \ \ ALU/SHIFT NEXT U3 SOURCE S0 DEST PUSHS-POPR STACK 0 CIN DSTabs [ buff-hdr-size buff-size + ] literal [ forth ] call exec_lib freemem drop [ scasm32 ] ; : free-all-buffers \ --- 1st-buffer @ begin dup @ swap free-buffer dup 0= until drop ; : get-1st-buffer \ --- get-buffer dup if >rel dup 1st-buffer ! last-buffer ! else true buff-err? then ; : get-subsequent-buffer \ --- get-buffer dup if >rel dup last-buffer @ ! last-buffer ! else true buff-err? then ; : manage-buffers \ --- here (there) 0= here 0> and if get-subsequent-buffer then ; \ *** Output File Handling create out-filename 100 allot variable out-fileptr variable outfile-buff : outfile-err? \ t|f --- abort" Couldn't Open Output File" ; : writefile-err? \ t|f --- abort" Error While Writing Output File" ; : out-filename.default \ --- 0" ram:scasm32.out" 0count 1+ out-filename swap cmove ; : open-outfile \ --- \ what the heck is going on here? out-filename new 0fopen dup out-fileptr ! 0= outfile-err? out-fileptr @ fclose out-filename 0fopen dup 0= outfile-err? out-fileptr ! ; : close-outfile \ --- out-fileptr @ fclose ; : (get-outfile-buff) \ --- 0|abs_addr here MEMF_CLEAR [ forth ] exec? call exec_lib allocmem [ scasm32 ] ; : get-outfile-buff \ --- (get-outfile-buff) dup 0= abort" Couldn't Get Outfile Buff" >rel outfile-buff ! ; : free-outfile-buff \ --- outfile-buff @ >abs here [ forth ] call exec_lib freemem drop [ scasm32 ] ; : fill-outfile-buff \ --- here buff-size /mod \ how many 4k buffs to consolidate? outfile-buff @ \ get the file buffer 1st-buffer @ rot \ get the first asm buffer 0 do \ JForth DO is a ?DO dup buff-hdr-size + \ move to data area 2 pick \ get file buffer address buff-size cmove> \ move data @ swap buff-size + swap \ get next data buff, inc file buff adr loop rot dup \ is there a modulus remaining? if \ yes, copy rest of data swap buff-hdr-size + -rot cmove> else 2drop drop \ drop data-adr filebuf-adr 0ct then ; : write-outfile \ --- out-fileptr @ outfile-buff @ here fwrite 0= abort" Error Writing Assembly to File" ; : save-assembly \ --- open-outfile get-outfile-buff fill-outfile-buff write-outfile close-outfile free-outfile-buff ; \ *** Assemble to Memory \ all SC32 operands are longwords : , \ longword --- manage-buffers here there ! 4 asm-ptr +! ; \ *** Initialization : scasm32.init \ --- scasm32 get-1st-buffer asm-ptr.init out-filename.default ; : wrapup \ --- save-assembly free-all-buffers ; decimal