Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A two instruction set computer that greatly speeds things up over SUBLEQ

License

NotificationsYou must be signed in to change notification settings

howerj/muxleq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THE ORIGINAL MUXLEQ.

A faster SUBLEQ variant called MUXLEQ. SUBLEQ is a single instruction machine,this is a two instruction machine. By just adding one instruction is becomes possible tospeed up the system dramatically whilst also reducing the program size. Themachine is not much more complex, and it would still be trivial to implement thesystem in hardware.

SUBLEQ programs can (usually) run unaltered on the MUXLEQ CPU.

MUXLEQ runs a Forth interpreter, a programming language, as a test program.To run, type:

make run

This requires a C compiler and make to be installed.

The pseudo code for this SUBLEQ variant, MUXLEQ, is:

while pc >= 0:a = m[pc + 0]b = m[pc + 1]c = m[pc + 2]pc = pc + 3if a == -1:m[b] = get_byte()else if b == -1:put_byte(m[a])else if c != -1 and c < 0:m[b] = (m[a] & ~m[c]) | (m[b] & m[c])else:r = m[b] - m[a]if r <= 0:pc = cm[b] = r

Removing the lineelse if c != -1 and c < 0: along with the clause turnsthis variant back into a SUBLEQ machine.

Possible variants to pack as much functionality as possible in would include:

  • A pure single instruction muxleq variant, this would have the problem thatshifting bits in either direction would be expensive, however it would be aninteresting comparison to SUBLEQ.
  • Bit reversal, the resulting multiplexed value could have its bits reversed.This could be folded into themux instruction.
  • Right shift, even if only by one place.
  • Comparison, the result of comparingm[a] andm[b] could be stored inm[a], useful comparisons would beis zero?, signed or unsigned less thanor greater than. Any of those five would be useful.
  • The paperhttps://janders.eecg.utoronto.ca/pdfs/esl.pdf "Subleq(?): AnArea-Efficient Two-Instruction-Set Computer" extends SUBLEQ in a differentway using bit-reversal that should lend itself to a hardware implementationthat uses minimal extra resources as the structure of the new instructionis very similar SUBLEQ. If thec operand is negative it computesr = reverse(reverse(m[b]) - reverse(m[a])). This turns the less than orequal to zero branch into a branch on evenness, allowing a quicker rightshift to be implemented using minimal resources.reverse reverses allbits in a cell.

This variant greatly speeds up loading, storing and the bitwise operations,even with minimal effort. There are a few features missing from this MUXLEQvariant (such as the "self-interpreter") and as such have been disabled. Nodoubt if more effort was expended many more performance gains could be made.

The old SUBLEQ only version of the Forth interpreter can be run with:

make old

This is useful for speed tests.

This project could contain alternative SUBLEQ instructions and improvementsin the future,altleq might be a better name for the project.

gforth can be used to build the images from eithermuxleq.fth orsubleq.fth, but the Forth systems are self-hosting so you can usethem to build the new images if you modify either Forth source file.

References

About

A two instruction set computer that greatly speeds things up over SUBLEQ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp