Chit Chat

Joined
Sep 20, 2022
Messages
277
Reaction score
40
Not much discussion happening on the forum lately.

I have no code to share, none of my programs do anything interesting.

I've been reverse engineering Devin Kilminster's prime number generator.

Its a 9 number program, written in FRACTRAN. On one level its cryptic spaghetti, on another, its a work of art.

Just my opinion.
 
Joined
Sep 20, 2022
Messages
277
Reaction score
40
If fractions are lines, and using a fraction is executing that line, then I wrote a version of a FRACTRAN interpreter that traced for each line, which lines came next.

The output is not the full picture, but allowed me to make a diagram, similar to a state transition diagram.

The diagram gave me a feel for what was happening, and what each register means. It also clarified that it was using exactly the same algorithm as Conway's except the test factor was starting at 2 and increasing.

From here I wrote a little pseudocode and comments for each line. Only 4 GOTOs, so there wasn't much spaghetti.

It did use an interesting trick for controlling the jumps, much better than Conway's state flags, which I will steal.
 
Joined
Sep 20, 2022
Messages
277
Reaction score
40
I've just had a look at Conway's paper. I should have read this first, but I just assumed it would be way over my head and that all the salient details were in the book/article that I was reading.

His flowcharts are much better than my diagrams. Using different arrowheads for precedence is a good idea.
 
Joined
Sep 20, 2022
Messages
277
Reaction score
40
It is a good chat program.

I ask it 3 types of questions: things I want to know, and can verify; things I already know, to test ChatGPT itself; nonsense, just to have a bit of fun.

I think its 90% google search and 10% Eliza.

The last thing I asked it about, it got a bit wrong. I didn't want to give it any feedback because then the next person to ask the same question might get a slightly better answer, giving the impression that ChatGPT is better than it really is.
 
Joined
Sep 20, 2022
Messages
277
Reaction score
40
I wrote a 56 fraction program to calculate the integer square root of a number, using Hero's method.

Not my best work, but my goal was to create subroutines.

The argument passing and return value are implemented similar to using global variables in BASIC.

Its already a nightmare to debug, what I need now is a stack, to pass arguments and have local variables.

Not sure yet how to do that.
 
Joined
Sep 20, 2022
Messages
277
Reaction score
40
A register could hold a stack, using a predefined BASE. Pushing X would be multiplying by BASE and adding X. Popping into X would be dividing by BASE, putting the remainder into X.

The only downside is there is no random access, so I can't use a stack for local variables.

That's a 8086 assembly idea, to have more variables than registers, and not the only way to skin this rabbit.

FRACTRAN has no register limit, so my subroutines could push any registers, use them, then restore (pop) them before returning.

This is going to run like a slug, but should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,344
Messages
2,571,423
Members
48,794
Latest member
massivestack

Latest Threads

Top