The largest digit

Read a line of digits and print the largest one.

Input

One line of 1 to 30 digits.

Output

The largest digit in the line.

Examples

Example 1 · Input
3725
Expected output
7
Example 2 · Input
0
Expected output
0

Hints

Hint 1

Keep the largest digit seen so far in a register, starting with '0'.

Hint 2

Read keys until Enter; compare each with the largest so far (characters compare in the same order as the digits).

Hint 3

If the new key is above it, it becomes the largest.

Solution

Show one correct solution (try it yourself first)
; The largest digit
.MODEL SMALL
.STACK 100H
.CODE
MAIN PROC
    MOV BL, '0'         ; the largest so far
NEXT:
    MOV AH, 1
    INT 21H
    CMP AL, 0DH
    JE DONE
    CMP AL, BL
    JBE NEXT            ; not larger
    MOV BL, AL
    JMP NEXT
DONE:
    MOV DL, BL
    MOV AH, 2
    INT 21H
    MOV AH, 4CH
    INT 21H
MAIN ENDP
END MAIN

Lesson: Comparing and jumping →