Input to screen using int 21h Function 7

Started by setonai, April 01, 2011, 08:51:37 AM

Previous topic - Next topic

setonai

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. 


MichaelW

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
eschew obfuscation

dedndave


FORTRANS

Hi,

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

Cheers,

Steve N.

dedndave

well - that is true, Steve   :P
but - he is entering numeric digits, perhaps letters and punctuation - rarely, if ever, chars above 127

FORTRANS

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

setonai