6
\$\begingroup\$

I'd like to start a series of challenges for http://box-256.com/ starting with the first challenge, “BIG SQUARE II”. After this one I'll add another for "CHECKERBOARD" and so on.

enter image description here

Rules:

  • Complete the BIG SQAURE II challenge in the Box-256 emulator (either on the website or download the program if you run Windows)
  • Post back here a screenshot of your working answer
  • You MUST include the code in plain text so that others can easily copy and very it’s operation.

Scoring:

The winner will be the least amount of instructions used (just the instruction calls, either by name or opcode, the arguments to them are not counted as JMP takes one argument but MOD can take three).

I think in the future contests we can add some additional bonus points for use of coding tricks and we could include the argument count too. I wanted to start basic to get the ball rolling.

Winning

I think we should put a stake in the ground and say two weeks from today we announce the winner(s, there maybe be mutliple entries with the same instruction count).

\$\endgroup\$
  • 1
    \$\begingroup\$ I'm confused It says BIGSQUARE in the title but you should solve BIGSQUARE2?? \$\endgroup\$ – CalculatorFeline Apr 15 '16 at 1:06
  • \$\begingroup\$ @CatsAreFluffy Thanks for pointing that out, I have amended the title. It should have been BIG SQUARE II since the first BIG SQUARE challenge is already solved on the box-256 homepage with a very efficient answer. \$\endgroup\$ – jwbensley Apr 15 '16 at 7:33
  • \$\begingroup\$ How about we score by memory rows? \$\endgroup\$ – CalculatorFeline Apr 15 '16 at 15:20
  • 1
    \$\begingroup\$ @jwbensley please can you clairify the scoring. 1) will data lines with no instruction / opcode count towards the score? 2) will overlapping / misaligned code count as the number of instructions they actually execute or the number of lines they occupy? \$\endgroup\$ – impomatic Apr 19 '16 at 10:49
  • 1
    \$\begingroup\$ @jwbensley 3) does executing empty memory / invalid instructions count towards the score? (e.g. if I leave off the final JMP at the end of the code and let the program execute the unused memory before returning to 00) \$\endgroup\$ – impomatic Apr 21 '16 at 14:21
4
\$\begingroup\$

1 instruction

This solution is to illustrate that counting instructions is not a proper way of scoring for BOX-256.

JMP 002 072 00C
002 000 013 00C
001 00C 055 002
010 000 000 000
011 012 013 014
015 016 017 018
019 01A 01B 01C
01D 01E 021 022
023 024 025 026
027 028 029 02A
02B 02C 02D 02E
0D1 0D2 0D3 0D4
0D5 0D6 0D7 0D8
0D9 0DA 0DB 0DC
0DD 0DE 0E1 0E2
0E3 0E4 0E5 0E6
0E7 0E8 0E9 0EA
0EB 0EC 0ED 0EE
031 041 051 061
071 081 091 0A1
0B1 0C1 032 042
052 062 072 082
092 0A2 0B2 0C2
03D 04D 05D 06D
07D 08D 09D 0AD
0BD 0CD 0ED 03E
04E 05E 06E 07E
08E 09E 0AE 0BE
0CE 000 000 000

screenshot

\$\endgroup\$
  • \$\begingroup\$ Do you need JMP 002? \$\endgroup\$ – CalculatorFeline Apr 15 '16 at 1:13
  • 1
    \$\begingroup\$ @CatsAreFluffy Sadly it's not possible to directly set the instruction pointer in BOX-256 as an initial parameter, so you need an initial instruction. \$\endgroup\$ – orlp Apr 15 '16 at 1:17
  • \$\begingroup\$ Hmm...Well how do you get the plaintext version of the programs? \$\endgroup\$ – CalculatorFeline Apr 15 '16 at 1:33
  • 1
    \$\begingroup\$ JMP with @ ≠ JMP with 0 ≠ JMP with * \$\endgroup\$ – CalculatorFeline Apr 15 '16 at 15:20
  • 1
    \$\begingroup\$ @impomatic Maybe, I haven't tried :) But LOC is still wrong. We should just score by bytes. \$\endgroup\$ – orlp Apr 16 '16 at 19:14
