16 December 2020, 10:39 | #41 | |
Registered User
Join Date: May 2017
Location: Munich/Bavaria
Posts: 2,361
|
Quote:
My ideas must be seen as "changing the rules" and alienate quite a few people ... probably not the right place for this kind of discussion - sorry for that. |
|
16 December 2020, 10:57 | #42 | |
Registered User
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,156
|
Quote:
I don't see anything wrong with exploring ideas, and changing rules, provided of course that you're not demanding that anyone else should play by your new rules! If nothing else, by exploring what happens when you change the rules, you sometimes gain new insights into why things were done the way they were. Is this discussion pointless? Yes, probably - but in the grand scheme of things so is every other Amiga-related endeavour over the last two decades. Anyone who doesn't find the discussion interesting is perfectly welcome to ignore it! |
|
16 December 2020, 11:39 | #43 | ||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
|
Quote:
Note that 4-bit c2p has of course a lot less pressure than 8-bit one. Quote:
Sure the repeat can only break implementations. But let's say we have routine A calling routine B. Routine A uses the register stack. Without any special care, everything routine B does, will break the stack. Even if it's explicitly documented as not touching some regs, it can't just save/restore the 32-bit regs like before. Saving is ok but restoring would push. Quote:
Quote:
But yes these can be used at the same time... at least in theory ; in practice i would have to remove existing encodings to make room for that feature, potentially harming code density in other places... At the end, is it worth ? It only brings code density, nothing in ease to code or speed, and doesn't make implementation easier. |
||||
16 December 2020, 12:49 | #44 | |||
Registered User
Join Date: Jun 2015
Location: Germany
Posts: 1,920
|
Quote:
PUSH/POP type instructions and the entire head of the traditional stack can be made transparent (i.e. zero execution time) using shadow registers. Basically the difference between 2-operand and 3-operand ISAs is that you need a lot of extra MOVE instructions for the 2-operand ISA. However, you get shorter instructions in exchange. In a modern CPU all those extra MOVEs of 2-operand ISAs just disappear in the execution time because the CPU internally just works with 3 operands after early decode. This makes your 2-operand code basically compressed 3-operand code with the MOVE being equivalent to an extension word for 3-operands which you only use if you need the 2nd input operand of the 2-operand operation after executing that. The downside of your approach is that, while you can easily extend the number of shadow registers any way you want (wattage constraints etc.) without changing compatibility and code, you can't (at least not easily) if you explicitly define register stacks and frames. Quote:
I guess using a directly addressable 0-cyle access local memory like many DSPs do for operands and extending this concept to short subroutines might be a more interesting idea. EDIT: the 16 previous instructions are also going to be a nightmare when doing context switches. Quote:
Last edited by grond; 16 December 2020 at 19:17. |
|||
16 December 2020, 19:18 | #45 | ||||
Registered User
Join Date: May 2017
Location: Munich/Bavaria
Posts: 2,361
|
Quote:
In theory static address registers should be a very good use case for my idea. Quote:
When using this new feature in combination with old code, one should turn off the stack-feature - it is one write to the features register, that I mentioned earlier and locks the topmost register in place - before jumping to the critical subroutine.... Quote:
Quote:
Last edited by Gorf; 16 December 2020 at 20:17. |
||||
16 December 2020, 19:52 | #46 | |||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
|
Quote:
Quote:
Well, of course one can not think about every possible case. Obviously. Quote:
For a software vm, forget it. And for hardware, well, read grond's comments. |
|||
16 December 2020, 19:55 | #47 | |||||
Registered User
Join Date: May 2017
Location: Munich/Bavaria
Posts: 2,361
|
Quote:
But from what I learned here so far, I was trying to solve a non existing problem, since more registers are not as needed as I thought ... Quote:
(as in: the referred instructions are already decoded ...) Speculative execution, out-of-order ... well - that all is far beyond the scope of my little project. Quote:
Actually the TAOS project did something like that: it's first VM was a many register machine (32?) and there was an implementation for the Transputer CPU, which is a stack-machine, but had very fast internal memory (claimed register-speed) So this VM made the Transputer a de facto register machine Quote:
Quote:
While I came up with it, trying to speed up emulation, it is not limited to that: It should improve any kind of byte-code like e.g. for scripting languages, and might also be useful for compression algorithms. Last edited by Gorf; 16 December 2020 at 23:03. |
|||||
16 December 2020, 20:16 | #48 | |||
Registered User
Join Date: Jun 2015
Location: Germany
Posts: 1,920
|
Quote:
Quote:
Quote:
|
|||
16 December 2020, 22:52 | #49 | |
Registered User
Join Date: May 2017
Location: Munich/Bavaria
Posts: 2,361
|
Quote:
My reply was about how to save the "invisible" registers of my stacked registers. If you are talking about the "log" - this is not not part of the normal instruction cache, but in fact a bunch of registers ... and yes: they have to be saved on context switches, as any other registers do, if your next task is going to use them. (kernel and interrupt request handlers can chose not to use this feature - stop the log and avoid the memory transaction) Last edited by Gorf; 16 December 2020 at 22:59. |
|
17 December 2020, 05:04 | #50 | ||||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,655
|
Quote:
Quote:
I personally think that 68k is close enough to ideal from a coding perspective that it doesn't need improving. Your 'improvements' would just make it harder for me to read and write, because then I would have to learn new instructions that do unfamiliar things - for marginal benefit. Quote:
Quote:
look, I understand where you are coming from. After doing a couple of large Z80 projects I had similar ideas about improving it. But I rejected the idea because I would be destroying the character of the machines I was working on - and that's with a CPU that is begging for improvement. I got more enjoyment out of producing code that was fast and efficient despite the CPU's limitations, than if I had taken the lazy path of tinkering with the ISA. But don't let my opinion stop you guys from continuing what you are doing. even if it is a dead end, it still makes us think more about 68k coding and appreciate its beauty (and warts), and what we can create with it. |
||||
17 December 2020, 09:11 | #51 | ||||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
|
Quote:
Sure, Amiga software can work on other machines as well thru emulation, but this needs a copyrighted ROM to work. My VM does not need that. Quote:
Quote:
and.l a0,d0or eor.w (a0)+,d0without any effort. Then it's like going from 68000 to 68020. You're free to use improvements or not. But the benefit isn't marginal. What previously took a lot of efforts or was even not doable in asm due too complex, is now straigthforward or at least possible. All the memory you used to keep the 68k's limits in mind is now free for other, better tasks because most of these limits are gone. Quote:
And yes it's smaller and easier to read and write (at least for myself ). Quote:
I run into the 68k's limitations just too often. I originally tried to solve that with macros but they can't handle everything. Quote:
Of course it is currently very slow which limits its use (even though the high level part can run at native speed). But if i could directly translate the code to 68k so that it does at least same job as a compiler, i could release some software using it without the users even knowing about it... In fact, my vm is the continuation of my system framework, but for the low level. Do you know my system framework ? Probably not, it's not visible to the end user - but nearly all my code uses it, from my picture viewer, audio flac player, to all the games i ported. And it allows writing such programs without any direct use of OS and hardware. In a shorter, more efficient way. Perhaps i will forever be alone using it. But i don't care, as it makes my life easier. And it is the same for my cpu. |
||||||
18 December 2020, 07:00 | #52 | |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,655
|
Quote:
But can you understand this? Code:
move.b ([Label1,za1,d1.w],Label2),d0 ... Label1: ... Label2: Perhaps I should use Barfly assembler instead, since it is a bit faster and doesn't have this bug? But it can't handle the suppressed address register! So I am more concerned about being able to use all existing 68k instructions than creating new ones that aren't needed. |
|
18 December 2020, 08:26 | #53 | ||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
|
Quote:
Quote:
Quote:
Your example here is very interesting. It shows the 68k can be more complicated than it should, and for little benefit. Another shortcoming i wanted to fix. Quote:
As for using all existing 68k instructions, good luck at finding a use for rtr, chk, cmp2, chk2, cas2, trapv, trapcc, nbcd. |
||||
18 December 2020, 22:59 | #54 | |||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,655
|
Quote:
Quote:
Quote:
You are creating a 68k-like instruction set for you own code so dropping some opcodes is fine, but it wouldn't do for something that needs to run Amiga programs. Nevertheless it is interesting to consider how the 68k could have been improved in a compatible way. It is a bit puzzling why some instructions do not allow certain addressing modes, while others are 'unnecessarily' duplicated. |
|||
18 December 2020, 23:29 | #55 | |||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
|
Quote:
Quote:
Quote:
Right, 68k lacks a little bit of logic. In my vm, if an addressing mode is meaningful (and not an easy to remove duplicate) then it is allowed. |
|||
19 December 2020, 09:05 | #56 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,249
|
Quote:
rtr has certainly its uses for restoring the full context transparently, after a movem of all registers. If I recall, it may be that COP uses this instruction. chk is a compiler support for languages that expect or require bounds checking on arrays. Such languages run "out of favour" as we do such things not at all (C-style) or in software (suitable classes in C++ with bounds checking), but it is certainly useful for Pascal. cmp2 is useful for saturation logic, and chk2 for debug paths of similar applications, or for 1-based arrays if the source language requires that. cas2 is essential for multi-core systems. Implementing a lock-free queue or a robst lock-free stack without cas2 is hard if not impossible. Of course, on the Amiga, you do not need anything of that. trapv is in use by certain compilers - I recall an Oberon compiler for the Amiga - which used it for arithmetic overflow checking. That is, from a language perspective, a much better and saner logic that the C style "undefined behaivour" on arithmetic overflows. trapcc is likewise an extension, if you need this for signed logic. All in all, these instructions are for languages that run out of favour, though are still useful, or for system designs the Amiga does not follow, but that have been envisioned by Motorola. There are other examples in this family: Consider "callm" which supports (through the 68581 MMU) a layered security system. That was considered "a good idea" somewhere in the 90's, but nobody writes operating systems with more than 2 layers nowadays, and if so, then uses virtual machines. So it was useful to implement an architecture paradigm that "run out of favour", though was still useful (or required) for it. |
|
19 December 2020, 09:13 | #57 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,249
|
Quote:
There is a certain logic why particular addressing modes are not allowed. The design principle of the 68K is to separate instruction and data space. In fact, with proper hardware, one could have data space and instruction space in separate RAMs as the 68K provides control signals that indicate what is addressed: data or instrucitons. Anything that is in the instruction space, cannot be modified by the processor. Thus, if you address something relative to the PC, it is "instruction space". You thus can read relative to the PC, but not write relative to the PC. While I do not have evidence at this moment, I would believe that the external logic would also decode accesses relative to the PC as "instruction space" addresses, whereas indirections through an address register are "data accesses". The 68K there follows a generally advisable design, unfortunately one the Amiga does not fully implement, but that has been envisioned for other applications. While we are at it: nbcd is useful for BCD arithmetics, it is in the same family as abcd and sbcd, and as such useful. BCD arithmetics run out of favour (for better or worse), but there was "some market" that likes it (financial) and there are certainly languages that would require it. Probably cobol. |
|
19 December 2020, 10:35 | #58 | ||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
|
Quote:
rtris just move (sp)+,ccr+ rts. Not worth creating an instruction. chkis faster than cmp+ bccbut less flexible (it crashes if out of bounds, period) and it takes significant opcode space which probably could have been used for something less specific. cmp2/ chk2are too slow to be of any real use and they'll never gonna be fast as they're dependent of memory accesses. All this makes them unsuitable for most of the cases they were supposed to handle... Besides, their implementation is problematic (see 68060). cas2can't be essential for multi-core systems, as multi-core RISC cpus certainly don't have such a complex instruction and they still work. It is not for nothing it has been deleted too in 68060. The same feature as trapv/ trapccis easy to get with branches, but branches can at least do other things than just crashing by the means of an exception. While we're at it, nbcdis easy to replace with sbcd(it's just 0-n). The case is too rare to justify an instruction. So yes, i wouldn't advocate removing all these for a cpu intended to execute legacy code, but for new software you have to admit they're not the most useful stuff we have... OTOH, move with zero/sign extend would be incredibly common -- but we just don't have that. Quote:
Quote:
callmwas so useful that it didn't even reach next generation of same cpu. It is just too complex. Not targeted at me but i wanted to react : Quote:
leato some address and the space can't be known afterwards. Any stored pointer will lose that info. By disallowing PC-relative writes Mot' just wanted to discourage SMC. Now whenever we have data right after the code and need to make alterations to it, we run into that limitation. But ok. We know why it's there and can live with it. It does not explain, however, why we can't eorfrom mem, or why we can't movem.x rlist,(an)+. (In reality i know the reasons behind these too, but they're not very valid either.) |
||||
19 December 2020, 12:40 | #59 | ||||||||||||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,249
|
Quote:
Quote:
Quote:
Quote:
Quote:
At that time, SMP was not much an issue, and multi-core 68K systems were rare. However, nowadays the story is a completely different one, and CAS2 or rather its x86 equivalent, compare-exchange with "lock prefix" are essential. Mot envisioned such systems with the 68K, but there wasn't a market big enough back then. On the Amiga, you cannot use locked memory transfers safely, so this instruction family is of no use in the Amiga anyhow, but it is quite important for some other systems (or was supposed to be). Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Nowadays, nobody would use the LINK and UNLK instruction either as compilers can keep track of the stack frame themselves, without wasting an address register as frame pointer. But that was all before compilers became smarter. So certainly 68K carries some legacy around, but that legacy is not Amiga specific. |
||||||||||||
19 December 2020, 13:47 | #60 | |||||||||||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
|
Starting personal attacks again, i see.
The fact it has been left behind, doesn't make it technically obsolete in any manner. Quote:
Quote:
Note that x64 also declared the boundinstruction obsolete. Quote:
Now, CAS2 is for double linked list. All others are satisfied with the simpler CAS instruction, which i wouldn't remove. About the other primitive used by risc cores, and the 68k doesn't have, why not telling more about it ? Hey, wait. Isn't it just some exginstruction targeting memory ? Quote:
Quote:
Quote:
Quote:
Coldfire has mvs/mvz. x86 has movsx/movzx. (An no, Vampire doesn't have it. Worse, it reused its natural encoding space for something else.) Opcode fusion is the lazy reply. It doesn't change the fact there is a big impact on code density. Quote:
It is nice theory vs programming flexibility. Forgive me if i prefer the latter. Quote:
Quote:
But yes, the excuse behind this error is that eor is 'rare enough'. Quote:
Yet the instruction is extremely handy in many situations, and a gem for code density. I'd rather extend it. Quote:
Quote:
It doesn't have to be Amiga specific for us to talk about it. |
|||||||||||||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
68k & PPC CPU Usage monitor for OS3 | ancalimon | support.Apps | 1 | 29 June 2020 23:42 |
68k CPU pause (bubble) | kamelito | Coders. Asm / Hardware | 9 | 27 January 2020 15:09 |
Bad weather for the 68K socket cpu cards | Solderbro | support.Hardware | 0 | 14 July 2018 10:19 |
Looking to get max CPU performance in WinUAE 68k OS | GunnzAkimbo | support.WinUAE | 1 | 12 May 2016 11:18 |
Apollo / Phoenix CISC CPUs m68k compatible | Snake79 | News | 3 | 05 March 2015 20:20 |
|
|