Mac users can also change directory to the app’s /Contents/MacOS folder
Then chmod +x Digital\ Logic\ Sim
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
@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.
@l0: .data 0,0,@l2+3,0,0,0,0,0,0,0,0,0,0,0,0,0 @l1: .data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 @l2: .data 0,0,0,0,0,@l3+3,0,0,0,0,0,0,@l3+10,0,0,0 @l3: .data 0,0,0,0,0,@l4+3,0,0,0,0,0,0,@l4+10,0,0,0 @l4: .data 0,0,0,0,0,@l5+3,0,0,0,0,0,0,@l5+10,0,0,0 @l5: .data 0,0,0,0,0,@l6+3,0,0,0,0,0,0,@l6+10,0,0,0 @l6: .data 0,0,0,0,0,@l7+3,0,0,0,0,0,0,@l7+10,0,0,0 @l7: .data 0,0,0,0,0,@l2+10,0,0,0,0,0,0,@lc+2,0,0,0 @l8: .data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 @l9: .data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 @la: .data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 @lb: .data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 @lc: .data 0,0,0,0,@ld+3,0,0,0,0,0,0,0,0,@l2+3,0,0 @ld: .data 0,0,0,0,0,@le+5,0,0,0,0,0,0,@lc+11,0,0,0 @le: .data 0,0,0,0,0,0,0,@le+8,0,0,@ld+10,0,0,0,0,0 @lf: .data 0,0,0,0,0,0,0,0,0,0,0,0,0
This traces a smiley face using the current highlighted instruction in the memory block.
Writing the bytes yourself as data doesn't change "bytes read" but it can help you realize a simpler solution for First Assessment:
(SOLVED; cycles: 8, bytes: 11)
subleq 0, @IN subleq @OUT, 0
Once the program jumps to address 6, the instruction is essentially
subleq 0, 0, 0
and will automatically clear address 0 and jump there for you.