From 67d25d837ac55f28a366c0a3b262e439a6e75fc3 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 19 Aug 2017 12:15:28 +0200 Subject: Add AmForth --- amforth-6.5/msp430/drivers/fram/words/d-to-i.asm | 37 ++++++++++++++++++++++ .../msp430/drivers/fram/words/flaligned.asm | 4 +++ amforth-6.5/msp430/drivers/fram/words/i-store.asm | 10 ++++++ amforth-6.5/msp430/drivers/fram/words/ic-store.asm | 10 ++++++ amforth-6.5/msp430/drivers/fram/words/init-ram.asm | 16 ++++++++++ amforth-6.5/msp430/drivers/fram/words/save.asm | 7 ++++ amforth-6.5/msp430/drivers/fram/words/scrub.asm | 6 ++++ 7 files changed, 90 insertions(+) create mode 100644 amforth-6.5/msp430/drivers/fram/words/d-to-i.asm create mode 100644 amforth-6.5/msp430/drivers/fram/words/flaligned.asm create mode 100644 amforth-6.5/msp430/drivers/fram/words/i-store.asm create mode 100644 amforth-6.5/msp430/drivers/fram/words/ic-store.asm create mode 100644 amforth-6.5/msp430/drivers/fram/words/init-ram.asm create mode 100644 amforth-6.5/msp430/drivers/fram/words/save.asm create mode 100644 amforth-6.5/msp430/drivers/fram/words/scrub.asm (limited to 'amforth-6.5/msp430/drivers/fram/words') diff --git a/amforth-6.5/msp430/drivers/fram/words/d-to-i.asm b/amforth-6.5/msp430/drivers/fram/words/d-to-i.asm new file mode 100644 index 0000000..fdc7ef7 --- /dev/null +++ b/amforth-6.5/msp430/drivers/fram/words/d-to-i.asm @@ -0,0 +1,37 @@ +;Z D->I c-addr1 c-addr2 u -- move Data->Code +; Block move from Data space to Code space. Flashable. +; For the MSP430, this uses a "smart" algorithm that uses word writes, +; rather than byte writes, whenever possible. Note that byte reads +; are used for the source, so it need not be aligned. + CODEHEADER(XT_DTOI,4,"d->i") + MOV @PSP+,W ; dest adrs + MOV @PSP+,X ; src adrs + CMP #0,TOS + JZ DTOI_X +DTOI_LOOP: ; Begin flash write sequence + DINT ; Disable interrupts + mov #0A500h, &MPUCTL0 ; Enable write access by disabling MPU + ; If length is 1, or dest. address is odd, do a byte write. + ; Else, do a word write. + CMP #1,TOS + JZ DTOI_BYTE + BIT #1,W + JNZ DTOI_BYTE +DTOI_WORD: MOV.B @X+,Y ; get low byte of word + MOV.B @X+,Q ; get high byte of word + SWPB Q + BIS Q,Y ; merge bytes + MOV Y,0(W) ; write byte to dest + ADD #2,W + SUB #1,TOS ; another 1 will be subtracted below + JMP DTOI_END +DTOI_BYTE: MOV.B @X+,0(W) ; copy byte from src to dest + ADD #1,W +DTOI_END: ; End flash write sequence + mov #0A501h, &MPUCTL0 ; Disable write access again + mov.b #0, &MPUCTL0+1 ; Disable MPU access + EINT ; Enable interrupts + SUB #1,TOS + JNZ DTOI_LOOP +DTOI_X: MOV @PSP+,TOS ; pop new TOS + NEXT diff --git a/amforth-6.5/msp430/drivers/fram/words/flaligned.asm b/amforth-6.5/msp430/drivers/fram/words/flaligned.asm new file mode 100644 index 0000000..9271eba --- /dev/null +++ b/amforth-6.5/msp430/drivers/fram/words/flaligned.asm @@ -0,0 +1,4 @@ +;Z FLALIGNED a -- a' align IDP to flash boundary +; $200 OVER - $1FF AND + ; + HEADER(XT_FLALIGNED,9,"flaligned",DOCOLON) + DW XT_DOLITERAL,0200h,XT_OVER,XT_MINUS,XT_DOLITERAL,01FFh,XT_AND,XT_PLUS,XT_EXIT diff --git a/amforth-6.5/msp430/drivers/fram/words/i-store.asm b/amforth-6.5/msp430/drivers/fram/words/i-store.asm new file mode 100644 index 0000000..c4de731 --- /dev/null +++ b/amforth-6.5/msp430/drivers/fram/words/i-store.asm @@ -0,0 +1,10 @@ +;Z I! x a-addr -- store cell in Instruction memory + CODEHEADER(XT_STOREI,2,"!i") + + mov #0A500h, &MPUCTL0 ; Enable write access by disabling MPU + MOV @PSP+,0(TOS) + MOV @PSP+,TOS + mov #0A501h, &MPUCTL0 ; Disable write access again + mov.b #0, &MPUCTL0+1 ; Disable MPU access + + NEXT diff --git a/amforth-6.5/msp430/drivers/fram/words/ic-store.asm b/amforth-6.5/msp430/drivers/fram/words/ic-store.asm new file mode 100644 index 0000000..dee4575 --- /dev/null +++ b/amforth-6.5/msp430/drivers/fram/words/ic-store.asm @@ -0,0 +1,10 @@ +;Z IC! x a-addr -- store char in Instruction memory + CODEHEADER(XT_CSTOREI,3,"c!i") + + mov #0A500h, &MPUCTL0 ; Enable write access by disabling MPU + MOV @PSP+,W + MOV.B W,0(TOS) + MOV @PSP+,TOS + + mov #0A501h, &MPUCTL0 ; Disable write access again + mov.b #0, &MPUCTL0+1 ; Disable MPU access diff --git a/amforth-6.5/msp430/drivers/fram/words/init-ram.asm b/amforth-6.5/msp430/drivers/fram/words/init-ram.asm new file mode 100644 index 0000000..30fab64 --- /dev/null +++ b/amforth-6.5/msp430/drivers/fram/words/init-ram.asm @@ -0,0 +1,16 @@ +;Z INIT_RAM -- initialize RAM +HEADER(XT_INIT_RAM,8,"init-ram",DOCOLON) +; the first cell is either FFFF or the recognizer stack depth, see ram.asm + DW XT_DOLITERAL, INFOSTART, XT_FETCH + DW XT_ZEROLESS + DW XT_DOCONDBRANCH + DEST(COLD1) +; there is no valid data in INFO flash + DW XT_UINIT,XT_DOBRANCH + DEST(COLD2) +COLD1: +; there is valid content in INFO, restore it + DW XT_DOLITERAL, INFOSTART +COLD2: + DW XT_DOLITERAL,RAMINFOAREA,XT_DOLITERAL,INFO_SIZE,XT_CMOVE + dw XT_EXIT diff --git a/amforth-6.5/msp430/drivers/fram/words/save.asm b/amforth-6.5/msp430/drivers/fram/words/save.asm new file mode 100644 index 0000000..96d2f0b --- /dev/null +++ b/amforth-6.5/msp430/drivers/fram/words/save.asm @@ -0,0 +1,7 @@ +; SAVE erases the first 128 bytes of Info Flash, then +; copies the User Area and subsequent RAM variables there. + HEADER(SAVE,4,"SAVE",DOCOLON) + DW XT_DOLITERAL,RAMINFOAREA + DW XT_DOLITERAL,INFOSTART + DW XT_DOLITERAL,INFO_SIZE + DW XT_DTOI,XT_EXIT diff --git a/amforth-6.5/msp430/drivers/fram/words/scrub.asm b/amforth-6.5/msp430/drivers/fram/words/scrub.asm new file mode 100644 index 0000000..85fbe22 --- /dev/null +++ b/amforth-6.5/msp430/drivers/fram/words/scrub.asm @@ -0,0 +1,6 @@ +; SCRUB erases the application area of the Program Flash, +; and then does COLD to reset the User Variables. + HEADER(SCRUB,5,"SCRUB",DOCOLON) + DW XT_DOLITERAL,INFOSTART,XT_DOLITERAL,INFO_SIZE,FLERASE + DW XT_DOLITERAL,FLASHSTART,XT_DOLITERAL,(FLASHEND-FLASHSTART),FLERASE + DW XT_COLD,XT_EXIT -- cgit v1.2.3