Skip to content

Commit

Permalink
#295 extended memory access with FC@ and FC!
Browse files Browse the repository at this point in the history
  • Loading branch information
TG9541 committed Jul 26, 2020
1 parent a9e1b61 commit 911d4ae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/FC!
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\ STM8eForth : FC! TG9541-200726
\ ------------------------------------------------------------------------------

\ store char c to far address ah:al
: FC! ( c al ah -- ) [
\ Note: creates/executes LDF A,ah:al + RET code on the Data Stack
$A6BD , \ LD A,#0xBD ; Opcode LDF ExtAddr,A
$F7 C, \ LD (X),A ; MSB of ah (instead of "0")
$A681 , \ LD A,#0x81 ; Opcode RET
$E704 , \ LD (4,X),A ; MSB of C (instead of "0")
$E605 , \ LD A,(5,X) ; load C
$FD C, \ CALL (X) ; execute LDF
$1C C, $0006 , \ ADDW X,#6 ; DROP all
] ;
14 changes: 14 additions & 0 deletions lib/FC@
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
\ STM8eForth : FC@ TG9541-200726
\ ------------------------------------------------------------------------------

\ read char c at far address ah:al
: FC@ ( al ah -- c )
\ Note: creates/executes LDF ah:al,A + RET code on the Data Stack
$8100 ROT ROT [ \ get a RET ready
$A6BC , \ LD A,#0xBC ; Opcode LDF A,ExtAddr
$F7 C, \ LD (X),A ; MSB of ah (instead of "0")
$FD C, \ CALL (X) ; execute LDF
$6F04 , \ CLR (4,X) ; bring c onto stack
$E705 , \ LD (5,X),A
] 2DROP \ remove LDF ah:al
;

0 comments on commit 911d4ae

Please sign in to comment.