Int 21h has many more than 1h function, for almost everything you need. Also, there is not only Int 21h interrupt. As Frank says, Ralf Brown's Interrupt List would be a good friend.
Regarding MS-DOS programming I think it is a clever task. I believe that, in the core, is not very different from Windows programming. One gives you interrupts to programming and other functions, but basically are the same. Moreover, if you learn DOS programming, I guess you can do it also in Windows without great difficulty. Besides, I think it is a pity losing decades of programming experience. That's at least my opinion.
Well, since we have the code above, I present the secret number guessing game. Indeed, this code fixes a small mistake in the previous one, of what no one seemed to have noticed.
; avch. Guess the secret number. Random routine need to be improved, but it should work
; hit CTRL+C at any time to exit
[org 100h]
[section .text]
xor ah, ah
int 1ah
mov word [RandSeed], dx
@main:
mov cx, 30
call Random
inc dx
mov byte [Secret], dl
xor ah, ah
mov al, dl
mov cl, 10
div cl
or ax, 3030h
mov word [Text3+17], ax ; The secret number in final text
mov cl, 5
@Inner:
mov ch, cl
or ch, 30h
mov byte [Text1+27], ch ; Attempts left in input text
; Input message
mov dx, Text1
mov ah, 9
int 21h
; Get Response
mov dx, Input
mov ah, 0Ah
int 21h
call GetResp
call Success
jc @Exit
jnz @Inner
@Exit:
; ¿Exit?
mov dx, Text4
mov ah, 9
int 21h
xor ah, ah
int 16h
or al, 100000b
cmp al, 'y'
jz @main
mov dx, Text5
mov ah, 9
int 21h
ret
Success:
clc ; There are attempts, mark it
cmp al, byte [Secret] ; Are we success?
mov dx, Text2 ; we suppose so
jz @SExit
cmp cl, 1
ja @Next1
; We have finished attempts
mov dx, Text3 ; We have finished, failed
stc ; Mark it
jmp @SExit
@Next1:
; We have not finished yet and we have not succeeded
dec cl ; One attempt less
sub al, byte [Secret] ; Which is greather?
mov dx, Text6 ; Suppose lower
js @SExit0
mov dx, Text7 ; no, greather
@SExit0:
clc ; There are attempts, mark it
@SExit:
; Print the message
mov ah, 9
int 21h
ret
Random:
; Purpose : pseudo random number in [0, CL)
; In : CX
; Out : DL: número aleatorio
; Destoys : DX
push ax
mov ax, [RandSeed]
mov dx, 8405h
mul dx
inc ax
mov [RandSeed],ax
xor dx, dx
div cx
pop ax
ret
GetResp:
; Out : al
push bx
push cx
push si
mov si, Input+1
xor bh, bh
cmp byte [Input+1], 1
mov bh, byte [Input+2]
jz @next
mov bx, word [Input+2]
@next:
xor ah, ah
mov al, bl
and al, 0Fh
mov cl, 10
mul cl
mov ah, bh
and ah, 0Fh
add al, ah
pop si
pop cx
pop bx
ret
[section .bss]
RandSeed resw 1
Secret resb 1
[section .data]
Input db 3, " "
Text1 db 13, 10, "Guess the number [1,30], attempts: $"
Text2 db 13, 10, "Right!", 13, 10, "$"
Text3 db 13, 10, "Failed, it was ", 13, 10, "$"
Text4 db 13, 10, "Try again (Y/N)?$"
Text5 db 13, 10, 13, 10, "Take a look at http://www.abreojosensamblador.net/", 13, 10, "bye!$"
Text6 db 13, 10, "Too low", 13, 10, "$"
Text7 db 13, 10, "Too high", 13, 10, "$"
Cheers!