x86-16 ASM, IBM PC DOS, 11 bytes
Binary:
00000000: 8a0e 8000 49b8 200a cd10 c3 ....I. ....
Unassembled:
D1 EE SHR SI, 1 ; SI to 80H (SI intialized at 100H)
AC LODSB ; load string length into AL
91 XCHG AX, CX ; put input string length into CX
49 DEC CX ; remove leading whitespace from length
AC LODSB ; load whitespace delimiter into AL
B4 0A MOV AH, 0AH ; BIOS "write character CX number of times" function
CD 10 INT 10H ; call BIOS, display to console
C3 RET ; return to DOS
Explanation:
Input is via command line, though all that's important is the length. Command line input length is always stored at memory address DS:0080H
in DOS, so put that into CX
. DOS includes the space between the executable name and the command line args string in this number.
For example: in FOO.COM Hello
, length is 6 and command line string is " Hello"
, or calling as FOO.COM/Hello
, command line string is "/Hello"
(Note: those are the the only valid characters for the character immediately after the executable name). This first character (will be a space when called normally) is what is displayed as the "invisible text" for output. This builds in a handy little "debug mode" where you can use a slash instead of a space to actually be able to test your output is the right length.
Then, use the IBM PC BIOS's INT 10H "Write character only at cursor position" (0AH
) function that writes the same character CX
number of times.
Example Output:
Admittedly, displaying 13 chars of whitespace is not very interesting in a screenshot. However, by using a slash instead of a space ("debug mode") you can actually see that you are displaying the right number of chars.

0x0A
and0x20
are the hexadecimal values for the Newline and Space characters respectively \$\endgroup\$ – Skidsdev May 25 '17 at 12:58These can be any mix of spaces and newlines
Your output can be any mix of spaces and newlines, you can just output spaces if you want, like everyone else, or you can just output newlines. It's up to you \$\endgroup\$ – Skidsdev May 25 '17 at 13:05