9
\$\begingroup\$

8 instructions

My smallest solution to the Big Square II challenge is 8 lines of code. There's a simple loop which cycles through a table of 8 pixel locations.

; Big Square II in 0x08h instructions
; John Metcalf

PIX @18 002 000
ADD @16 @18 @18
MOV @18 @20 001
MOV @19 @18 008
FLP @16 @17 001
JMP @00 001 010
011 031 021 032
0D3 01D 0E3 01E

BOX-256 Big Square II

\$\endgroup\$
  • 1
    \$\begingroup\$ Welcome to Programming Puzzles & Code Golf! Since this challenge scores by number of instructions, please include your instruction count in the post. With some more text, perhaps an explanation, you should be able to add the code and pass the spam filter. \$\endgroup\$ – Alex A. Apr 14 '16 at 19:57
  • 2
    \$\begingroup\$ You really need to include the code. If the system isn't letting you, include a link to a GitHub Gist and a higher-rep user like myself can edit it in for you. \$\endgroup\$ – Mego Apr 14 '16 at 19:58
  • \$\begingroup\$ Thanks for the suggestion. I've added an external link to the code. \$\endgroup\$ – impomatic Apr 14 '16 at 20:09
  • 1
    \$\begingroup\$ I edited in the code for you as well as the number of instructions (assuming I'm interpreting your code correctly as 9 instructions). \$\endgroup\$ – Alex A. Apr 14 '16 at 20:10
  • 2
    \$\begingroup\$ This comment belongs on the original question or on @orlp.'s answer but I haven't got enough reputation to comment there. I believe the scoring should be restated as "the lowest lines of code as counted by the Box-256 emulator" so tables of data, hand-assembled instructions and misaligned instructions count towards the total. \$\endgroup\$ – impomatic Apr 15 '16 at 5:44
3
\$\begingroup\$

11 instructions, 12 lines

PIX 011 002 000
ADD @01 @2C @01
ADD @03 001 @03
JGR 00D @03 @00
MOV 000 @03 000
ADD @06 001 @06
JGR 030 @06 @00
MOV 022 @01 000
MOV 02C @06 000
MOV 00B @0D 000
JMP @00 000 000
001 010 -01 -10

Any bonus for self-modification?

(Note the differences between the memory and the command line, specifically in locations @01 @06, @0D.)

Note the differences between the memory and the command line.

\$\endgroup\$
0
\$\begingroup\$

I think my answer is probably what you were suggesting @orlp ?

I've used 3 instrutions, PIX, ADD and JMP, the rest are the co-ordinates (however the instructions and coordinates are spaced out below for easier reading):

000 000 000 000
000 000 000 000
PIX @2C 002 000
ADD 001 @09 @09
JMP @08 000 000
000 000 000 000
000 000 000 000
000 000 000 000
000 000 000 000
000 000 000 000
000 000 000 000
011 012 013 014
015 016 017 018
019 01A 01B 01C
01D 01E 021 022
023 024 025 026
027 028 029 02A
02B 02C 02D 02E
031 032 03D 03E
041 042 04D 04E
051 052 05D 05E
061 062 06D 06E
071 072 07D 07E
081 082 08D 08E
091 092 09D 09E
0A1 0A2 0AD 0AE
0B1 0B2 0BD 0BE
0C1 0C2 0CD 0CE
0D1 0D2 0D3 0D4
0D5 0D6 0D7 0D8
0D9 0DA 0DB 0DC
0DD 0DE 0E1 0E2
0E3 0E4 0E5 0E6
0E7 0E8 0E9 0EA
0EB 0EC 0ED 0EE

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Yes, this is why I don't think counting instructions is a good idea. \$\endgroup\$ – orlp Apr 15 '16 at 15:24
  • \$\begingroup\$ @orlp - Can you expand a bit more on why? I want to gather up all the feedback from this question/challenge to make the next one better. \$\endgroup\$ – jwbensley Apr 17 '16 at 11:10
  • \$\begingroup\$ Big data tables rake 3 instructions but many more bytes, but the 9 instruction solution spends around 8 bytes on tables. \$\endgroup\$ – CalculatorFeline Apr 17 '16 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.