# Mira ISA (5-tick CPU made by Alex\_you and Embizone

**URL:** <https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935>\
**Category:** Projects\
**Created:** [May 28, 2022, 11:17pm UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935 "2022-05-28T23:17:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![embizone](https://discourse.openredstone.org/letter_avatar_proxy/v4/letter/e/13edae/32.png) [@embizone](https://discourse.openredstone.org/u/embizone)\
**Post date:** [May 28, 2022, 11:17pm UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/1 "2022-05-28T23:17:16Z")

</div>

Hey there,

I think people have been waiting for this for over year. I wrote a blog post describing the ISA used in the 5-tick CPU Alex and I made: [Mira | chariotsofiron](https://chariotsofiron.github.io/mira/)

Whoever implements Collatz Conjecture in fewest bytes wins.

Lots of love,

Embi

---

<div class="post-metadata">

**Author:** ![Kuggo](https://discourse.openredstone.org/user_avatar/discourse.openredstone.org/kuggo/32/112_2.png) [@Kuggo](https://discourse.openredstone.org/u/Kuggo)\
**Post date:** [May 29, 2022, 10:52am UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/2 "2022-05-29T10:52:59Z")

</div>

Here is my attempt (uses 3 registers and assumes the input is on value, and output will be on register b):

```
value: .i16 13 ; number we start with
mov b, 0 ; number of iterations
start: mov a, value
loop: cmp b, 1
      bec end ; branch if equal
      inc b ; increment iterations
      mov x, a ; save a copy of acc
      shr a ; try to shr
      bcs odd ; if it generate carry: its odd
      jmp loop
odd: mov a, x ; restore acc
      shl a ; mlt by 2
      add x ; add the copy (mlt by 3)
      inc a ; add 1
      jmp loop
end:  

```

note: im not sure i did the conditions correctly as im not familiar with the isa. i could optimize this if i knew how to ‘branch if not carry’ in 1 instruction.  
edit: optimised 3 lines so it takes 1 less instruction.

---

<div class="post-metadata">

**Author:** ![embizone](https://discourse.openredstone.org/letter_avatar_proxy/v4/letter/e/13edae/32.png) [@embizone](https://discourse.openredstone.org/u/embizone)\
**Post date:** [May 29, 2022, 11:49am UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/3 "2022-05-29T11:49:27Z")

</div>

Awesome submission! Sorry conditional branching was not clearer, I have added a sentence to the blog post to hopefully clarify. For each flag (N Z V C), you have two branch instructions, for e.g. for the carry flag, you have bcc (branch if carry clear) and bcs (branch if carry set). Your 3n+1 logic is perfect. Also perhaps instead of counting number of iterations, you could print the value using an instruction like

```
mov TICKER, a ; print value to ticker-tape device

```

If you replace the iteration count logic with a print, and assume the correct value is already in A, I count 18 bytes. There are a few tricks you could use to shave off some more bytes 🙂

In the meantime, here’s a neat program that swaps the nibbles in the accumulator i.e. 0x96 becomes 0x69:

```
; swap the nibbles of A
shl a
adc 0x80
rol a
shl a
adc 0x80
rol a
```

---

<div class="post-metadata">

**Author:** ![Tukeque](https://discourse.openredstone.org/user_avatar/discourse.openredstone.org/tukeque/32/54_2.png) [@Tukeque](https://discourse.openredstone.org/u/Tukeque)\
**Post date:** [May 29, 2022, 11:54am UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/4 "2022-05-29T11:54:25Z")

</div>

Yo embi your cpu is absolutley amazing. I may even take some stuff for my own designs, specially the addressing modes, love that  
Could you link some screenshots of the cpu and maybe some of the devices like the ticker? I would like to see them  
Could you also elaborate how your memory is managed? How big are your pages? How do you load them? What does the programmer have to do to manage them or do they not manage them?  
im too lazy to write collatz btw 😛

Also how do you manage to jump if your program counter is a shift register?

---

<div class="post-metadata">

**Author:** ![Kuggo](https://discourse.openredstone.org/user_avatar/discourse.openredstone.org/kuggo/32/112_2.png) [@Kuggo](https://discourse.openredstone.org/u/Kuggo)\
**Post date:** [May 29, 2022, 6:10pm UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/5 "2022-05-29T18:10:06Z")

</div>

> [@embizone](#):
>
> There are a few tricks you could use to shave off some more bytes 🙂

Im sure there are, im not used to write stuff for accumulator based cpus. Im more used to write in 3op (urcl cough cough). Tho atm i can only see 2 things: replacing the 2 branches i used to make branch if odd with 1, and using the temporary register, instead of reverting the changes. In fact ill edit the post including that change

---

<div class="post-metadata">

**Author:** ![embizone](https://discourse.openredstone.org/letter_avatar_proxy/v4/letter/e/13edae/32.png) [@embizone](https://discourse.openredstone.org/u/embizone)\
**Post date:** [May 31, 2022, 6:38pm UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/6 "2022-05-31T18:38:06Z")

</div>

Here’s my solution:

```
; Collatz conjecture (14 bytes)
; starting value in A
loop: mov TICKER, a ; print value
        shr a ; divide by 2
        bzs end ; if we hit 0 we're done
        bcc loop ; loop while even
        rol a ; restore true odd value
        mov b, a ; compute a = 3a+1
        shl a
        add b
        inc a ; a = 3a+1 at this point
        jmp loop
end:
```

---

<div class="post-metadata">

**Author:** ![FireTner](https://discourse.openredstone.org/user_avatar/discourse.openredstone.org/firetner/32/2068_2.png) [@FireTner](https://discourse.openredstone.org/u/FireTner)\
**Post date:** [June 7, 2022, 12:19pm UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/7 "2022-06-07T12:19:27Z")

</div>

Memory isn’t managed by the CPU; it is completely external. The CPU stalls on reads until memory indicates it has finished reading. Writing happens without stalling. The memory banking is a suggestion as to how to increase memory size. So far from what I’ve heard, there isn’t any built yet.

How can you jump on a shift register? Simply clear the shift register and set a bit at the decoded address.

---

<div class="post-metadata">

**Author:** ![Alex\_you](https://discourse.openredstone.org/user_avatar/discourse.openredstone.org/alex_you/32/839_2.png) [@Alex\_you](https://discourse.openredstone.org/u/Alex_you)\
**Post date:** [September 9, 2024, 9:50pm UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/8 "2024-09-09T21:50:26Z")

</div>

Hi, please note that the ISA in the link is slightly outdated. Here is the correct one:

 ![image](https://discourse.openredstone.org/uploads/default/original/2X/0/073cdcd62a4df24081f4fa9e65fadf952ea15502.png)

---

<div class="post-metadata">

**Author:** ![jobe](https://discourse.openredstone.org/user_avatar/discourse.openredstone.org/jobe/32/5061_2.png) [@jobe](https://discourse.openredstone.org/u/jobe)\
**Post date:** [September 11, 2024, 4:20am UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/9 "2024-09-11T04:20:38Z")

</div>

Looks nice (even tho I mostly do 3op), but why post 2 yrs later? Lol

---

<div class="post-metadata">

**Author:** ![system](https://discourse.openredstone.org/uploads/default/original/1X/3751cb7164d949629ccd5dd712d1e65996e22e97.png) [@system](https://discourse.openredstone.org/u/system)\
**Post date:** [August 23, 2026, 6:57pm UTC](https://discourse.openredstone.org/t/mira-isa-5-tick-cpu-made-by-alex-you-and-embizone/1935/10 "2026-08-23T18:57:49Z")

</div>

Closed on August 23, 2026, 6:57pm UTC


