Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

SIC-1 Solutions

Forum for posting SIC-1 solutions · By jaredkrinke

6.2 Decimal Digits Solution: (cycles: 11, bytes: 14)

A topic by nad2040 created Sep 09, 2022 Views: 137 Replies: 2
Viewing posts 1 to 2
(+1)
@program: .data 0, @IN, 3, 0, 8, 6, @OUT, 0, -48, 0, 0, 0

If a command is guaranteed to output a positive number to @OUT, the jump address can be used to store a number. Thus, bytes read can be reduced by one. And writing the bytes by hand allows negative numbers and characters so you don't have to subtract from 256 every time.

Developer

Well done!

For the comment about writing bytes by hand, is that different from just negating a character value (i.e. ".data -'0'")?

(1 edit) (+1)

If I use subleq, I would have to use the value range 0-255, and so instead, I write the bytes in the .data directive to use the - sign so it’s slightly easier to understand. By writing the bytes ‘by hand’ in the .data directive, I also have to handle the jumps, which are normally handled by the assembler.

Example:

subleq @OUT 2 -‘0’ isn’t allowed, but you can subtract from 256
subleq @OUT 2 208 is what it will be, but it’s less expressive
So,
@prog: .data @OUT, 2, -‘0’ is the best choice in my opinion