Jump to content
IGNORED

1 Meg Super AMS Discussion Thread


Omega-TI

Recommended Posts

  • 3 weeks later...
On 4/19/2022 at 4:11 PM, johnph3 said:

Success My 2017 Super AMS is working. Chalk up one more problem to a bad 74ls245. Thanks for your help

Now that I have it working, I would like to have a test program that shows status of card. I would like a print out of program so I can type it in my TI 99/4a and save it for future use. Thanks

Link to comment
Share on other sites

2 hours ago, johnph3 said:

Now that I have it working, I would like to have a test program that shows status of card. I would like a print out of program so I can type it in my TI 99/4a and save it for future use. Thanks

printing out is trouble as all the tests are written in assembly.. do you have disk? tipi?

 

Link to comment
Share on other sites

8 minutes ago, johnph3 said:

OK I have PEB with disk drives but no tipi.  I also have FlashRom99 and a FinalGROM99

both tests are available as bin for finalgrom/flashrom 

 

https://github.com/jedimatt42/ti994a-32kmemtest/releases   (tests sams ram, better than anything else)

 

 

AMSTEST4-8.BIN

  • Like 2
Link to comment
Share on other sites

3 hours ago, johnph3 said:

Now that I have it working, I would like to have a test program that shows status of card. I would like a print out of program so I can type it in my TI 99/4a and save it for future use. Thanks

 

Here is the test I use in fbForth:

Spoiler

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                             *
* SMSTST                                       by Lee Stewart *
*                                                             *
* This SAMS test routine checks for the presence of the SAMS  *
* card. It stores a value in SAMSFL with the results. It will *
* conatin the highest available SAMS bank if SAMS is present  *
* or 0 if no SAMS.                                            *
*                                                             *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
SMSTST
SAMSFL DATA 0           Storage for SAMS status
*
* Initialize SAMS card whether or not present.
* 
*++ SAMS card initialization routine.
* ...Originally ported from TurboForth code courtesy of Mark Wills
* ...Modified to explicitly set banks to power-up defaults, viz., banks >0002,
* ...   >0003,>000A-->000F mapped to >2000,>3000,>A000-->F000, respectively.
*
SMSINI LI   R12,>1E00         CRU address of SAMS
       SBO  0                 enable access to mapper registers
       SBZ  1                 disable mapping while we set it up
       LI   R0,>4004          register for >2000
       LI   R1,>0200          map bank >0002...
       MOV  R1,*R0+           ...into >2000
       LI   R1,>0300          map bank >0003...
       MOV  R1,*R0            ...into >3000
*
* Now set up the banks for high memory...
*
       LI   R0,>4014          register address
       LI   R1,>0A00          register value for bank >000A
       LI   R2,6              loop count
SAMS   MOV  R1,*R0+           write to the register
       AI   R1,>0100          next register value
       DEC  R2                finished?
       JNE  SAMS              loop if not
       SBO  1                 enable mapping
       SBZ  0                 lock the mapper registers
*

***++ Check for presence of SAMS card.
***++ SAMS flag will be set to highest available bank#.

* Testing will start with 32 MiB SAMS and will proceed by halving the range
* until 128 KiB is reached. 128 KiB is assumed to be the lowest viable SAMS.
* The actual bank tested will be >000E higher than the lowest bank in the
* upper half of the range.
*
* To test, Map >000E + lowest bank in upper half of SAMS range to >E000. For
* 32 MiB, this is >1000 + >000E. We initially store >0010 (LSB,MSB) in
* R3 to allow a circular shift each round before MOVing to R0 to then add
* >0E00 (LSB,MSB) for the next test. If the test fails at >001E, the last
* viable SAMS (128 KiB), R3 will go to >0800, at which point the loop
* exits, setting R3 to 0, effectively reporting "no SAMS".
*
* Set up SAMS check.
*
       LI   R2,>994A       check-value
       MOV  R2,@>E000      check-value to check-location
* Classic99 emulator can do 32 MiB
       LI   R3,>0010       lowest bank in upper half of SAMS to R3 (LSB,MSB)
       LI   R12,>1E00      CRU address of SAMS
