output of al contents? 
Author Message
 output of al contents?

I ama  newbie, so please forgive me..

using masm, how do I write code that outputs the contents of AL to the
screen?  Say I did the following:

mov ah,19h
int 21h

now the default drive value is in the AL register.  How do I get that and
put it on the screen?  I do the following and get a odd mess of characters:

mov ah,9
mov drive,al    ; previously declared drive to be where I store the default
drive value
mov dx, offset drive
int 21h

Any help is appreciated.  Thanks.



Mon, 05 Aug 2002 03:00:00 GMT  
 output of al contents?

Quote:

>using masm, how do I write code that outputs the contents of AL to the
>screen?  Say I did the following:

>mov ah,19h
>int 21h

>now the default drive value is in the AL register.  How do I get that and
>put it on the screen?

To begin with, what you now have in AL is

        A: 1
        B: 2
        C: 3

etc.

which is a number. But what you put on screen is a character, so if
you want to put a number on screen, you need the ASCII value of the
character for that number. Now, an ASCII table may tell us that the
following ASCII values correspond with the following characters:

        char 0 : 48
        char 1 : 49
        char 2 : 50

        etc.

and

        char a : 97
        char b : 98
        char c : 99

        etc.

So you must adapt the value in AL to the corresponding ASCII. Just do
this

        ADD AL, 48

if you want to display a number, or

        ADD AL, 97

if you want to display the drive letter. Now AL has the ASCII value
corresponding to the character you want to display.

Quote:
>I do the following and get a odd mess of characters:

>mov ah,9
>mov drive,al    ; previously declared drive to be where I store the default
>drive value
>mov dx, offset drive
>int 21h

So you are using the good and old "AH=9/INT 21h" way of displaying
some text on screen. Now, this function is used to display strings
terminated in "$". If you are going to use it, be sure you have first
declared

        drive   DB 0,"$"

otherwise, the function shall go on displaying byte after byte (the
corresponding ASCII character, actually) until it reaches a "$" one.

But then, if all you need is to display a single character, rather
than a string, you can just use function AH=2/INT 21h, in which case
you'll do

        mov dl, al
        mov ah, 2
        int 21h

Manuel Algora



Mon, 05 Aug 2002 03:00:00 GMT  
 output of al contents?
mov ah,19h
int 21h
add al,41h             ; this will convert 0-->'A', 1-->'B' ...
mov [output],al       ; this will move the character from AL to output
string
mov dx,offset output
mov ah,09h
int 21h

output db '#:$'        ; the # will be replaced by the drive character
                                ;$ is to terminate the string, so DOS will
know to stop printing here



Mon, 05 Aug 2002 03:00:00 GMT  
 output of al contents?
Get a copy of the UCR Standard Library for 80x86
Assembly language Programmers.  It has tons of
I/O routines and conversion routines that will help
you skip all the pain of figuring this out for yourself.
You can find the library at http://webster.cs.ucr.edu.
While you're there, take a look at "The Art of Assembly
Language Programming" and the HLA (High Level
Assembly) language.
Randy Hyde


Quote:
> I ama  newbie, so please forgive me..

> using masm, how do I write code that outputs the contents of AL to the
> screen?  Say I did the following:

> mov ah,19h
> int 21h

> now the default drive value is in the AL register.  How do I get that and
> put it on the screen?  I do the following and get a odd mess of
characters:

> mov ah,9
> mov drive,al    ; previously declared drive to be where I store the
default
> drive value
> mov dx, offset drive
> int 21h

> Any help is appreciated.  Thanks.



Mon, 05 Aug 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Output Request - file volumes et al

2. Help to output contents of a Multi Line Entry Field

3. How to output dictionary sorted on content (not keys)

4. Corruption of field content / Content spreading over fields / NIGHTMARE

5. content of content variable

6. get the content of the content

7. how print output to screen and output file

8. Outputting info from awk and using the info to name the awk output file

9. Create polymorhpic output for I32 input (select output type)

10. rxvt + python problem: script output buffered and interactive output missing

11. HOW TO CAPTURE AN OUTPUT LINE OF A VHDL OUTPUT IN TCL

12. MOV AL,20 OUT 20,AL doesn't work for int 9h...

 

 
Powered by phpBB® Forum Software