Welcome, Guest. Please login or register.

Author Topic: Imaginary 64-bit 680x0  (Read 5119 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Imaginary 64-bit 680x0
« on: March 10, 2022, 07:55:41 PM »
Have you ever wondered what it would be like to have a 64-bit 68000? Not specifically the hardware architecture per se, bur the familiar programming environment? Of all the assembly languages I ever learned, 68000 was my favourite. During lockdown, a few of us wondered about it a bit too much, so we decided to build our own. We aren't hardware engineers bur I've implemented a few virtual machines in my time, so we went that route...

https://youtu.be/3W7gG8MXit4

int p; // A
 
The following users thanked this post: gertsy

Offline nicholas

Re: Imaginary 64-bit 680x0
« Reply #1 on: March 16, 2022, 03:09:11 PM »
Have all the creatives left?  :'(
“Een rezhim-i eshghalgar-i Quds bayad az sahneh-i ruzgar mahv shaved.” - Imam Ayatollah Sayyed  Ruhollah Khomeini
 

Offline BozzerBigD

Re: Imaginary 64-bit 680x0
« Reply #2 on: March 16, 2022, 04:21:24 PM »
@Karlos

It would just address more memory, I can't see what other difference it would make and it would be pointless unless 64-bit apps became standard.
"Art challenges technology. Technology inspires the art."

John Lasseter, Co-Founder of Pixar Animation Studios
 

Offline nicholas

Re: Imaginary 64-bit 680x0
« Reply #3 on: March 16, 2022, 11:03:09 PM »
Whoosh!

Here is there repo. The readme is quite upfront about what this is and why we are doing it.

https://github.com/intuitionamiga/mc64000
“Een rezhim-i eshghalgar-i Quds bayad az sahneh-i ruzgar mahv shaved.” - Imam Ayatollah Sayyed  Ruhollah Khomeini
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Imaginary 64-bit 680x0
« Reply #4 on: March 16, 2022, 11:16:47 PM »
@BozzerBigD - I think you may have missed the point of this. It's not about what difference it would make to end users, it's about what it might be like to write code for. When AMD extended the x86 to 64 bit, it wasn't just wider registers, there were more of them, newer instructions, etc.

For MC64K, for example, we merged the integer and address registers into 16 64-bit ones. Similarly we increased the FPU to 16 registers too. We also allowed effective addressing modes to be used for source and destination operands for all dyadic instructions that made sense and likewise made some of the monadic ones dyadic. As we were making a virtual machine to run the code on we were free to experiment in this way without worrying about how difficult it would be to implement in in silicon.

int p; // A
 

Offline psxphill

Re: Imaginary 64-bit 680x0
« Reply #5 on: March 17, 2022, 07:40:02 AM »
Is it really a 64 bit 680x0 though?

It kinda reminds me more of a 64bit MIPS cpu.
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Imaginary 64-bit 680x0
« Reply #6 on: March 17, 2022, 10:10:58 AM »
Is it really a 64 bit 680x0 though?

It kinda reminds me more of a 64bit MIPS cpu.

It's a virtual machine so any similarity to any silicon (living or dead) is coincidental. MIPS is a load-store, register-to-register RISC style architecture. MC64K is not. You can use most of the familiar 68000 addressing modes for each operand. It just doesn't support the "memory indirect" modes added in the 020. It's also much easier (and preferred) to write position independent code because branch offsets are 32-bit and you'd be doing well to create bytecode gigabytes in size.

The largest divergence from 680x0 is in the handling of conditional logic. Maintaining a status register is a pain and for the vast majority of executed instructions it's wasted effort since the condition codes are not used. Instead we implemented a "compare and branch" model for simplicity. We aren't creating a simulator or emulator and accept that this will not be able to do "anything a 68000 can" because it doesn't do overflow or carry, for example. However for the things it can do, you can often do in fewer instructions because there are wider types, more available registers, ability to use effective addresses for both source and destination at the same time, etc.

These simplifications allow the bytecode interpreter to run at speeds that make it actually fun to play with. The simple Rotozoom demo in the video, for example, is running full RGB 640*480 at 30fps with time to spare despite being the most naive implementation I could think of. Factoring in the idle time and instructions per pixel, it's about 350 MIPS on my laptop (i7-7500U). Not going to win any prizes but it's adequately fast enough for most things. Obviously a JIT would be better but that's a long way off.

int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Imaginary 64-bit 680x0
« Reply #7 on: March 17, 2022, 11:25:29 AM »
It's also little endian, so there's that I suppose. Not as big of a deal as it sounds as it's not an emulator and doesn't have to have binary compatibility with anything. The choice was dictated by the fact the immediate target hosts are x64 and AArch64. It means little from an assembly language perspective since registers have always behaved little endian on 68000 and the only gotcha is when accessing memory at the same address.
int p; // A
 

Offline AJCopland

Re: Imaginary 64-bit 680x0
« Reply #8 on: March 18, 2022, 02:14:32 PM »
It's cool that you can just decide to create a virtual CPU because it's fun!

Interesting and cool work
Be Positive towards the Amiga community!
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Imaginary 64-bit 680x0
« Reply #9 on: March 18, 2022, 09:10:20 PM »
It's cool that you can just decide to create a virtual CPU because it's fun!

Exactly. We were having a nostalgic conversation about the days when assembler was fun to write and still legible, things we'd wished the 68000 had, or had done differently from a user programming perspective.

Designing bytecode machine was pretty easy as I've done more than one in the past. By far the largest effort was actually writing the assembler tool itself. It's not especially brilliant but it does work.
Right now the focus is on building a "host" that provides the IO, graphics, audio etc. that are exposed through a trap like mechanism.
int p; // A
 

Offline Pyromania

  • Sent from my Quantum Computer
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 1820
  • Country: 00
  • Thanked: 6 times
    • Show only replies by Pyromania
    • http://www.discreetfx.com
Re: Imaginary 64-bit 680x0
« Reply #10 on: March 18, 2022, 10:32:23 PM »
Very cool project.
 

Offline psxphill

Re: Imaginary 64-bit 680x0
« Reply #11 on: March 19, 2022, 11:29:54 AM »
Obviously a JIT would be better but that's a long way off.

Even lazy flag calculation in an interpreter would be a win, I did that when I wrote an interpreter in 6502 assembler.

The no flags is what made me think of MIPS, but then 88100 doesn't appear to have flags either. But the 68k does.

You can create a virtual CPU if you want, I just think it's not inspired enough by the 68k to make a big deal out of it.

6502 was inspired by pdp11, but that was never once mentioned in documentation.
 

Offline nicholas

Re: Imaginary 64-bit 680x0
« Reply #12 on: March 19, 2022, 12:30:15 PM »
 
Quote
6502 was inspired by pdp11, but that was never once mentioned in documentation.

As was the 68000, which is sod all like the 6502.

mc64k is inspired by the 68k because that's what we know and love the best.

Feel free to use it or not. No skin off our noses.
“Een rezhim-i eshghalgar-i Quds bayad az sahneh-i ruzgar mahv shaved.” - Imam Ayatollah Sayyed  Ruhollah Khomeini
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Imaginary 64-bit 680x0
« Reply #13 on: March 19, 2022, 12:35:04 PM »
I think you're conflating the implementation specifics with the intent. The intent is to provide a programming experience familiar to those used to writing 680x0 assembly but providing 64 bit support. The no flags implementation was a simplification trade off. If your code is mostly comprised mostly of conditional branching instructions then sure, it's going to less familiar. You're also probably doing something a bit weird.

The Rotozoom demo code his here: https://github.com/IntuitionAmiga/MC64000/blob/main/assembler/test_projects/rotozoom/src/main.s

I'm sure most 68000 programmers would have no difficulty understanding it and navigating the differences from actual 68000.
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Imaginary 64-bit 680x0
« Reply #14 on: March 19, 2022, 12:54:05 PM »
Quote
Even lazy flag calculation in an interpreter would be a win, I did that when I wrote an interpreter in 6502 assembler

For an emulator yes. For an interpreter? Why? Unless you intend to support arithmetic overflow and other special cases, I can't think of a single reason to implement it. If you want to take a branch because an operand is zero, not zero or bigger than some other operand, comparing them directly means you don't have to evaluate the side effects of any operation.
int p; // A