*
*
SMSCHK
       MOV  R3,R0          lowest bank in upper half of SAMS range
       AI   R0,>0E00       get >000E banks higher
       SBO  0              enable SAMS registers
       MOV  R0,@>401C      poke SAMS register for >E000
       SBZ  0              disable SAMS registers
       C    @>E000,R2      compare possible copy with test value
       JNE  SMSXIT         exit if SAMS mapped, viz., no match
       SRC  R3,1           shift right circularly by ^2 to next lower SAMS
       CI   R3,>0800       too far?
       JNE  SMSCHK         try half as much if not >0008 (LSB,MSB)
       CLR  R3             no-SAMS..set flag to 0
       JMP  SMSXT0         we're outta here
SMSXIT
       SWPB R3             restore bank#
       SLA  R3,1           double value (highest bank# + 1)
       DEC  R3             decrement to highest bank#
SMSXT0
       MOV  R3,@SAMSFL     save SAMS flag
       JEQ  SMSXT1         exit now if no SAMS [no need to restore anything]
*
* Remap default bank >0E to >E000.
* R12 should still have correct CRU value.
*
       LI   R0,>0E00       load SAMS bank >000E
       SBO  0              enable SAMS registers
       MOV  R0,@>401C      poke SAMS register for >E000
       SBZ  0              disable SAMS registers
*
SMSXT1 END  SMSTST
*

...lee

 

  • Like 2
Link to comment
Share on other sites

10 minutes ago, Lee Stewart said:

 

Here is the test I use in fbForth:

  Reveal hidden contents


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                             *
* SMSTST                                       by Lee Stewart *
*                                                             *
* This SAMS test routine checks for the presence of the SAMS  *
* card. It stores a value in SAMSFL with the results. It will *
* conatin the highest available SAMS bank if SAMS is present  *
* or 0 if no SAMS.                                            *
*                                                             *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
SMSTST
SAMSFL DATA 0           Storage for SAMS status
*
* Initialize SAMS card whether or not present.
* 
*++ SAMS card initialization routine.
* ...Originally ported from TurboForth code courtesy of Mark Wills
* ...Modified to explicitly set banks to power-up defaults, viz., banks >0002,
* ...   >0003,>000A-->000F mapped to >2000,>3000,>A000-->F000, respectively.
*
SMSINI LI   R12,>1E00         CRU address of SAMS
       SBO  0                 enable access to mapper registers
       SBZ  1                 disable mapping while we set it up
       LI   R0,>4004          register for >2000
       LI   R1,>0200          map bank >0002...
       MOV  R1,*R0+           ...into >2000
       LI   R1,>0300          map bank >0003...
       MOV  R1,*R0            ...into >3000
*
* Now set up the banks for high memory...
*
       LI   R0,>4014          register address
       LI   R1,>0A00          register value for bank >000A
       LI   R2,6              loop count
SAMS   MOV  R1,*R0+           write to the register
       AI   R1,>0100          next register value
       DEC  R2                finished?
       JNE  SAMS              loop if not
       SBO  1                 enable mapping
       SBZ  0                 lock the mapper registers
*

***++ Check for presence of SAMS card.
***++ SAMS flag will be set to highest available bank#.

* Testing will start with 32 MiB SAMS and will proceed by halving the range
* until 128 KiB is reached. 128 KiB is assumed to be the lowest viable SAMS.
* The actual bank tested will be >000E higher than the lowest bank in the
* upper half of the range.
*
* To test, Map >000E + lowest bank in upper half of SAMS range to >E000. For
* 32 MiB, this is >1000 + >000E. We initially store >0010 (LSB,MSB) in
* R3 to allow a circular shift each round before MOVing to R0 to then add
* >0E00 (LSB,MSB) for the next test. If the test fails at >001E, the last
* viable SAMS (128 KiB), R3 will go to >0800, at which point the loop
* exits, setting R3 to 0, effectively reporting "no SAMS".
*
* Set up SAMS check.
*
       LI   R2,>994A       check-value
       MOV  R2,@>E000      check-value to check-location
* Classic99 emulator can do 32 MiB
       LI   R3,>0010       lowest bank in upper half of SAMS to R3 (LSB,MSB)
       LI   R12,>1E00      CRU address of SAMS
*
*
SMSCHK
       MOV  R3,R0          lowest bank in upper half of SAMS range
       AI   R0,>0E00       get >000E banks higher
       SBO  0              enable SAMS registers
       MOV  R0,@>401C      poke SAMS register for >E000
       SBZ  0              disable SAMS registers
       C    @>E000,R2      compare possible copy with test value
       JNE  SMSXIT         exit if SAMS mapped, viz., no match
       SRC  R3,1           shift right circularly by ^2 to next lower SAMS
       CI   R3,>0800       too far?
       JNE  SMSCHK         try half as much if not >0008 (LSB,MSB)
       CLR  R3             no-SAMS..set flag to 0
       JMP  SMSXT0         we're outta here
SMSXIT
       SWPB R3             restore bank#
       SLA  R3,1           double value (highest bank# + 1)
       DEC  R3             decrement to highest bank#
SMSXT0
       MOV  R3,@SAMSFL     save SAMS flag
       JEQ  SMSXT1         exit now if no SAMS [no need to restore anything]
*
* Remap default bank >0E to >E000.
* R12 should still have correct CRU value.
*
       LI   R0,>0E00       load SAMS bank >000E
       SBO  0              enable SAMS registers
       MOV  R0,@>401C      poke SAMS register for >E000
       SBZ  0              disable SAMS registers
*
SMSXT1 END  SMSTST
*

...lee

 

Thanks but I never got into forth. Maybe someday,

  • Like 1
Link to comment
Share on other sites

47 minutes ago, johnph3 said:

can you give me a link? Can it be run from FinalGrom99 or it is Editor Assembly only?

 

Perhaps I misunderstood you. If you can copy and paste, the Assembler code is in the spoiler of my post.

 

Or—Do you need object code that loads and runs from the E/A cartridge or similar? In that case, I will need to assemble the code and post the object code. I should probably also modify it to display the result on your screen. As it stands, it merely places the number of the highest SAMS bank found at memory location SAMSFL. I will get to it later this evening.

 

...lee 

Link to comment
Share on other sites

2 hours ago, Lee Stewart said:

 

Here is the test I use in fbForth:

  Reveal hidden contents


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                             *
* SMSTST                                       by Lee Stewart *
*                                                             *
* This SAMS test routine checks for the presence of the SAMS  *
* card. It stores a value in SAMSFL with the results. It will *
* conatin the highest available SAMS bank if SAMS is present  *
* or 0 if no SAMS.                                            *
*                                                             *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
SMSTST
SAMSFL DATA 0           Storage for SAMS status
*
* Initialize SAMS card whether or not present.
* 
*++ SAMS card initialization routine.
* ...Originally ported from TurboForth code courtesy of Mark Wills
* ...Modified to explicitly set banks to power-up defaults, viz., banks >0002,
* ...   >0003,>000A-->000F mapped to >2000,>3000,>A000-->F000, respectively.
*
SMSINI LI   R12,>1E00         CRU address of SAMS
       SBO  0                 enable access to mapper registers
       SBZ  1                 disable mapping while we set it up
       LI   R0,>4004          register for >2000
       LI   R1,>0200          map bank >0002...
       MOV  R1,*R0+           ...into >2000
       LI   R1,>0300          map bank >0003...
       MOV  R1,*R0            ...into >3000
*
* Now set up the banks for high memory...
*
       LI   R0,>4014          register address
       LI   R1,>0A00          register value for bank >000A
       LI   R2,6              loop count
SAMS   MOV  R1,*R0+           write to the register
       AI   R1,>0100          next register value
       DEC  R2                finished?
       JNE  SAMS              loop if not
       SBO  1                 enable mapping
       SBZ  0                 lock the mapper registers
*

***++ Check for presence of SAMS card.
***++ SAMS flag will be set to highest available bank#.

* Testing will start with 32 MiB SAMS and will proceed by halving the range
* until 128 KiB is reached. 128 KiB is assumed to be the lowest viable SAMS.
* The actual bank tested will be >000E higher than the lowest bank in the
* upper half of the range.
*
* To test, Map >000E + lowest bank in upper half of SAMS range to >E000. For
* 32 MiB, this is >1000 + >000E. We initially store >0010 (LSB,MSB) in
* R3 to allow a circular shift each round before MOVing to R0 to then add
* >0E00 (LSB,MSB) for the next test. If the test fails at >001E, the last
* viable SAMS (128 KiB), R3 will go to >0800, at which point the loop
* exits, setting R3 to 0, effectively reporting "no SAMS".
*
* Set up SAMS check.
*
       LI   R2,>994A       check-value
       MOV  R2,@>E000      check-value to check-location
* Classic99 emulator can do 32 MiB
       LI   R3,>0010       lowest bank in upper half of SAMS to R3 (LSB,MSB)
       LI   R12,>1E00      CRU address of SAMS
*
*
SMSCHK
       MOV  R3,R0          lowest bank in upper half of SAMS range
       AI   R0,>0E00       get >000E banks higher
       SBO  0              enable SAMS registers
       MOV  R0,@>401C      poke SAMS register for >E000
       SBZ  0              disable SAMS registers
       C    @>E000,R2      compare possible copy with test value
       JNE  SMSXIT         exit if SAMS mapped, viz., no match
       SRC  R3,1           shift right circularly by ^2 to next lower SAMS
       CI   R3,>0800       too far?
       JNE  SMSCHK         try half as much if not >0008 (LSB,MSB)
       CLR  R3             no-SAMS..set flag to 0
       JMP  SMSXT0         we're outta here
SMSXIT
       SWPB R3             restore bank#
       SLA  R3,1           double value (highest bank# + 1)
       DEC  R3             decrement to highest bank#
SMSXT0
       MOV  R3,@SAMSFL     save SAMS flag
       JEQ  SMSXT1         exit now if no SAMS [no need to restore anything]
*
* Remap default bank >0E to >E000.
* R12 should still have correct CRU value.
*
       LI   R0,>0E00       load SAMS bank >000E
       SBO  0              enable SAMS registers
       MOV  R0,@>401C      poke SAMS register for >E000
       SBZ  0              disable SAMS registers
*
SMSXT1 END  SMSTST
*

...lee

 

Can someone zip this for me. Thx... nevermind...I see what he's doing. No need to zip it.

Edited by GDMike
Link to comment
Share on other sites

2 hours ago, johnph3 said:

While I'm playing around has anybody ever added speech to a program like blackjack and poker, so it might speak the cards it deals. Might be interesting if doable?

Something can be done, is have a recording of any audio and it can be played straight through the cassette player through the tv or monitor. It's not the same, but a standalone audio built just for the BJ cart could be made.

 

Edited by GDMike
Link to comment
Share on other sites

On 2/8/2022 at 2:38 PM, TheBF said:

 

I have some useful structures too Bill that could be bolted onto FbForth.

On 2/8/2022 at 2:38 PM, TheBF said:

And then there is PAGED ( virtual-addr -- real-addr) 

You set a 64K segment of SAMS memory with:  HEX 10 SEGMENT 

Now you have a 64k address by adding PAGED to your memory operations.


: @S    ( addr -- n )  PAGE @ ;
: !S    ( n addr -- )    PAGE ! ; 
etc...

 

 

  Reveal hidden contents


\ SAMS CARD support for CAMEL99 in Forth   May 2020  B Fox
\ 16 by 64K segmented memory model for DATA
\ You can access any ADDRESS from 1 to 65535 using PAGED
NEEDS SAMSINI  FROM DSK1.SAMSINI

HERE
VARIABLE SEG     \ holds current 64K segment
VARIABLE BANK#   \ current mapped bank
HEX
3000 CONSTANT DMEM    \ CPU RAM memory block location
\ Legal values: 2000,3000,A000,B000,C000,D000,E000,F000

\ compute SAMS register based on PMEM address
DMEM 0B RSHIFT 4000 + CONSTANT DREG

HEX
: PAGED  ( virtual-addr -- real-addr)
      SEG @ 1000 UM/MOD  ( -- offset bank#)
      DUP BANK# @ -     \ different page?
      IF
        DUP BANK# !
        SAMSCARD 0SBO   \ card on, enable registers
( bank#) >< DREG !      \ swap bytes & store in SAMS register
         0SBZ           \ card off
      ELSE DROP
      THEN DMEM +       \ then add offset to paged mem block
;
\ safely set the 64K segment that you want to use
: SEGMENT ( 1..F -- ) \ don't allow segment 0
      DUP 01 10 WITHIN 0= ABORT" SAMS segment err"
      SEG ! ;

CR HERE SWAP - DECIMAL . .( bytes)
SAMS-OFF SAMSINI SAMS-ON
1 SEGMENT
CR .( SAMS card activated)
CR .( Window = ) DMEM HEX U.
CR .( Segment = ) SEG @  DECIMAL U.
CR

 

 

The two-page buffer solves a problem I was thinking about! How to walk through a linked list or any kind of pointers in a big memory space. Assuming that the pointers are 32 bit.  
 

I thought I might have to resort to locking pointers and bigger worries. But this is simple and does the right job. 

  • Like 1
Link to comment
Share on other sites

1 hour ago, FarmerPotato said:

The two-page buffer solves a problem I was thinking about! How to walk through a linked list or any kind of pointers in a big memory space. Assuming that the pointers are 32 bit.  
 

I thought I might have to resort to locking pointers and bigger worries. But this is simple and does the right job. 

Yes the two window paging makes everything simpler. Almost like real virtual memory!. :) 

The code in your post uses only one window for SAMS memory.

The following code uses two windows at >2000 and >3000 and toggles between them 

The BLOCK word made memory management in ED99 as simple as using linear RAM as long as you go through BLOCK.

 

Spoiler

\ BLOCK  as a method to manage SAMS pages    Jan 15 2021 Brian Fox
\ Jan 2022 Fixed SAMSINI to access registers properly

\ NEEDS .S   FROM DSK1.TOOLS
NEEDS MOV, FROM DSK1.ASM9900
NEEDS SAMSINI  FROM DSK1.SAMSINI

HERE
\ ==========================================
\ BLOCK is the entire SAMS manager
HEX
VARIABLE USE
CREATE BLK#S       0 ,    0 ,      \ SAMS page in the buffer
CREATE WINDOWS  2000 , 3000 ,      \ windows in Low CPU RAM

\ SAMS memmory access as BLOCK from Forth.  Source code   Brian Fox 
CODE BLOCK ( bank -- buffer)
          R0 BLK#S LI,     \ handle 0 search
         R0 ** TOS CMP,
          EQ IF,
                TOS 2000 LI,
                NEXT,      \ Return to Forth
          ENDIF,
                R0 INCT,   \ handle 1 search
         R0 ** TOS CMP,
          EQ IF,
                TOS 3000 LI,
                NEXT,     \ Return to Forth
          ENDIF,
           W  0001 LI,    \ W is R8
         USE @@  W XOR,
         W  USE @@ MOV,
         W       W ADD,   \ W holds offset
     TOS BLK#S (W) MOV,   \ store the bank#
    WINDOWS (W) R1 MOV,   \ get the window to use
          R1    0B SRL,   \ divide by 2048
          R1  4000 AI,    \ convert to SAMS register address
          R12 1E00 LI,    \ cru address of SAMS
                 0 SBO,   \ SAMS card on
              TOS  SWPB,  \ swap bytes on bank value
         TOS R1 ** MOV,   \ load bank into register
                 0 SBZ,   \ SAMS card off
   WINDOWS (W) TOS MOV,   \ return buffer on TOS
                   NEXT,
 ENDCODE

 

 

I put SAMSINI in a separate file because it was common to all my SAMS code.

This new version incorporates some help from Lee.

 

Spoiler

\ SAM 1M memory card common code              Feb 2 2022 Brian Fox
\ This file is common code for all other SAMS extensions
DECIMAL
  24 USER 'R12  \ address of R12 in any Forth workspace
HEX
: SAMSCARD  ( -- ) 1E00 'R12 ! ;   \ select sams card
\ using machine code so we don't need the CRU library
HEX
\ *set the CRU address in 'R12 before using these words*
  CODE 0SBO  ( -- ) 1D00 ,  NEXT, ENDCODE
  CODE 0SBZ  ( -- ) 1E00 ,  NEXT, ENDCODE
  CODE 1SBO  ( -- ) 1D01 ,  NEXT, ENDCODE
  CODE 1SBZ  ( -- ) 1E01 ,  NEXT, ENDCODE

: SAMS-ON   ( -- ) SAMSCARD 1SBO ;  \ enable mapper
: SAMS-OFF  ( -- ) SAMSCARD 1SBZ ;  \ disable mapper

\ * SAMSINI sets 1Mbyte card to "pass-through" condition
: SAMSINI ( -- n)
       SAMSCARD          \ select SAMS card
       0SBO              \ turn card on, enable registers
       0                 \ register value stays on stack
       4000 20           \ register address, # SAMS regs
       BOUNDS ( -- 4100 4000)
       DO
           DUP >< I !    \ swap bytes and write 16 bits to reg
           I C@  OVER <> ABORT" SAMSINI failed"
           01 +          \ next passthru value
       2 +LOOP
       DROP
       0SBZ              \ turn off card, disable registers
;
SAMS-OFF CR .( Init 1M card) SAMSINI
SAMS-ON  CR .( Mapper enabled )

 

 

 

  • Like 2
Link to comment
Share on other sites

21 minutes ago, TheBF said:

Yes the two window paging makes everything simpler. Almost like real virtual memory!. :) 

 

This new version incorporates some help from @Lee Stewart

Thanks! I didn’t realize I had quoted the code too, but all for the best. 

 

Two schemes that build on this, but  use just 16 bits for their pointers:

 

1. Pointers on 16 byte boundaries.
 

An ALLOCATE-like word returns them, using up to 1 megabyte of heap. Give up  4 LSbits to make room for 4 more MSBits. To dereference one or two pointers,  there is a SEGMENT-like word to bring it back into a 16-bit local page address. 
 

2. Another scheme is handles. A handle is a pointer to pointer. Here, a 16-bit pointer to 32-bit pointer. 
 

Suppose ALLOCATE-like word NEWHANDLE returns a 16 bit pointer into a 64K table of contents… or a 16 bit integer index value. *HANDLE turns it back into a 16-bit local page address. 
 

The underlying block pointed to, can be moved, to compact the heap. Or block needs to grow, which might mean it migrates.  In either case, the caller’s handle (being an index) does not change. 
 

 

 

  • Like 2
Link to comment
Share on other sites

51 minutes ago, FarmerPotato said:

Thanks! I didn’t realize I had quoted the code too, but all for the best. 

 

Two schemes that build on this, but  use just 16 bits for their pointers:

 

1. Pointers on 16 byte boundaries.

 

This was used by FPC a Forth that worked across segments in DOS. Can be a bit complicated to get at bytes. 

Quote

An ALLOCATE-like word returns them, using up to 1 megabyte of heap. Give up  4 LSbits to make room for 4 more MSBits. To dereference one or two pointers,  there is a SEGMENT-like word to bring it back into a 16-bit local page address. 
 

2. Another scheme is handles. A handle is a pointer to pointer. Here, a 16-bit pointer to 32-bit pointer. 

I would be concerned about speed on this one but it could be done. 

 

 

Link to comment
Share on other sites

I had never built data structures on the two-window SAMS management system using BLOCK so I just did.

Here is an example of adding Forth style static memory management and then creating fetch and store operators and some data types.

The L suffix goes back to DOS segment days so I "borrowed it"

 

Spoiler

\ Virtual memory with two windows in LOW RAM   Jun 2022 Fox
NEEDS DUMP FROM DSK1.TOOLS
NEEDS BLOCK  FROM DSK1.SBLOCKS

VARIABLE SEG     \ holds current 64K segment
1000 CONSTANT 4K

HEX
: >VIRT  ( addr -- offset page#)   SEG @ 4K UM/MOD ;
: PAGED  ( virtual-addr -- real-addr) >VIRT BLOCK + ;

  1 SEG !   \ use the 2nd 64K segment (above passthru memory)

\ "FAR" memory access words operate on active SEGment
: !L    ( n addr --)  PAGED ! ;   \ store int
: C!L   ( c addr --)  PAGED C! ;  \ store char
: 2!L   ( d addr --)  PAGED 2@ ;  \ store double

: @L    ( addr -- n)  PAGED @ ;
: C@L   ( addr -- c)  PAGED C@ ;
: 2@L   ( addr -- d)  PAGED 2@ ;

\ SAMS static Forth style memory allocation
VARIABLE SDP  \ sams dictionary pointer for 1 64K segment

: SHERE  ( -- addr) SDP @ ;    \ return end of SAMS dictionary
: SALLOT ( n -- )   SDP +! ;   \ move dictionary pointer ( pos or neg)

: ,L   ( n --) SHERE !L  2 SALLOT ;
: C,L  ( c --) SHERE C!L 1 SALLOT ;

\ ======================================================
\ build some hi-level data structures with the new tools
: VAR ( <name> -- addr)      \ use !L and @L  with VAR
        CREATE  SHERE  0 ,L  \  put a zero into SAMS HERE
                 ,           \ compile the address pointer in the Forth word.
        DOES> @ ;  \ runtime: fetch the virtual memory pointer

: CONST ( n -- )
      CREATE   SHERE  ,L   ,   DOES> ( -- n) @ @L ;

\ these arrays are all in the same 64k segment
\ The return virtual addresses so are used with !L  @L  C!l C@l
: FAR-ARRAY ( n -- <name>)
     CREATE SHERE              \ remember where we parked this
            SWAP SALLOT        \ allocate memory in the SAMS space
            ( shere) ,         \ compile the sams memory location in the word
     DOES>  @ SWAP CELLS + ;

: FAR-CARRAY ( n -- <name<)
     CREATE  SHERE  SWAP SALLOT  ,
     DOES>  @ +  ;

 

 

Here are two test programs to fill an array and then see it to confirm it works.

\ EXAMPLE: 40K byte array of integers in SAMS.
INCLUDE DSK1.ELAPSE
INCLUDE DSK1.BREAK
DECIMAL
20000 FAR-ARRAY ]BIG

: BIGFILL   20000 0 DO  I I ]BIG !L    LOOP  ;
: BIGSEE    20000 0 DO    I ]BIG @L . ?BREAK  LOOP ;

 

As you can see in the video it take ~21 seconds to fill a 20,000 integer array. (40Kbytes of SAMS space) 

I could be made a bit faster with some CODE words but it would not be much faster IMHO.

 

 

 

  • Like 4
Link to comment
Share on other sites

I should add that if the application permits accessing SAMS on a BLOCK level rather than cell by cell,  it's much faster with this system.

For example this code runs in ~1 second to fill the entire array with zeros. (It could be faster with a FILLW that fills CELLS rather than bytes.

 

: BIGFILL   20000 0 DO   I BLOCK  0 FILL   4K +LOOP ;

 

 

  • Like 1
Link to comment
Share on other sites

8 hours ago, TheBF said:

I should add that if the application permits accessing SAMS on a BLOCK level rather than cell by cell,  it's much faster with this system.

For example this code runs in ~1 second to fill the entire array with zeros. (It could be faster with a FILLW that fills CELLS rather than bytes.

 


: BIGFILL   20000 0 DO   I BLOCK  0 FILL   4K +LOOP ;

 

 

I figured you’d write ALLOCATE to guarantee  that one whole array stays in one 4K page. Then only one  BIG[ call to get at the struct. 
 

Starting to think about the efficiency/overhead after you asked. 


I like how 2 banks solves the problem of linked lists that need to grow past a 4K page boundary. 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...