6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 21, 2024 12:04 am

All times are UTC




Post new topic Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3
Author Message
PostPosted: Tue Jan 15, 2019 4:40 am 
Offline

Joined: Thu Jan 21, 2016 7:33 pm
Posts: 275
Location: Placerville, CA
Plus, saving three bytes per system call is fairly non-negligible on an architecture where the maximum possible memory size is 16MB and typical sizes are more like 64-512KB.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 15, 2019 8:48 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
whartung wrote:
BigDumbDinosaur wrote:
The main value in using COP for API calls is nothing special has to be done to call an API from another bank. All of that is handled for you due to COP being just another interrupt.

Is the problem that the caller simply doesn't have to distinguish between JSR and JSL?

That's part of it. The API backend also has to distinguish between the two, since the return from JSL (RTL) has to pull one more byte from the stack than does RTS. Also consider that JSL is a four-byte instruction, whereas COP is a two-byte instruction. Furthermore, if one has to JSL to an API then it is implied the kernel must be loaded to an immutable location.

Contrary to one might think, using JSL to call an API function confers no performance advantage over COP—both instructions require eight clock cycles to execute. Use of COP automatically pushes SR to the stack, which may be important in an API call from which some sort of "error" status is to be returned (usually via the carry bit). However, in native mode, RTL is one clock cycle faster than the RTI needed to return following an interrupt. On the other hand, since RTI automatically restores SR, the two cycles that would be required to "manually" pull SR as part of a JSL/RTL return are avoided.

COP also offers the possibility of a change in machine state when an OS API is called. During cycles 7 and 8 of COP, the 65C816's VPB output is driven low to indicate an interrupt vector is being fetched. This same signal could be used to switch the hardware protection, if present, from user to kernel mode. How would you do this if the API is called via JSL, especially when you consider the fact that the kernel address space should be protected from user-space accesses?

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 15, 2019 9:49 pm 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
As a point of order, the performance cost quoted for using COP/RTI doesn't include the cost of dispatching on the argument of COP. Since there is no "indirect long via stack" addressing mode, accessing that argument is not trivial, and probably requires pushing/restoring DPR. A JSL call would be direct to a well-known entry point specific to the routine required, though this may itself merely be a jump to the real code.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 15, 2019 10:34 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
(I think we said upthread that the COP argument byte isn't much use, for that very reason.)


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 15, 2019 10:45 pm 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
In which case, how *do* you handle more than one routine, given that COP only provides a single entry point? You have to stuff a code into a well-known location in memory, or sacrifice a register to it. And you still need to index a jump table (or something) to get to the routine itself. All of these are costly to some degree.

So I think the performance argument for COP is bogus. The other arguments may have merit.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 15, 2019 11:08 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
Chromatix wrote:
In which case, how *do* you handle more than one routine, given that COP only provides a single entry point? You have to stuff a code into a well-known location in memory, or sacrifice a register to it. And you still need to index a jump table (or something) to get to the routine itself. All of these are costly to some degree.

So I think the performance argument for COP is bogus. The other arguments may have merit.

I already posted example code illustrating how it could be done. In any case, no one is claiming that use of COP confers performance advantages over JSL/RTL. What it confers is flexibility.

Anyhow, this line of discussion should be terminated here and resumed over here.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


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 40 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: