Three letters on three lines

Characters are numbers, and the letters of the alphabet are in a row in the ASCII table: 'a' is 61h, 'b' is 62h, and so on. Adding 1 to a letter gives the next letter.

What to build

Read one letter and print it and the two letters that follow it, each on its own line.

Requirements

  • Print the typed letter first, then the next letter, then the one after that.
  • End every one of the three lines with a new line (a carriage return, 0Dh, and a line feed, 0Ah).
  • Do not print anything else.

Input

One lower-case letter from a to x, then Enter.

Output

Three lines, each with one letter.

Constraints

The letter is between a and x, so the next two letters are still letters.

Example

Input:

a

Output:

a
b
c

Why it works

A loop that prints BL, a new line, and then adds 1 to BL does the same work three times, one letter apart. A new line needs both 0Dh and 0Ah: 0Ah alone moves down but not back to the left on a real DOS screen.

Examples

Example 1 · Input
a
Expected output
a
b
c
Example 2 · Input
m
Expected output
m
n
o

Hints

Hint 1

Read the letter with AH = 1 and keep it in BL.

Hint 2

A new line is two characters: print 0Dh and then 0Ah with service 2.

Hint 3

INC BL gives the next letter, because letters are consecutive in the ASCII table. A LOOP with CX = 3 avoids writing the same lines three times.

Solution

Show one correct solution (try it yourself first)
; Three letters on three lines
.MODEL SMALL
.STACK 100H
.CODE
MAIN PROC
    MOV AH, 1
    INT 21H             ; AL = the letter
    MOV BL, AL
    MOV CX, 3
AGAIN:
    MOV DL, BL
    MOV AH, 2
    INT 21H             ; the letter
    MOV DL, 0DH
    INT 21H
    MOV DL, 0AH
    INT 21H             ; a new line
    INC BL              ; the next letter
    LOOP 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 →