Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

SIC-1 Solutions

Forum for posting SIC-1 solutions · By jaredkrinke

Interleave

A topic by jaredkrinke created Dec 10, 2022 Views: 141
Viewing posts 1 to 1
Developer

149 cycles, 62 bytes

@loop:
subleq @tmp, @IN
subleq @tmp2, @tmp2
subleq @tmp2, @tmp, @dequeue
@queue:
subleq @stack, @tmp2
subleq @count, @n_one
subleq @queue, @n_one
subleq @tmp, @tmp, @loop
@dequeue:
subleq @OUT, @stack
subleq @tmp, @IN
subleq @OUT, @tmp
subleq @dequeue+1, @n_one
subleq @tmp, @tmp
subleq @count, @one, @done
subleq @tmp, @tmp, @dequeue
@done:
subleq @OUT, @IN, @loop
; Constants
@one: .data 1
@n_one: .data -1
; Variables
@tmp: .data 0
@tmp2: .data 0
@count: .data 0
; Base of stack (stack will grow upwards)
@stack: .data 0