6 add other string type variations
source | link

x86 Machine Code, 2 bytes

As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.

Input string is in SI, length in CX and output character is in AL:

F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                       ; loop CX number of times. The last char will be in AL when done.

Or 4 bytes as a "Pascal string" (length is prepended to beginning of string):

AC     LODSB           ; first byte is string length
91     XCHG AX, CX     ; move length to CX for loop 
F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                       ; loop CX number of times. The last char will be in AL when done.

Or 5 bytes as a "C string" (zero/null terminated), input in DI:

F2 AE     REPNZ SCASB     ; scan for value in AL (0), end when found and advance DI
8A 45 FE  MOV AL, [DI-2]  ; DI is now two bytes ahead of last, put value of DI-2 into AL

IBM PC DOS, 8088 Assembly, 12 11 bytes

Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.

D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC      LODSB           ; load command line length in AL 
91      XCHG AX, CX     ; move length to CX for loop 
F3/ AC  REPZ LODSB      ; load next char into AL, repeat until CX = 0 
B4 0E   MOV  AH, 0EH    ; PC BIOS write to screen function 
CD 10   INT  10H        ; display 
C3      RET             ; exit to DOS

Output:

enter image description here

Download LAST.COM DOS executable (11 bytes)

x86 Machine Code, 2 bytes

As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.

Input string is in SI, length in CX and output character is in AL:

F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                       ; loop CX number of times. The last char will be in AL when done.

IBM PC DOS, 8088 Assembly, 12 11 bytes

Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.

D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC      LODSB           ; load command line length in AL 
91      XCHG AX, CX     ; move length to CX for loop 
F3/ AC  REPZ LODSB      ; load next char into AL, repeat until CX = 0 
B4 0E   MOV  AH, 0EH    ; PC BIOS write to screen function 
CD 10   INT  10H        ; display 
C3      RET             ; exit to DOS

Output:

enter image description here

Download LAST.COM DOS executable (11 bytes)

x86 Machine Code, 2 bytes

As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.

Input string is in SI, length in CX and output character is in AL:

F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                       ; loop CX number of times. The last char will be in AL when done.

Or 4 bytes as a "Pascal string" (length is prepended to beginning of string):

AC     LODSB           ; first byte is string length
91     XCHG AX, CX     ; move length to CX for loop 
F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                       ; loop CX number of times. The last char will be in AL when done.

Or 5 bytes as a "C string" (zero/null terminated), input in DI:

F2 AE     REPNZ SCASB     ; scan for value in AL (0), end when found and advance DI
8A 45 FE  MOV AL, [DI-2]  ; DI is now two bytes ahead of last, put value of DI-2 into AL

IBM PC DOS, 8088 Assembly, 12 11 bytes

Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.

D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC      LODSB           ; load command line length in AL 
91      XCHG AX, CX     ; move length to CX for loop 
F3/ AC  REPZ LODSB      ; load next char into AL, repeat until CX = 0 
B4 0E   MOV  AH, 0EH    ; PC BIOS write to screen function 
CD 10   INT  10H        ; display 
C3      RET             ; exit to DOS

Output:

enter image description here

Download LAST.COM DOS executable (11 bytes)

5 add machine code only version
source | link

x86 Machine Code, 2 bytes

As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.

Input string is in SI, length in CX and output character is in AL:

F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                       ; loop CX number of times. The last char will be in AL when done.

IBM PC DOS, 8088 Assembly, 12 11 bytes

Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.

D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC      LODSB           ; load command line length in AL 
91      XCHG AX, CX     ; move length to CX for loop 
F3/ AC  REPZ LODSB      ; load next char into AL, repeat until CX = 0 
B4 0E   MOV  AH, 0EH    ; PC BIOS write to screen function 
CD 10   INT  10H        ; display 
C3      RET             ; exit to DOS

Complete program as IBM PC DOS executable. Input is from command line, output is to console.

Output:

enter image description here

Download LAST.COM DOS executable (11 bytes)

IBM PC DOS, 8088 Assembly, 12 11 bytes

D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC      LODSB           ; load command line length in AL 
91      XCHG AX, CX     ; move length to CX for loop 
F3/ AC  REPZ LODSB      ; load next char into AL, repeat until CX = 0 
B4 0E   MOV  AH, 0EH    ; PC BIOS write to screen function 
CD 10   INT  10H        ; display 
C3      RET             ; exit to DOS

Complete program as IBM PC DOS executable. Input is from command line, output is to console.

Output:

enter image description here

Download LAST.COM DOS executable (11 bytes)

x86 Machine Code, 2 bytes

As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.

Input string is in SI, length in CX and output character is in AL:

F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                       ; loop CX number of times. The last char will be in AL when done.

IBM PC DOS, 8088 Assembly, 12 11 bytes

Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.

D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC      LODSB           ; load command line length in AL 
91      XCHG AX, CX     ; move length to CX for loop 
F3/ AC  REPZ LODSB      ; load next char into AL, repeat until CX = 0 
B4 0E   MOV  AH, 0EH    ; PC BIOS write to screen function 
CD 10   INT  10H        ; display 
C3      RET             ; exit to DOS

Output:

enter image description here

Download LAST.COM DOS executable (11 bytes)

4 add download link
source | link

IBM PC DOS, 8088 Assembly, 12 11 bytes

D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC      LODSB           ; load command line length in AL 
91      XCHG AX, CX     ; move length to CX for loop 
F3/ AC  REPZ LODSB      ; load next char into AL, repeat until CX = 0 
B4 0E   MOV  AH, 0EH    ; PC BIOS write to screen function 
CD 10   INT  10H        ; display 
C3      RET             ; exit to DOS

Complete program as IBM PC DOS executable. Input is from command line, output is to console.

Output:

enter image description here

Download LAST.COM DOS executable (11 bytes)

IBM PC DOS, 8088 Assembly, 12 11 bytes

D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC      LODSB           ; load command line length in AL 
91      XCHG AX, CX     ; move length to CX for loop 
F3/ AC  REPZ LODSB      ; load next char into AL, repeat until CX = 0 
B4 0E   MOV  AH, 0EH    ; PC BIOS write to screen function 
CD 10   INT  10H        ; display 
C3      RET             ; exit to DOS

Complete program as IBM PC DOS executable.

Output:

enter image description here

IBM PC DOS, 8088 Assembly, 12 11 bytes

D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC      LODSB           ; load command line length in AL 
91      XCHG AX, CX     ; move length to CX for loop 
F3/ AC  REPZ LODSB      ; load next char into AL, repeat until CX = 0 
B4 0E   MOV  AH, 0EH    ; PC BIOS write to screen function 
CD 10   INT  10H        ; display 
C3      RET             ; exit to DOS

Complete program as IBM PC DOS executable. Input is from command line, output is to console.

Output:

enter image description here

Download LAST.COM DOS executable (11 bytes)

3 -1 byte, use XCHG instead of MOV
source | link
2 -1 byte, remove unnecessary DEC AX
source | link
1
source | link