Skip to main content
Improvement
Source Link
m90
  • 12.5k
  • 1
  • 14
  • 51

x86-64 machine code, 1717 15 bytes

B0 41 AAE6 04 01 3C5B 4CAA 742C FA4B 3C 5A01 7614 F5F1 C675 07F5 00AA C3 

Try it online!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 assembly:

f: mov al, 'A'-26  # Set AL to the first letter, 'A'-26. r: stosbadd al, 'Z'+1 # Add #this Writevalue to AL to theproduce outputa string,letter.  advancing the pointer. b: stosb add al, 1 # Add 1 to # Write AL to get the nextoutput letterstring, advancing the pointer. cmpsub al, 'L''K'  # CompareSubtract it'K' tofrom 'L'..AL. jecmp bal, 1 # Set andflags iffrom it'scalculating equal,AL jump- back1. toCF addis 1 againiff AL is 0. cmpadc al, 'K'-'Z' # CompareAdd it(this value + CF) to 'Z'.AL. The net change is +1 or +2. jbejnz r # and if it's# lessIf thanthe orresult equalis nonzero, repeat the loop. movstosb BYTE PTR [rdi], 0 # Add a null terminator to# theWrite string. AL (0) to the retoutput string, advancing the pointer.  ret # Return. 

x86-64 machine code, 17 bytes

B0 41 AA 04 01 3C 4C 74 FA 3C 5A 76 F5 C6 07 00 C3 

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 assembly:

f: mov al, 'A' # Set AL to the first letter, 'A'. r: stosb # Write AL to the output string, advancing the pointer. b: add al, 1 # Add 1 to AL to get the next letter. cmp al, 'L' # Compare it to 'L'... je b # and if it's equal, jump back to add 1 again. cmp al, 'Z' # Compare it to 'Z'... jbe r # and if it's less than or equal, repeat the loop. mov BYTE PTR [rdi], 0 # Add a null terminator to the string.  ret # Return. 

x86-64 machine code, 17 15 bytes

B0 E6 04 5B AA 2C 4B 3C 01 14 F1 75 F5 AA C3 

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 assembly:

f: mov al, -26  # Set AL to -26. r: add al, 'Z'+1 # Add this value to AL to produce a letter.  stosb  # Write AL to the output string, advancing the pointer. sub al, 'K'  # Subtract 'K' from AL. cmp al, 1 # Set flags from calculating AL - 1. CF is 1 iff AL is 0. adc al, 'K'-'Z' # Add (this value + CF) to AL. The net change is +1 or +2. jnz r # If the result is nonzero, repeat the loop. stosb # Write AL (0) to the output string, advancing the pointer.  ret # Return. 
Correction in the explanation
Source Link
m90
  • 12.5k
  • 1
  • 14
  • 51

x86-64 machine code, 17 bytes

B0 41 AA 04 01 3C 4C 74 FA 3C 5A 76 F5 C6 07 00 C3 

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 assembly:

f: mov al, 'A' # Set AL to the first letter, 'A'. r: stosb # Write AL to the output string, advancing the pointer. b: add al, 1 # Add 1 to AL to get the next letter. cmp al, 'L' # Compare it to 'L'... je b # and if soit's equal, jump back to add 1 again. cmp al, 'Z' # Compare it to 'Z'... jbe r # and if it's less than or equal, repeat the loop. mov BYTE PTR [rdi], 0 # Add a null terminator to the string. ret # Return. 

x86-64 machine code, 17 bytes

B0 41 AA 04 01 3C 4C 74 FA 3C 5A 76 F5 C6 07 00 C3 

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 assembly:

f: mov al, 'A' # Set AL to the first letter, 'A'. r: stosb # Write AL to the output string, advancing the pointer. b: add al, 1 # Add 1 to AL to get the next letter. cmp al, 'L' # Compare it to 'L'... je b # and if so, jump back to add 1 again. cmp al, 'Z' # Compare it to 'Z'... jbe r # and if it's less than or equal, repeat the loop. mov BYTE PTR [rdi], 0 # Add a null terminator to the string. ret # Return. 

x86-64 machine code, 17 bytes

B0 41 AA 04 01 3C 4C 74 FA 3C 5A 76 F5 C6 07 00 C3 

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 assembly:

f: mov al, 'A' # Set AL to the first letter, 'A'. r: stosb # Write AL to the output string, advancing the pointer. b: add al, 1 # Add 1 to AL to get the next letter. cmp al, 'L' # Compare it to 'L'... je b # and if it's equal, jump back to add 1 again. cmp al, 'Z' # Compare it to 'Z'... jbe r # and if it's less than or equal, repeat the loop. mov BYTE PTR [rdi], 0 # Add a null terminator to the string. ret # Return. 
Source Link
m90
  • 12.5k
  • 1
  • 14
  • 51

x86-64 machine code, 17 bytes

B0 41 AA 04 01 3C 4C 74 FA 3C 5A 76 F5 C6 07 00 C3 

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 assembly:

f: mov al, 'A' # Set AL to the first letter, 'A'. r: stosb # Write AL to the output string, advancing the pointer. b: add al, 1 # Add 1 to AL to get the next letter. cmp al, 'L' # Compare it to 'L'... je b # and if so, jump back to add 1 again. cmp al, 'Z' # Compare it to 'Z'... jbe r # and if it's less than or equal, repeat the loop. mov BYTE PTR [rdi], 0 # Add a null terminator to the string. ret # Return.