6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri May 10, 2024 5:55 pm

All times are UTC




Post new topic Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3
Author Message
PostPosted: Mon Oct 15, 2018 12:05 pm 
Offline

Joined: Sun May 13, 2018 5:49 pm
Posts: 247
chitselb wrote:
SamCoVT wrote:
Has anyone else implemented this with only a single buffer, or am I missing something that would preclude using only a single buffer?


PETTIL on a 32K machine uses only one 1K buffer for BLOCK, BUFFER, LOAD etc... It does some odd things with memory management


Thanks for letting me know it can be done. I actually just finished making it all work with a single buffer, and everything seems to be working fine so far. I would like to make the number of buffers user selectable, and I will probably use some of the suggestions in this thread when I start working on that.


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 16, 2018 5:10 pm 
Offline

Joined: Sat Aug 21, 2010 7:52 am
Posts: 231
Location: Arlington VA
SamCoVT wrote:
Thanks for letting me know it can be done. I actually just finished making it all work with a single buffer, and everything seems to be working fine so far. I would like to make the number of buffers user selectable, and I will probably use some of the suggestions in this thread when I start working on that.
Copying a block looks something like
Code:
: copy   ( from to -- )
    swap  block pad b/buf cmove
    pad swap block b/buf cmove update ;


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 16, 2018 5:38 pm 
Offline

Joined: Sun May 13, 2018 5:49 pm
Posts: 247
chitselb wrote:
Copying a block looks something like
Code:
: copy   ( from to -- )
    swap  block pad b/buf cmove
    pad swap block b/buf cmove update ;

I needed to move one of my blocks and made use of the fact that BUFFER leaves the data in the one and only buffer in place, so I only needed:
Code:
: copy ( from to -- )
    swap block drop
    buffer update ;

That only works, of course, on a single buffer forth where the word BUFFER doesn't just have BLOCK in it, which I've seen in some other Forths. Your code is much more portable as it will work on any Forth that supports blocks.
Thanks for the demo of using PAD, in any event. I always forget that it's there and this is the perfect example of its use.


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 16, 2018 6:09 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Well, ideally, copy would be a system specific primitive that knows how to reassign the block numbers that a buffer is allocated to. Then it just tweaks the assignment and marks the buffer as dirty.


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 17, 2018 7:59 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 858
SamCoVT wrote:
chitselb wrote:
Copying a block looks something like
Code:
: copy   ( from to -- )
    swap  block pad b/buf cmove
    pad swap block b/buf cmove update ;

I needed to move one of my blocks and made use of the fact that BUFFER leaves the data in the one and only buffer in place, so I only needed:
Code:
: copy ( from to -- )
    swap block drop
    buffer update ;

That only works, of course, on a single buffer forth where the word BUFFER doesn't just have BLOCK in it, which I've seen in some other Forths. Your code is much more portable as it will work on any Forth that supports blocks.
Thanks for the demo of using PAD, in any event. I always forget that it's there and this is the perfect example of its use.

But that requires PAD to be at least 1024 bytes.
If BUFFER never reads from mass storage, this version of COPY will work with one buffer or many:
Code:
: COPY  ( BLK1 BLK2 -- )
   SWAP BLOCK SWAP BUFFER
   B/BUF CMOVE UPDATE ;


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 22, 2019 9:06 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 858
whartung wrote:
I don't know how MOVE is defined when the source and destination addressed are the same (it should just NOP).

It's better if it doesn't, at least on the Commodore 64. The C64 has a full 64K of RAM as well as kernel ROM, BASIC ROM, and memory mapped I/O. The memory configuration controlled by locations 0 and 1 ( and two lines on the expansion port.) If a programmer wishes to copy the kernel ROM to RAM, modify it in some way and switch in the new Commodore kernel then the following will work.
Code:
HEX
E000 E000 2000 MOVE

On the C64, when the ROM is switched in it is read during a memory read( of course), but any write to that address range will write to the underlying RAM.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: