aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/msp430/drivers/fram/words
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-08-19 12:15:28 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-08-19 12:15:28 +0200
commit67d25d837ac55f28a366c0a3b262e439a6e75fc3 (patch)
treedf7715c7724c5935ab87c807f3b8b4ef529315e3 /amforth-6.5/msp430/drivers/fram/words
parente0d6784e89dba33226c0edb815bb974486fa7c48 (diff)
Add AmForth
Diffstat (limited to 'amforth-6.5/msp430/drivers/fram/words')
-rw-r--r--amforth-6.5/msp430/drivers/fram/words/d-to-i.asm37
-rw-r--r--amforth-6.5/msp430/drivers/fram/words/flaligned.asm4
-rw-r--r--amforth-6.5/msp430/drivers/fram/words/i-store.asm10
-rw-r--r--amforth-6.5/msp430/drivers/fram/words/ic-store.asm10
-rw-r--r--amforth-6.5/msp430/drivers/fram/words/init-ram.asm16
-rw-r--r--amforth-6.5/msp430/drivers/fram/words/save.asm7
-rw-r--r--amforth-6.5/msp430/drivers/fram/words/scrub.asm6
7 files changed, 90 insertions, 0 deletions
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