stdout.txt

来自「汇编编程艺术」· 文本 代码 · 共 890 行 · 第 1/3 页

TXT
890
字号
Character Output Routines
-------------------------


The stdlib character output routines allow you to print to the 
standard output device.  Although the processing of non-ASCII 
characters is undefined, most output devices handle these characters
properly.  In particular, they can handle return, line feed, back space, 
and tab.  

Most of the output routines in the standard library output data 
through the Putc routine.  They generally use the AX register upon 
entry and print the character(s) to the standard output device by
calling DOS by default. The  output is redirectable to the 
user-written routine.  However, the PutcBIOS routine prints doesn't 
use DOS.  Instead it uses BIOS routines to print the character in AL 
using the INT command for teletype-like output. 

The print routines are similar to those in C, however, they differ
in their implementation. The print routine returns to the address
immediately following the terminating byte, therefore, it is important
to remember to terminate your string with zero or you will print an
unexpected sequence of characters.



Routine:  Putc
--------------

Category:             Character Output Routine

Registers on Entry:   AL- character to output

Registers on Return:  None

Flags affected:       None

Example of Usage:
                       mov     al, 'C'
                       putc                    ;Prints "C" to std output.


Description:  Putc is the primitive character output routine.  Most other
              output routines in the standard library output data through
              this procedure.  It prints the ASCII character in AL register.  
              The processing of control codes is undefined although most output
              routines this routine links to should be able to handle return, 
              line feed, back space, and tab.  By default, this routine calls
              DOS to print the character to the standard output device.  The
              output is redirectable to to user-written routine.


Include:                stdlib.a or stdout.a



Routine:  PutCR
---------------

Category:             Character Output Routine 

Register on entry:    None

Register on return:   None

Flags affected:       None

Example of Usage:     PutCR


Description:  Using PutCR is an easy way of printing a newline to the stdlib 
              standard output. It prints a newline (carriage return/line feed) 
              to the current standard output device.


Include:                stdlib.a or stdout.a


Routine: PutcStdOut
-------------------

Category:              Character Output Routine

Registers on Entry:    AL- character to output

Registers on Return:   None

Flags Affected:        None

Example of Usage:
                       mov AL, 'C'
                       PutcStdOut        ; Writes "C" to standard output


Description:  PutcStdOut calls DOS to print the character in AL to the standard
              output device.  Although processing of non-ASCII characters and
              control characters is undefined, most output devices handle these
              characters properly.  In particular, most output devices properly
              handle return, line feed, back space, and tab.  The output is
              redirectable via DOS I/O redirection.


Include:                stdlib.a or stdout.a



Routine: PutcBIOS
-----------------

Category:              Character Output Routine

Registers on Entry:    AL- character to print

Registers on Return:   None

Flags Affected:        None

Example of Usage:
                       mov AL, "C"
                       PutcBIOS


Description:  PutcBIOS prints the character in AL using the BIOS routines,
              using INT 10H/AH=14 for teletype-like output.  Output through
              this routine cannot be redirected; such output is always sent
              to the video display on the PC (unless, of course, someone has
              patched INT 10h).  Handles return, line feed, back space, and
              tab.  Prints other control characters using the IBM Character
	      set.


Include:     	stdlib.a or stdout.a



Routine: GetOutAdrs
-------------------

Category:             Character Output Routine

Registers on Entry:   None

Registers on Return:  ES:DI- address of current output routine (called by Putc)

Flags Affected:       None

Example of Usage: 
                      GetOutAdrs
                      mov word ptr SaveOutAdrs, DI
                      mov word ptr SaveOutAdrs+2, ES

Description:  GetOutAdrs gets the address of the current output routine, perhaps
              so you can save it or see if it is currently pointing at some
              particular piece of code.  If you want to temporarily redirect
              the output and then restore the original output routine, consider
              using PushOutAdrs/PopOutAdrs described later.

Include:	stdlib.a or stdout.a




Routine:  SetOutAdrs
--------------------

Category:               Character Output Routine

Registers on Entry:     ES:DI - address of new output routine

Registers on return:    None 

Flags affected:         None

Example of Usage:

                        mov     es, seg NewOutputRoutine
                        mov     di, offset NewOutputRoutine
                        SetOutAdrs
                        les     di, RoutinePtr
                        SetOutAdrs

Description:  This routine redirects the stdlib standard output so that it
              calls the routine who's address you pass in es:di.  This routine
              expects the character to be in AL and must preserve all registers.
              It handles the printable ASCII characters and the four control
              characters return, line feed, back space, and tab.  (The routine
              may be modified in the case that you wish to handle these codes
              in a different fashion.)


Include:        stdlib.a or stdout.a


Routine:  PushOutAdrs
---------------------

Category:              Character Output Routine 

Registers on Entry:    ES:DI- Address of new output routine

Registers on Return:   None

Flags Affected:        Carry = 0 if operation is successful
                       Carry = 1 if there were already 16 items on the stack

Example of Usage:  
                       mov  ES, seg NewOutputRoutine
                       mov  DI, offset NewOutputRoutine
                       PushOutAdrs
                          .
                          .
                          . 
                       les  DI, RoutinePtr
                       PushOutAdrs


Description:  This routine "pushes" the current output address onto an internal
              stack and then uses the value in es:di as the current output
              routine address.  The PushOutAdrs and PopOutAdrs routines let you
              easily save and redirect the standard output and then restore the
              original output routine address later on.  If you attempt to push
	      more than 16 items on the stack, PushOutAdrs will ignore your
              request and return with the carry flag set.  If PushOutAdrs is
              successful, it will return with the carry flag clear.


Include:      	stdlib.a or stdout.a



Routine:  PopOutAdrs
--------------------

Category:             Character Output Routine 

Registers on Entry:   None

Registers on Return:  ES:DI- Points at the previous stdout routine before
                      the pop

Flags Affected:       None

Example of Usage:  
                      mov ES, seg NewOutputRoutine
                      mov DI, offset NewOutputRoutine
                      PushOutAdrs
                         .
                         .
                         .
                      PopOutAdrs


Description:  PopOutAdrs undoes the effects of PushOutAdrs.  It pops an item off
              the internal stack and stores it into the output routine pointer.
              The previous value in the output pointer is returned in es:di.
              Defaults to PutcStdOut if you attempt to pop too many items off
              the stack.

Include:	stdlib.a or stdout.a




Routine:  Puts
--------------

Category:            Character Output Routine 

Register on entry:   ES:DI register - contains the address of the string

Register on return:  None

Flags affected:      None

Example of Usage:
                     les     di, StrToPrt
                     puts
                     putcr


Description:   Puts prints a zero-terminated string whose address appears
	       in es:di.  Each character appearing in the string is printed
               verbatim.  There are no special escape characters.  Unlike
               the "C" routine by the same name, puts does not print a
               newline after printing the string.  Use putcr if you want
               to print the newline after printing a string with puts.


Include:        stdlib.a or stdout.a



Routine:  Puth
--------------

Category:             Character Output Routine

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?