Say it twice

A program prints with INT 21h, service 2, which writes the character whose code is in DL. This exercise reads one key and prints it twice.

What to build

Read one key and print it two times in a row.

Requirements

  • Read the key with service 1 (the key arrives in AL).
  • Print it with service 2, which prints DL.
  • Print no other character, not even a new line.

Input

One character, then Enter.

Output

The same character, twice, on one line.

Constraints

The character is a letter, a digit or a punctuation mark.

Example

Input:

a

Output:

aa

Why it works

Service 1 puts the code of the typed key in AL, and service 2 takes the code to print from DL, so a MOV between the two registers connects them. A service does not change AH or DL (it only reads them), so a second INT 21h right after the first prints the same character again.

Examples

Example 1 · Input
a
Expected output
aa
Example 2 · Input
7
Expected output
77

Hints

Hint 1

Read one key with AH = 1 and INT 21h: its code arrives in AL.

Hint 2

Copy it to DL, set AH = 2, and call INT 21h to print it.

Hint 3

AH is still 2 after the call, so a second INT 21h prints DL again.

Solution

Show one correct solution (try it yourself first)
; Say it twice
.MODEL SMALL
.STACK 100H
.CODE
MAIN PROC
    MOV AH, 1
    INT 21H             ; AL = the key
    MOV DL, AL
    MOV AH, 2
    INT 21H             ; print it
    INT 21H             ; AH is still 2: print it again
    MOV AH, 4CH
    INT 21H
MAIN ENDP
END MAIN

▶ Open this solution in the compiler, then press Visualize to watch it run step by step

Lesson: Your first 8086 program →