Post History
x86-64 machine code, 27 bytes 6A D7 58 99 B1 10 48 D3 C0 48 AB C6 07 0A AE 80 C1 48 73 F2 FF C2 74 EC 88 37 C3 Try it online! Following the standard calling convention for Unix-like systems (f...
Answer
#2: Post edited
- # x86-64 machine code, 27 bytes
- 6A D7 58 99 B1 10 48 D3 C0 48 AB C6 07 0A AE 80 C1 48 73 F2 FF C2 74 EC 88 37 C3
- [Try it online!](https://tio.run/##TZHBTgIxEIbPnacY1xC7upBF0QOIB41HE2M8aIBDabtsTWmhXXCR@Oqug0j00DYz/z/fzKSyPZOyaUScI8enhENnZv1UWCyg6LPFKpbY7nUHuPALDKIGJtUSQq/P5n6N0maYT/M879LJIfRZ8HZny0gCFisfl/DjvH19vsfH5yccBWUmGZ6M3QkZpIhTYEKpA6q7ZwF7cxIDMEOPVtT27QNDb8/6RagSWNAVpAmmA1h7o7DgshThFCMl4Jhq7UppvI6VMr5T3gAYV@FcGMdT2NIqZMag48pWo8vu@WQArOD7mABsEche8KQVkwz/0n/C2D0IWRqnUXql@8lO3XWocYh5hhsKlcftwY6t/PyFUJsh5ysXzcxp2ns3cFqko/rsbJIOPvG9NFYj3@ARQeq7i/@TIG8ZnG4qHdOxI1JN4mfTfMnCills2vOrHl30l0Pya/sN "C (gcc) – Try It Online")
- Following the standard calling convention for Unix-like systems (from the System V AMD64 ABI), this takes in RDI a memory address at which to place the result, as a null-terminated byte string in [ISO-8859-1](https://en.wikipedia.org/wiki/ISO-8859-1).
- In assembly:
- ````
- f: push -41; pop rax # Set RAX to -41: low byte 0xD7, other bytes 0xFF.
- cdq # Set EDX to -1 by sign-extending EAX.
- r4: mov cl, 0b00010000 # Set CL to 2*8.
- r: rol rax, cl # Rotate RAX left by the value of CL.
- # CL will always be a multiple of 8; this moves the 0xD7 byte.
- stosq # Write RAX to the string, advancing the pointer.
- mov [rdi], '\n' # Add a line feed to the string.
- scasb # Advance past it while comparing it with AL.
- add cl, 0b01001000 # Add 1*8+64 to CL.
- jnc r # Jump if no carry; iterate 4 times.
- inc edx # Add 1 to EDX.
- jz r4 # Jump (here resetting CL) if it's 0.
mov [rdi], dl # Add a 0 byte from DL to the string.- ret # Return.
- ````
- The output is:
- ````
- ÿÿ×ÿÿÿÿÿ
- ÿÿÿÿÿ×ÿÿ
- ÿ×ÿÿÿÿÿÿ
- ÿÿÿÿÿÿ×ÿ
- ×ÿÿÿÿÿÿÿ
- ÿÿÿ×ÿÿÿÿ
- ÿÿÿÿÿÿÿ×
- ÿÿÿÿ×ÿÿÿ
- ````
- This solution was chosen for the pattern formed by the horizontal offsets between queen positions in adjacent rows, wrapping around and starting at 0; those offsets are 2, 3, 4, 5, 2, 3, 4, 5.
- # x86-64 machine code, 27 bytes
- 6A D7 58 99 B1 10 48 D3 C0 48 AB C6 07 0A AE 80 C1 48 73 F2 FF C2 74 EC 88 37 C3
- [Try it online!](https://tio.run/##TZHBTgIxEIbPnacY1xC7upBF0QOIB41HE2M8aIBDabtsTWmhXXCR@Oqug0j00DYz/z/fzKSyPZOyaUScI8enhENnZv1UWCyg6LPFKpbY7nUHuPALDKIGJtUSQq/P5n6N0maYT/M879LJIfRZ8HZny0gCFisfl/DjvH19vsfH5yccBWUmGZ6M3QkZpIhTYEKpA6q7ZwF7cxIDMEOPVtT27QNDb8/6RagSWNAVpAmmA1h7o7DgshThFCMl4Jhq7UppvI6VMr5T3gAYV@FcGMdT2NIqZMag48pWo8vu@WQArOD7mABsEche8KQVkwz/0n/C2D0IWRqnUXql@8lO3XWocYh5hhsKlcftwY6t/PyFUJsh5ysXzcxp2ns3cFqko/rsbJIOPvG9NFYj3@ARQeq7i/@TIG8ZnG4qHdOxI1JN4mfTfMnCills2vOrHl30l0Pya/sN "C (gcc) – Try It Online")
- Following the standard calling convention for Unix-like systems (from the System V AMD64 ABI), this takes in RDI a memory address at which to place the result, as a null-terminated byte string in [ISO-8859-1](https://en.wikipedia.org/wiki/ISO-8859-1).
- In assembly:
- ````
- f: push -41; pop rax # Set RAX to -41: low byte 0xD7, other bytes 0xFF.
- cdq # Set EDX to -1 by sign-extending EAX.
- r4: mov cl, 0b00010000 # Set CL to 2*8.
- r: rol rax, cl # Rotate RAX left by the value of CL.
- # CL will always be a multiple of 8; this moves the 0xD7 byte.
- stosq # Write RAX to the string, advancing the pointer.
- mov [rdi], '\n' # Add a line feed to the string.
- scasb # Advance past it while comparing it with AL.
- add cl, 0b01001000 # Add 1*8+64 to CL.
- jnc r # Jump if no carry; iterate 4 times.
- inc edx # Add 1 to EDX.
- jz r4 # Jump (here resetting CL) if it's 0.
- mov [rdi], dh # Add a 0 byte from DH to the string.
- ret # Return.
- ````
- The output is:
- ````
- ÿÿ×ÿÿÿÿÿ
- ÿÿÿÿÿ×ÿÿ
- ÿ×ÿÿÿÿÿÿ
- ÿÿÿÿÿÿ×ÿ
- ×ÿÿÿÿÿÿÿ
- ÿÿÿ×ÿÿÿÿ
- ÿÿÿÿÿÿÿ×
- ÿÿÿÿ×ÿÿÿ
- ````
- This solution was chosen for the pattern formed by the horizontal offsets between queen positions in adjacent rows, wrapping around and starting at 0; those offsets are 2, 3, 4, 5, 2, 3, 4, 5.
#1: Initial revision
# x86-64 machine code, 27 bytes 6A D7 58 99 B1 10 48 D3 C0 48 AB C6 07 0A AE 80 C1 48 73 F2 FF C2 74 EC 88 37 C3 [Try it online!](https://tio.run/##TZHBTgIxEIbPnacY1xC7upBF0QOIB41HE2M8aIBDabtsTWmhXXCR@Oqug0j00DYz/z/fzKSyPZOyaUScI8enhENnZv1UWCyg6LPFKpbY7nUHuPALDKIGJtUSQq/P5n6N0maYT/M879LJIfRZ8HZny0gCFisfl/DjvH19vsfH5yccBWUmGZ6M3QkZpIhTYEKpA6q7ZwF7cxIDMEOPVtT27QNDb8/6RagSWNAVpAmmA1h7o7DgshThFCMl4Jhq7UppvI6VMr5T3gAYV@FcGMdT2NIqZMag48pWo8vu@WQArOD7mABsEche8KQVkwz/0n/C2D0IWRqnUXql@8lO3XWocYh5hhsKlcftwY6t/PyFUJsh5ysXzcxp2ns3cFqko/rsbJIOPvG9NFYj3@ARQeq7i/@TIG8ZnG4qHdOxI1JN4mfTfMnCills2vOrHl30l0Pya/sN "C (gcc) – Try It Online") Following the standard calling convention for Unix-like systems (from the System V AMD64 ABI), this takes in RDI a memory address at which to place the result, as a null-terminated byte string in [ISO-8859-1](https://en.wikipedia.org/wiki/ISO-8859-1). In assembly: ```` f: push -41; pop rax # Set RAX to -41: low byte 0xD7, other bytes 0xFF. cdq # Set EDX to -1 by sign-extending EAX. r4: mov cl, 0b00010000 # Set CL to 2*8. r: rol rax, cl # Rotate RAX left by the value of CL. # CL will always be a multiple of 8; this moves the 0xD7 byte. stosq # Write RAX to the string, advancing the pointer. mov [rdi], '\n' # Add a line feed to the string. scasb # Advance past it while comparing it with AL. add cl, 0b01001000 # Add 1*8+64 to CL. jnc r # Jump if no carry; iterate 4 times. inc edx # Add 1 to EDX. jz r4 # Jump (here resetting CL) if it's 0. mov [rdi], dl # Add a 0 byte from DL to the string. ret # Return. ```` The output is: ```` ÿÿ×ÿÿÿÿÿ ÿÿÿÿÿ×ÿÿ ÿ×ÿÿÿÿÿÿ ÿÿÿÿÿÿ×ÿ ×ÿÿÿÿÿÿÿ ÿÿÿ×ÿÿÿÿ ÿÿÿÿÿÿÿ× ÿÿÿÿ×ÿÿÿ ```` This solution was chosen for the pattern formed by the horizontal offsets between queen positions in adjacent rows, wrapping around and starting at 0; those offsets are 2, 3, 4, 5, 2, 3, 4, 5.