Kent Johnric
Kent Johnric

Reputation: 11

What is the use of Mov ah,10 in int 21h

What is the use of mov ah,10 in int 21h

Mostly we use like mov ah,0a for string input but why mov ah,10?

nter db 'enter you name:$'
nam db 50,0,50 dup('$')     ;num is 50, num + 1 is 0, num + 2 is 50
lfcr db 10,13,'$'           ;line feed carrier return/next line carriage return
.code
main proc 
    mov ax,@data            ;define
    mov ds,ax
    mov ah,9                
    lea dx,nter             ;output nter
    int 21h
    mov ah,10
    lea dx,nam
    int 21h

Upvotes: 1

Views: 4452

Answers (2)

Joshua
Joshua

Reputation: 43337

Blatantly stolen from this DOS interrupts table.

Read buffered input

DS:DX = buffer

byte [ds:DX] = buffer length
byte [ds:DX + 1] (input) = number of characters in buffer that can be recalled
(output) = number of characters in buffer

buffer starts at DS:DX + 2

10 is the same as 0Ah

Upvotes: 1

Brendan
Brendan

Reputation: 37262

Mostly we use like mov ah,0a for string input but why mov ah,10?

You could use decimal if you want; but most (all?) reference material for DOS functions show values (for function numbers, interrupt numbers and addresses) in hexadecimal and other programmers are more likely to recognize the hexadecimal values; so using decimal will make it harder to read.

The other alternative is to use the pre-processor - e.g. maybe "#define BUFFERED_INPUT_FUNCTION_NUMBER 0x0A" and "mov ah,BUFFERED_INPUT_FUNCTION_NUMBER". For people that aren't very familiar with DOS this makes it easier to read (and/or avoids the need for a comment); but for people very familiar with DOS this makes it a little worse (to check if the right number is actually being used they have to check 2 different places instead of one).

Upvotes: 3

Related Questions