The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: setonai on April 01, 2011, 08:51:37 AM

Title: Input to screen using int 21h Function 7
Post by: setonai on April 01, 2011, 08:51:37 AM
My teacher wants me to use int 21h function 7 to input and echo with int 21h function 2. So far i've understand that in Function 7 stores any single character input into al and function 2displays in dl. This is all in 8 bit. the other option for output to use is function 9. So 2,7,9.

For multiple inputs say like 357
I use like a loop so

num = 0
getchar (ch)

while (ch !=#)

num = num * 10 + getchar(ch)-30h

getchar(ch)


My lab assignment was to calculate a given math problem and getting input from user. Initially we had to do without input and I wrote my entire program in 16-bit. My dilemma is that I don't know how to transition from the 8 bit store value to 16 bit to work with the rest of my problem. 

Title: Re: Input to screen using int 21h Function 7
Post by: MichaelW on April 01, 2011, 09:42:09 AM
As an example, to expand an 8-bit value in AL to a 16-bit value in AX, without changing the value, you simply need to zero the high-order byte of AX, with something like:

mov ah, 0

or

xor ah, ah
Title: Re: Input to screen using int 21h Function 7
Post by: dedndave on April 01, 2011, 12:16:58 PM
CBW also works - if it is signed
Title: Re: Input to screen using int 21h Function 7
Post by: FORTRANS on April 01, 2011, 01:33:26 PM
Hi,

   ASCII is rarely treated as signed.   MichaelW's suggestion
should be sufficient in the described situation.

Cheers,

Steve N.
Title: Re: Input to screen using int 21h Function 7
Post by: dedndave on April 01, 2011, 01:53:43 PM
well - that is true, Steve   :P
but - he is entering numeric digits, perhaps letters and punctuation - rarely, if ever, chars above 127
Title: Re: Input to screen using int 21h Function 7
Post by: FORTRANS on April 01, 2011, 04:51:13 PM
Hi Dave,

   Take it in the spirit of the 1st of April.  CBW is mostly not
one of the introductory opcodes and could be confusing
And you are correct, CBW does exactly what he wanted.
I would have not tried it out on his first program though.
As you occasionally say, LOL.

Cheers,

Steve
Title: Re: Input to screen using int 21h Function 7
Post by: setonai on April 15, 2011, 10:03:27 AM
Thank you again really has helped me