Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

SIC-1 Solutions

Forum for posting SIC-1 solutions · By jaredkrinke

Small byte optimization tip

A topic by trimute2 created Jul 27, 2022 Views: 251 Replies: 2
Viewing posts 1 to 3
(1 edit) (+1)

Not a solution but I felt that it would fit here. If your solution starts by taking an input like this


subleq @input @IN
;rest of the program

@input: .data 0

you can use one less byte by instead writing


@input: .data 0

.data @IN

.data 3

This works since the first address is 0 and as long as the value at address 0 is 0 it is going to modify itself. This only works as long as whenever that line is reached @input is equal to 0, as a bonus any byte that refrences @Input can be used as a constant for 0.

Developer

Great suggestion! Also, this optimization may make code less readable, thus ensuring continued employment ;)

(+1)

you don't actually have to make in unreadable - 'cos doing the following works just as well:

@loop:
@input:
subleq @input, @IN

the action of putting a label inside its own address already creates the right value, AND you can use multiple labels at the same address for more readability

another option is to write explicit 0 there instead:

@loop: 
@input: 
subleq 0, @IN