Thứ Bảy, 21 tháng 9, 2013

Int 21h


                                                DOS Interrupt 21 Functions
    mov  ah,00h                                   ;Program terminate
    mov  cs,xx                                     ;Segment address of program segment prefix in xx.
    int 21h

    mov  ah,01h                                    ;Console input from keyboard with echo or show input.
    int 21h                                         
    push al                                           ;Character returned in al to stack top.

    mov  ah,02h                                    ;Display output on screen or standard output.
    mov dl, 50                                      ;Character to display is send to dl.
    int 21h                                           ;Start 02h, no output from function 02h.

    mov ah,03h                                     ;Auxiliary input: read character from standard auxiliary device, wait for asynchronous
                                                          ;input character
    int 21h                              
    push al                                           ;Character returned in al to stack top.

   mov ah,04h                                      ;Auxiliary output: send character to a standard asynchronous output device.
   mov dl,50                                        ;Character to send is placed in dl.
   int 21h                                            ;Start 04h, no output from function.

   mov ah,05h                                      ;Printer output: character to standard printer the PRN:device.
   mov dl,50                                        ;Character to be send placed in dl.
   int 21h                                            ;Start 05h, no output from function.

   mov ah,06h                      ;Direct console input or output: reads or write character.
   mov dl,FFh                      ;Function selector in dl: FFh read character, not FFh for display dl.
   int 21h
   push zf                         ;Output in zf: on read only: 0= character returned, 1=no character ready.
   push dl                         ;Output in dl: character returned on reads only.

   mov ah,07h                  ;Direct console input without echoing to standard output: read character. from   
                                   ;keyboard; Crtl+Break, Crtl+S, Ctrl+Q, Crtl+P and Crtl+PrtSc are not processed.
   int 21h
   push al                                             ;Character returned in al placed on stack.

   mov ah,08h                                       ;Console input without echo: reads character from standard input.
   int 21h
   push al                                             ;Character returned in al send to stack.

   xx   DB   "String of characters."       ;Define xx in .DATA.
         DB    "bb5"
   mov ah, 09h                                      ;Display string of characters to standard output, string terminated at $ or 24h set write code.
   mov ds:dx,OFFSET STRING           ;Entry in ds or dx: start address of string in xx into ds.
  ; mov dx,ds
   int 21h                                    ;Start 09h, no return from function. Format at the buffer at ds:dx:
                                                  ;STRING  DB "Text ...", "$"  in .DATA.     

                                                                    ;Buffered keyboard input.
   KB_BUF  LABEL BYTE                         ;Format of buffer at ds:dx, array symbol or label.
    MAX_LEN     DB   m                             ;Maximum length m of returned text including a carriage return 0Dh.
    CUR_LENG   DB   n                              ;Length n of actual returned text following buffer pointed to by "CUR_LENG",
    CUR_TEXT    DB  x DUP(?),0Dh          ;Return text, size of array x for storing string ascii characters.
                         DB   (m-n-1) DUPO (?)     ;unused.
    mov ah,0Ah                                             ;Buffered keyboard input: saves character entered from a standard input
                                                                    ;usually the CON device in a buffer supplied by the caller and echoes
                                                                    ;characters  to standard output.
   mov ds:dx,KB_BUF                                  ;Entry into ds or dx: address of buffer, start address of string assigned to symbol   ;"KB_BUF"
                                                                     ;into register dx.
   int 21h                                                       ;Start 0Ah, no return value, stop function by pressing "Enter".

   mov ah,0Bh                                               ;Check standard input status: determine if character is available on standard input.
   int 21h
   push al                 ;Character available indicator: FFh in al for character is ready, no FFh for no                                                                                     ;character; place content in al in stack.

   mov ah,0Ch                 ;Clear keyboard buffer and invoke keyboard function: clears standard input of                                       ;characters in BIOS type-ahead buffer and executes a specific keyboard funtion.
   mov al, 00h                 ;Entry into al: 00h for just clear the buffer, 01h for console clear the buffer, 06h                       
                                      ;for direct console input or output, 07h for direct console input without echo,  08h                                     
                                      ;for console input without echo, 0Ah for buffered keyboard input.
   int 21h                         ;Start 0Ch, for return value registers and values see appropriate function.

   mov ah,0Dh                                      ;Disk reset: used before requesting change of removable media.
   int 21h                                             ;Start 0Dh, no return value.

   mov ah,0Eh                                       ;Select disk: function selects the current default drive.
   mov dl,0                                           ;Entry in dl, select the drive: 0= A drive, 1= B drive, 2=c drive.
   int 21h                                              ;
   push al                                             ;Combined available drives return: 1=A, 2=B, number of disk drives, 2 for single drive
                                      
                                                                ;FCB open file: opens a file in the current directory of a specified drive.
   INPUT_FCB LABEL BYTE                ;Variable format of buffer at ds:dx , variable "INPUT_FCB" becomes location of first byte of array.         
        DB 0                                              ;Drive:0=default,1=A drive, 2=B drive, etcetera.
        DB  "filename"                                 ;8 character filename.
        DB  "ext"                                         ;Three character filename extension like "txt", "ext" , "dll", "exe", etcetera.
        DB   25 DUP(0)                              ;Array initialize by DOS to (0). FCB= file control block. The 25 DUP(9) is duplicate or array
                                                               ;size for 25 bytes. Used with INT 21 function 0Fh.

   OUTPUT_FCB LABEL BYTE            ; File label. File label array declared in ".DATA" segment:
       DB         ?                                         ;drive: 1=A, 2=B, etcetera ,
       DB    "filename"                                 ;8 character filename,
       DB    "EXT"                                      ;EXT is a three character file name extension like: exe, txt, dll, etcetera;
                                                                ;example:  can use filename.exe for storing  machine code as an executable
                                                                ;file  in Windows XP;
       DW      0                                          ;current block,  
       DW  128                                          ;record size,
       DD   ?                                              ;double word file size from the, "?" means empty variable declaration.
       DW    ?                                            ;file date file's   
       DW    ?                                            ;file time directory,
       DB    8 DUP(?)                                ;reserved for DOS,
       DB    0                                             ;current record number,
       DD   0                                              ;random record number.    
      
   mov ah,0Fh                                          ;FCB open file: opens file in current directory of specified drive.
   mov ds:dx,OFFSET INPUT_FCB                       ;Array label entry into ds:dx: address in xx of an unopen FCB, start of file placed in dx
   int 21h                                                  ;assigned to by INPUT_FCB, file placed in main memory starting at dx value.
   push al                                                 ;Error code output in al: 00h for file opened,  FFh for file not found. 


   mov ah,10h                                        ;FCB closew file: function closes an open file.
   mov ds:dx,xx                                     ;Entry into ds:dx: addressib xx of an open FCB .
   int 21h
   push al                                              ;Function output in al: 00h for file closed, FFh for file not found.   

   mov ah,11h                 ;FCB search for first entry:searches for first match of specified filename in current
                                                           ;directory of specified drive.
   mov ds:dx,xx                                     ;Entry into ds:dx: address of an unopen FCB.
   int 21h
   push al                      ;Return is al: error code: 00h for file found, FFh for file not found DTA for found                                                                              ;file information 

   mov  ah,12h                        ;FCB search fornext entry: search for next matching file as specified by a prior
                                                          ;search for first entry.
   mov  ds:dx,xx                                   ;Entry xx into ds:dx: address of search FCB.
   int  21h
   push al            ;Output in al: error code: 00h for file found, FFh for file not found,
                             ;DTA found file information
   mov  ah,13h                                       ;FCB delete file.
   mov ds,PCB                                    ;Entry of PCB and zz into ds:dx: address of an unopen FCB
   mov  dx, zz
   int 21h
   push al                    ;Output in al: error code; 00h for file or files found, FFh file not found.
                                 ;Format of the buffer at ds:dx: normal PCB definition:
                                 ;PCB  LABEL BYTE
                                    ;DB        0                   ;drive: 1=A, 2=B, etcetera,
                                    ;DB       "filename"       ;8 character filename  (?allowed),
                                    ;DB      "ext"               ;3 character file name extension like: txt, exe, dll, cpp, etcetera(? allowed),
                                    ;DB    25  DUP(0)        ;reserved for DOS.

   mov  ah,14h             ;FCB sequential read: DOS sequential file read of an open fle reading
                                 ;the record addressed by
                                ; the FCB current-block and current record number fields into the DTA buffer.
   mov ds:dx,PCB        ;Entry of PCB into ds:dx: address of an open FCB.
   int  21h
   push  al                  ;Output in al: error code:  00h for no error, 01h for end of file EOF, 02h                                                         
                                 ;for DTA segment wrap.
                                 ;Format of the buffer at ds:dx:
                                  ;FCB  LABEL BYTE
                                     ;     DB              ?            ;drive: 1=A, 2=B, etcetera,
                                     ;     DB    "filename"         ; 8 character filename,
                                     ;     DB    "ext"                 ;3 character file name extension like: txt, exe, dll, etcetera;
                                     ;     DW     0                    ;current block,
                                     ;     DW     128                 ;record size,
                                     ;     DD       ?                   ;file size from the
                                     ;     DW      ?                   ;file date  file's
                                     ;     DW      ?                   ;file time directory,
                                     ;     DB   8 DUP(?)            ;reserved for DOS, duplicate process 8 times to store bytes,
                                     ;     DB   0                       ;current record number,
                                     ;     DD   0                       ;random record number.


   mov  ah,15h            ;FCB sequential write: write to an open file, writing the record address by the FCB                                          
                                      ;current-block and current record number fields into the DTA buffer.
   mov  ds:dx,FCB            ;Entry of FCB into ds:dx: address of an open FCB
   int  21h
   push al                     ;Output in al:error code: 00h for no error, 01h for disk is full or read-only file,
                                                          ;02h for DTA segment wrap, 03h for partial record read.
                                   ;Format of the buffer at ds:dx: same as funtion 14h with 21h.
                                     ;FCB    LABEL BYTE
                                        ;  DB       ?                 ;drive: 1=A, 2=B, etcetera,
                                        ;  DB  "filename"         ;8 character filename,
                                        ;  DB   "ext"                ;3 character file name extension,
                                        ;  DW   0                    ;current block,
                                        ;  DW    128               ;record size,
                                        ;  DD       ?                 ;


    mov  ah,16h                                     ;FCB make a file in current directory of specified drive and opens
                                                          ;the file for read and write access.
    mov  ds:dx,xx                                  ;Entry of xx into ds:dx: address of an unopen FCB
    int  21h
    push  al                          ;Output in al: error code: 00h for file made, FFh for no room in directory.
                                         ;Format of the buffer at ds:dx: similar to 14h.

    mov  ah,17h                                     ;Rename a file: changes matching filenames in current directory of
                                                        ;specified directory to a new filename.  
    mov ds:dx,xx                                     ;Entry of xx into ds:dx: address of an unopen FCB
    int  21h
    push al                                      ;Output in al: error code: 00h for file or files renamed, FFh for file not   ;found or new name exists.

   mov   ah,19h                                       ;Current disk: return the current drive
   int  21h
   push al                                               ;Output in al: 0 for A drive, 1 for B drive ,2 for c drive.
 
  mov    ax,@data                               ;Move data in @data to word register ax.
  mov    ds,ax                                  ;Set DS to point to the data segment; move data address in ax to dx.             
  mov    dx,OFFSET NumberPrompt     ;Move start address of time prompt string to dx: point to the time prompt.
  mov    ah,20h                                 ;DOS: print string on screen: move function 9 to ah.
  int    21h                                    ;Start interupt handler: display user time prompt on screen.

   mov  ah,1Ah                                         ;Set disk transfer address DTA
   mov  ds,xx                                      ;Entry of xx and zz into ds:dx: address of DTA buffer.
   mov  dx,zz                                       ;
   int  21h                                               ;Start 1Ah, no return byte.

   mov  ah,1Bh                                        ;Allocation table information:returns information concerning the current                                                            ;defualt drive's file allocation table FAT.
   mov  ds:dx,xx                                    ;Entry of xx into ds:dx: address of DTA buffer, buffer format: DAT                                                          ;LABEL BYTE ... .
   int  21h
   push al                                              ;Output in al: sectors per cluster, Fh is dik error, or
   push cx                                              ;Output in cx: bytes per sector.
   push dx                                              ;Output in dx: number of clusters
   push ds:bx                                          ;Output in ds,bx: address of media type, buffer formate at ds:bx:                                                          
;FAT_  DB  , FAT (file format) media type.
 
   mov ah,1Ch                    ;Allocation table information for specific device: returns information    
                                    ;convering the specified drive's file allocation table FAT,
   mov dl,0                ;Entry into dl: drive selector: 0=current, 1= A drive, 2=B drive.
   int  21h
   push al                    ;Output in al: sector per cluster, FFh =disk error, or
   push  cx                                              ;output in cx: bytes per sector.
   push  dx                                              ;Output in dx: number of cluster.
   push  ds:dx,xx                                     ;Output in ds:dx: address of media.  

   mov  ah,1Fh               ;Get default device parameter block: returns address of the device parameter block DPB
                                   ;for current drive.    
   int  21h
   push al,0                   ;Output in al: return code: 0 for no error.
   push ds:bx                 ;Output in ds:dx: DPB return address.

   mov  ah,21h                       ;Random read: performs a random file read from an open file by reading the record                                  
                                          ;addressed by the FCB current block and current record fields from the DTA     buffer.
   mov ds,dx,xx                                         ;Entry of xx into ds:dx: address of an open file
   int  21h
   push al          ;Output in al: error code: 00h for no error, 01h for end of file EOF, 02h for DTA
                       ;segment wrap, 03h for partial record read. Use relative record field function 24h.
                                                               ;Format for buffer at ds:dx in data segment:
                                                               ;FCB  LABEL  BYTE
                                                                       ;DB    ?                          ;drive 1=A, 2=B, etcetera
                                                                       ;DB   "filename"              ;8 character filename
                                                                       ;DB   "EXT"                    ;3 character file name extension
                                                                       ;DW    0                          ;current block
                                                                       ;DW    128                      ;record size
                                                                       ;DD      ?                         ;filesize
                                                                       ;DW     ?                         ;file date
                                                                       ;DW     ?                         ;file time
                                                                       ;DB       8 DUP(?)             ;reserved for DOS
                                                                       ;DB       0                         ;current record number
                                                                       ;DD       0                        ;random record number.


   mov  ah,22h                 ;FCB random write: performs random file write to an open file by writing the record
                                   ;address by the FCB current block and current record fields from the DTA buffer.
   mov  ds:dx,xx                                        ;Entry of xx into ds:dx: addrrss of an opent FCB.
   int  21h
   push al                     ;Output in al:error code: 00h for  o error, 01h for disk full, 02h for DTA segment wrap.

    mov  ah,35h                                       ;Get interrupt vector: gets contents of an interrupt vector.
    mov  al,nn                                          ;Entry of nn into al: interrupt vector number.
    int  21h
    push es:bx                                         ;Output in es:bx: address of IN_DOS flag. 

   mov  ah,25h                             ;Set interrupt vector: sets an interrupt vector to a specified interrupt
                                                  ;handling routine.
   mov  al,zz                                 ;Entry of zz into al: interrupt vector number.
   mov   ds:dx,xx                          ;Entry xx into ds:dx=vector address: address of new interrupt handler which receives control.
   int  21h                                     ;start function 25h, no return value.  

   mov   ah,26h                ;Make new program segment prefix: makes and initializes a new program segment                                     
                               ;prefix PSP at the specified address by copying the current program's PSP.
   mov  dx,zz                    ;Entry of zzinto dx: segment of new PSP.
   int  21h

    mov  ah,27h                 ;FCB random block read: performs a random file read of consecutive records from
                                       ;an open file by reading the record address by the FCB into the DTA buffer.
    mov  ds:dx,xx               ;Entry of xx into ds:dx: address of an open FCB.
    mov  cx,1                     ;Number of records to read.
    int  21h
    push al                        ;Output in al: error code: 00h for no error, 01h for end of file EOF, 02h for
                                      ;DTA segment wrap, 03h for partial record read.
    push  cx                      ;Output in cx: number of records read.
                                      ;Buffer format at ds:dx:
                                          FCB  LABEL BYTER
                                                 DB     ?                           ;Drive 1=A, 2=B, etcetera.
                                                 DB      "filename"             ;8 character filename.
                                                 DB      "EXT"                   ;3 character file name extension.

    mov  ah,28h                ;FCB random block write: performs a random file write of consecutive random records                                    
                                  ;from an open file by writing the record address by the FCB from the DTA buffer.
    mov  ds:dx,xx             ;Entry of xx into ds:dx: address of an open FCB.
    mov cs,zz                   ;Entry of zz into cs: number of records to write.
    int  21h
    push al                       ;Output in al: error code: 00h for no error, 01h for disk full, 02h for DTA segment wrap.


   move  ah,29h              ;Parse filename: funtion 29h parses a filename text string into a FCB.
   mov  al,0                    ;Entry into al: function bits: 0 for 1-scan off leading separators, 1 for 1=set FCB
                                    ; drive identification if present, 2 for 1=set FCB filename if present,
                                    ;3 for 1=set FCB extension if prsent, 7-4 for reserved must be set to 0.
   mov  ds:si,zz               ;Entry of zz into ds:si: address of source filename.
   mov  es:di,xx               ;Entry of xx into es:di: address of destination FCB.
   int  21h
   push  al                      ;Output in al: error code; 00h for no * or ? in name, 01h for * or ? in name,
                                    ;FFh for invalid drive specified.

   mov  ah,2Ah                ;Get date: returns date information: day of month, month, year.
   int  21h
   push  al                       ;Output in al: day of theweek
   push  cx                      ;year
   push  dh                      ;month
   push dl                        ;day.

   mov  ah,2Bh                ;Set date
   mov  cx,2003              ;Entry into cx: year
   mov  dh, 4                   ;Entry into dh: month
   mov  dl,15                    ;Entry into dl: day,
   int  21h
   push  al                        ;Output in al: error code: 00h for no error, FFh for invalid date.

   mov  ah,2Ch                  ;Get time: returns hours, minutes,seconds, and hundredths of seconds.
   int  21h
   push  ch                       ;Output in ch: hour
   push  cl                        ;Output in cl: minute
   push  dh                       ;Output in dh:second
   push  dl                        ;Output in dl: hundredths of a second.

   mov  ah,2Dh                 ;Set time:sets hours, minutes, seconds, and hundredths of seconds.
   mov  ch,3                     ;Entry into ch: hour
   mov  cl,20                    ;Entry into cl: minute
   mov  dh,23                   ;Entry into dh: second
   mov  dl,11                     ;Entry into dl: hunderedth of a second: 0 -99.

   mov ah,2Eh                  ;Set verify state
   mov dl,0                       ;0 in al to turn verify off, 1 in al to turn verify on.
   int 21h                         

   mov  ah,2E00h             ;Reset verify state: resets the disk write verfification state.
   int  21h

   mov  ax,2E01h              ;Set verifiy state:sets write verfication state.
   int 21h

    mov  ah,2Fh                 ;Get disk transfer address DTA: returns the current disk transfer address DTA
    int  21h
    push  es:bx,zz              ;Entry of zz into es:bx: address of current DTA.  The DTA begins at address
                                       ;defined by es:bx and extnds to the end of the data segment.

    mov  ah,30h                  ;Get DOS  disk operating system version number.
    int  21h
    push  ax                       ;Output in ax: DOS function numer: ah=minor version or revision number, al=major version,          
                                       ;1B03h implies DOS 3.30, bx,cx=0
    push  bx                       ;Output in bx: indicates DOS destroyed
    push  cx                       ;Output in cx: indicates DOS destroyed.

    mov  ah,31h                  ;Terminate current number and return control to parent programs or stay resident.
                                        ;Process management funtion: keep process
                                       ;Open files and memory blocks allocated to the programs are retained.
    mov  al, xx                   ;Entry of xx into al= return code
    mov dx,21                    ;Entry into dx: memory size of program and data in paragraphs.
    int  21h                        ;Start function 31h, no return value given.

    mov  ah,32h                  ;Get device parameter block: returns address of the device parameter block DPB
                                        ;for specified drive.
    mov  dl,0                       ;Entry into dl: drive: 0=current, 1=drive A, 2=drive B, etcetera
    int  21h
    push al                          ;Ouput in al: return code: 00f for no error, FFh for insufficient drive.
    push  ds:bx                   ;Output in ds:bx: DPB address.

    mov  ax,3300h               ;Get break state: this function gets the break state; when break is on, entry                                       
                                         ;Crtl+break  runs the int 23h Crtl+break handler which may stop the current
                                         ;procces information.
    int  21h
    push  dl                           ;Ouput in dl: current break state: 0 for off, 1 for on

    mov  ax,3301h                 ;Set break state
    int  21h
    push  dl                           ;Output in dl: new break state: 0 for off, 1 for on.

    mov  ax,3305h                 ;Get boot drive number.
    int  21h
    push  dl                           ;Output indl: boot drive: 1=A, 2=B, etcetera.

    mov ah,31h                     :Set stay resident.
    int 21h

    mov  ah,34h                     ;Get in_DOS flagg address.
    int  21h
    push  es:bx                      ;Ouput in es:bx: address of in_DOS flag.

    mov  ah,35h                     ;Get interrupt vector: gets content of an interrupt vector , get or read interupt vector address
    mov  al, 10h                     ;Entry into al: interrupt vector number.
    int  21h
    push  es:bx                      ;Output in es:bx: contents of interrupt.es:bx=vector address.

    mov  ah,36h                     ;Get disk free space; returns available free space on specified disk.
    mov  dl,0                         ;Entry into dl: drive selector: 0=current drive, 1=A, 2=B, etcetera.
    int  21h
    push  ax                          ;Ouput in ax: sectors per cluster, 0FFFFh=disk error if invalid or sectors per cluster in disk, or
    push  cx                          ;Output in cx: bytes per sector
    push  bx                          ;Output in bx: number of disk clusters
    push  dx                          ;Output in dx: number of free clusters: space=cx*ax*bx, free space=cx*ax*dx.

    mov  ax,3700h                ;Get current switch character
    int  21h
    push  dl                           ;Ouput in dl: current switch character; the switch character is the character
                                          ;used to identify switches in instruction paramters.The defaultr character for DOS                                         
                                          ;is "/". This character can be altered.

     mov  ax,3701h                ;Set new switch character.
     mov  dl,56                      ;Entry into dl: new switch character.
     int 21h

     mov  ah,38h                ;Get or set country dependent information: set active country code or return
                                       ;country dependedt information.
     mov  al,0                     ;Entry into al: country identification: 0=current, FFh=use bx, or
     mov  bx,0                    ;entry into bx: country identification; 0=current.
   ;mov  dx,FFFFh             ;Used to set country information only.
     mov  ds:dx,CTY_INFO            ;Entry into ds:dx: address CTY of information buffer; get country information only.
     int  21h
     push ax                       ;Return in ax: error code if Cf set. Fromat of buffer at ds:dx:
                                         ;CTY_INFO LABEL BYTE
                                               ;DB       1                     ;Selected country identification.
                                               ;DB       0                     ;Date format: 0=month-day-year, 1=day-month-year,
                                                                                  ;2=year-month-day.
                                               ;DB  "$",0,0,0,0            ;Currency symbol: "day-month", 0, ?, ?.
                                               ;DB    ",",0                    ;thousands operator,
                                               ;DB    ".",0                    ;decimal separator,
                                               ;DB    "/",0                   ;Time separator,
                                               ;DB    ":",0                    ;position currency number and symbol:
                                                                                   ;0=symbol, value
                                                                                   ;1=value, symbol
                                                                                   ;2=symbol, space, value
                                                                                   ;3=value, space, symbol
                                                                                   ;4=symbol is decimal separator.


    mov  ah,39h             ;Make a specified subdirectory: MKDIR.
    mov  ds:dx,zz          ;Entry into ds:dx: start address zz of ASCIIZ name or string for directory with a maximum of 128
                                  ;characters and terminated with a null character.
    int 21h
    push  ax                 ;Return in ax: error code carry flag set.

    mov  ah,3Ah           ;Remove a specified subdirectory: RMDIR.
    mov  ds:dx,zz         ;Entry into ds:dx: start address of ASCIIZ name; ds:dx=address of ASCIIZ string for directory,
    int  21h
    push  ax                 ;Return in ax: error code when carry flag is set.

    mov  ah,3Bh           ;Change current directory of a specified drive: CHDIR.
    mov  ds:dx,zz        ;Entry in ds:dx: address of ASCIIZ name; ds:dx=address of ASCIIZ string for new     directory.
    int  21h
    push  ax                ;Return in ax: error code when carry flag is set.

    mov  ah,3Ch           ;Make a file in specified directory and opens the file for read and write access.
    mov  cx,xx             ;Entry into cx: file attribute xx; bit 0 on for read only, bit 1 on for hidden,
                                 ;bit 2 on for system, bit 3 on for volume label, bit 4 on for reserved,
                                 ;bit 5 on for archive, bits 6 to 15 are reserved. ds:dx=address of ASCIIZ string
    int  21h
    push  ax                 ;Return in ax: error code if carry flag CF is set, or file handle.

    mov  ah,3Dh           ;Open a file
    mov  al,xx              ;Entry into al: access mode xx: bits 2 to 0 access code; 000 open for for reading, 001 for write,
                                 ;010 for read or write; bit 3 is reserved; bits 6 to 4 for sharing mode: 000 for
                                 ;compatibility, 001 for deny read or write, 010 for deny write, 011 for deny read,
                                 ;100 for deny none; bit 7 for handle inheritence: 0 for child inherits,
                                 ;1 for child does not inherit. al=2 to open for reading and writing
    mov  ds:dx,zz         ;Entry into ds:dx= addresszz of ASCIIZ name. LEA dx,filename.
    int  21h
    push ax                  ;Return in ax: error code if CF is set or file handle. MOV filehandle,ax.

    mov  ah, 3Eh          ;Close a file handle: forces the physical write of buffered data, updates the file's
                                ;directory and frees the file handle.
    mov  bx,xx            ;Entry into bx: file handle xx
    int  21h
    push  ax                ;Return in ax: error code if CF is set.

    mov  ah,3Fh           ;Read from a file or device: performs read from an open file at curent file pointer
                                 ;location by reading the number of bytes specified into a buffer.
    mov  bx,zz             ;Entry in bx: file handle zz.
    mov  cx,xx             ;Entry into cx: number of bytes xx to read.
    mov  ds:dx,cc         ;Entry into ds:dx: address cc of buffer; ds:dx=beuffer address, ax=number of bytes read, ax=0,
                                  ;if  read  from end of file.
    int   21h
    push  ax                 ;Return in ax: error code if Cf is set or bytes written if CF is clear.

    mov  ah,40h            ;Write to a file or device: performs a write to an open file at the current file pointer
                                  ;location by writing the number of bytes specified from a buffer.
    mov  bx,zz              ;Has same inputs and return as 3Fh. bx=file handle
    mov  cx,xx              ;cx=number of bytes to write.
    mov  ds:dx,cc          ds:dx=buffer address.
    int  21h
    push  ax                 ax=number of bytes written.

    mov  ah,41h             ;Delete a file: delectes a file from the specified directory.
    mov  ds:dx,zz          ;Entry into ds:dx: address zz of ASCIIZ name. ds:dx=address of ASCIIZ string.
    int  21h
    push  ax                  ;Return in ax: error code if CF is set.

    mov  ah,42h             ;Move file read or write pointer.
    mov  al,xx                ;Entry into al: location choice xx: 00h for cx:dx to beginning of file, 01h for add
                                   ;cx:dx to last access offset, 02h for add cx:dx to end of file.
    mov  bx,zz               ;Entry into bx: file handle zz.
    mov  cx:dx ,cc          ;Entry into cx;dx: file offset cc.
    int   21h
    push ax                    ;Return in ax: error code if CFis set.
    push  dx:ax              ;Return in dx:ax: new file position.

    mov ah, 43h            ;Get file attribute.
    mov al, 0                 ;ds:dx=address of ASCIIZ string for file.
    int 21h
                                   ;Return cx= attribute.

    mov  ah,45h             ;Duplicate an open file handle.
    mov  bx,zz               ;Existong file handle zz.
    int  21h
    push  ax                   ;Return in ax: error code if CF is set or new file handle.

   mov  ah,46h              ;Force duplicate file handle: duplicates a source handle reference to another target                                           
                                    ;handle. If arget handle is open it is closed prior to being replaced.
   mov  bx,zz                ;Source file handle zz,
   mov  cx,xx                ;target file handle xx.
   int  21h
   push  ax                    ;Return in ax: error code if CFis set.

   mov  ah,47h              ;Get current directory: returns current directory of specified drive.
   mov  dl,zz                 ;Drive number zz: zz= 0forcurrentdrive,zz=1=A drive, etecera; ds:si=address of 64 byte buffer.
   int  21h
   push  ax                    ;Return in ax: error code if CF is set; return in ds:si=address of ASCIIZ  string.


  mov  ah,48h            ;Allocate memory: returns the address of a contiguous block of system memory.
  mov  bx,zz              ;Entry into bx: number of paragraphs requested.
  int  21h
  push  ax                  ;Return in ax: error code if CF is set or segment of memory block. ax=segment address of
                                 ;allocated memory.
  push  bx                  ;Return in bx: available paragraphs.

  mov  ah,49h             ;Free allocated  memory block: releases the specified allocated memory block.
  mov  bs,zz               ;Segment of memory to release.
  mov es,xx                ;Segment address xx of memory to be free.
  int  21h
  push  ax                  ;Return in ax: error code if CF is set.

  mov  ah,4Ah         ;Modify allocated memory blocks: is used to change the size of an allocated block of memory. Set block
  mov  bx,zz           ;Entry into zz: new size zz in paragraphs. bx=nember of paragraphs
  mov  es,xx            ;Segment of memory to change. es=segment address of memory area.
  int  21h
  push  ax               ;Return in ax: error code if CF is set.
  push  bx               ;Return in bx: available paragraphs.

  mov  ax,4B00h      ;Execute a program: loads and begins execution of a child program without terminating
                              ;current program. Try 4Bh into ax. If 4Bh  for load and execute a program is used 4Bh in ah, al=0.
                               ;For load overlay al=3.;
  mov  es:bx,zz        ;Address zz of parameters. es:bx=address of parameter block.
  mov  ds:dx,xx        ;Entry intods;dx: address xx of ASCIIZ name, .EXE or .COM after program name
                              ;must be provided.
  int   21h
  push  ax                ;Return in ax: error code if CF is set. Format of the buffer at es:bx:

                                  ;zz  dw               ;environment segment
                                      ;  dd               ;instruction line address
                                      ;  dd               ;FCB1 address
                                      ;  dd               ;FCB2 address.

  mov  ax,4B01h        ;Load a program: loads a child program without terminating the current program without
                               ;beginning execution.
  mov  es:bx,zz         ;Address zz of parameters, start address of zz into dx.
  mov  ds:dx,xx         ;Entry into ds:dx: address xx of ASCIIZ name, .EXE or .COM must be provided.
  int  21h
  push ax                  ;Return in ax: error code if CF is set. Format of the buffer at ex:bx:
                                  zz   dw ?             ;environment segment
                                        dd 0             ;instruction line address
                                        dd 0             ;FCB1 address
                                        dd 0             ;FCB2 address
                                        dd 0              ;returned cs:ip value
                                        dd 0             ;returned ss:sp value.


  mov  ax,4B03h       ;Load an overlay into memoery without beginning execution of a program.
  mov  es:bx,zz         ;Entry into es:bx: address of paramemters.
  mov  ds:dx,xx         ;Address of ASCIIZ name.
  int  21h
  push  ax                 ;Return in ax: error code if CF is set. Format of the buffer ar es:bx:
                                 ;zz  DW                 ;overlay load segment address,
                                        DW                 ;overlay relocation factor for .EXE files.

  mov  ah,4Ch           ;Terminate a process or exit dos: is used to end execution of the current program and returns; exit dos for video mode.
  int  21h                 ;control to the parent program. Return code in al.
  push  al                 ;Return  in al: return code zz.

  mov  ah,4Dh          ;Get return code of a subprocess or chile, or wait: retrieves the user control code defined
                              ;during a terminate process ah=4Ch with int 21h.
  int  21h
  push  ah                ;Return in ah: exit type: 0 for normal exit, 1 for Ctrl+Break termination, 2 for critical
                              ;error termination, 3 for terminate and stay resident.
  push  al                 ;Return in al: return code. return in ax=return code process.

  mov  ah,4Eh          ;Find first matching file: searches for the first match of the specified file in specified
                              ;directory.
  mov  cx,zz            ;Entry into cx: file attribute zz: bit 0 for read only, bit 1 for hidden, 2 for system, 3 for
                              ;volume label, 4 for directory, 5 for archive, bits 6 to 15 are reserved.
  mov  ds:dx,xx        ;Entry into ds:dx: address xx of ASCIIZ name.
  int  21h
  push  ax                ;Return in ax: found file information.

  mov  ah,4Fh           ;Find next matching file: searches for the next matching file.
  mov  DTA              ;Restart information.
  int  21h
  push  ax                ;Return in ax: eror code if CF is set.
  push  DTA             ;Return: found file information. Format of the buffer at the DTA:
                                 ;DTA    DB   21 DUP(0)          ;reserved,
                                    ;       DB   ?                       ;file attribute,
                                    ;        DW  ?                       ;file time,
                                    ;        DW  ?                       ;file date,
                                    ;        DD   x                      ;file size x,
                                    ;        DB "filename.EXE",0  ;file name.

   mov ah, 54           ;Get verify state
   int 21h                   ;Return in al is 0 if verify is off, or 1 if verify is on.

  mov  ah,56h          ;Rename or move a file or rename a directory: used to rename and/or move a file to
                              ;different directory on the same disk. In addition, it is possible to rename a directory
                               ;with this function.
  mov  ds:dx,zz        ;address zz of previous ASCIIZ name,
  mov  es:di,xx         ;address xx of new ASCIIZ name.
  int   21h
  push  ax                ;Return in ax: error code if CF is set.

   mov  ax,5700h     ;Get a file's date and time stamp.
  mov  bx,zz           ;File handle zz into bx.
  int  21h
  push  ax               ;Return in ax: error code if CF is set,
  push  cx               ;Return in cx: file time: bits 4 to 0 for 0 to 29 units of 2 seconds day, bits 8 to 5 for
                             ;0 to 59 minutes, 15 to 11 for 0 to 23 hours,
  push  dx               ;Return in dx: bits 4 to 0 for 1 to 31 day, bits 8 to 5 for 1 to 12 month, bits 15 to 9
                             ;for year as 1980 to 2099.

  mov  ax,5701h      ;Set File's Date and Time
  mov  bx,zz           ;file handle zz,
  mov cx,time          ;time bits same as in 5700h,
  mov  dx,date        ;date bits same as in 5700h.
  int  21h
  push  ax               ;Return in ax: error code if CF is set.

  mov  ax,5800h      ;Get Current File Allocation Method
  int  21h
  push ax                 ;Return in ax: error code if CF is set.
  push  al,zz             ;Return in al: current allocation method: zz=0 for allocate low, zz=1 for allocate best,
                               ;zz=2 for allocate high.

  mov  ax,5801h      ;Set the new memory allocation method.
  mov  bl, zz           Allocation method: zz=0 for allocate low, zz=1 for allocate best, zz=2 for allocate high.
  int  21h.

  mov  ah,59h           ;Get extended error information: used to get additional information concening errors
                              ;returned during the execution of a DOS int 21h function invocation. Information returned
                              ; from this call includes the error, error class, suggested action, and error location.
  mov  bx,0
  int  21h
  push  ax                ;Return in ax: true error code, extended code
  push  bh                ;return in bh: error class,
  push  bl                 ;return in bl: error action, suggested action.
  push  ch                ;return locus.
 
  mov  ah,56h          ;Rename or move a file:rename a directory: used to rename and/or move a file to a
                              ;deifferent directory on the same disk.
  mov  ds:dx,zz        ;Entry into ds:dx: address zz of previous ASCIIZ name.
  mov  es:di,xx         ;Entry into es:di: address xx of new ASCIIZ name
  int  21h
  push  ax                ;Return in ax: error code if CF is set.

  mov  ax,5700h       ;Get a file's date and time: used to get a file's date and time stamp.
  mov  bx,zz             ;Entry into bx: file handle zz.
  int  21h
  push  ax                 ;Return in ax: error code if CF is set.
  push  cx                 ;Return in cx: file time: range and meaning: bit 4 to 0 for0 to 29 units of 2 seconds,
                               ;bits 10 to 5 for 0 to 59 minutes, bits 15 to 11 for 0 to 23 hours.
  push  dx                 ;Return in dx: file date: range or meaning: bits 4 to 0 for 1 to 31 day, bits 8 to 5 for
                               ;1 to 12 month, bits 15 to 9 for 0 to 119 as 1980 to 2019 year.

  mov  ax,5701h        ;Set file's date and time: used to set file's data and time stamp.
  mov  bx,zz             ;Entry into zz: file handle zz.
  mov  cx,xx             ;Entry into cx: file time bits xx same as in  5700h.
  mov  dx ,zz            ;Entry into dx: file date bits zz: same as in 5700h.
  int  21h
  push  ax                 ;Return in ax: error code if CF is set.

  mov  ah,67h            ;Set handle count: is used to set desired number of file handles from 20 to 32767 per
                                ;program.
  mov  bx,zz              ;Entry into bx: new file handle count zz.
  int  21h
  push  ax                  ;Return in ax: error code of CF is set.

  mov  ah,68h            ;Commit file: is used to force the physical write to a device of buffered sata and
                                ;directory associated with a file handle.
  mov  bx,zz              ;Entry into bx: file handle zz. 
  int  21h
  push  ax                  ;Return in ax: error code if CF is set.  

  mov  ax,5D07h       ;Get print stream state: gets the current netwrok print stream state.
  int  21h
  push  ax                 ;Retrun in ax: error code if CF is set.
  push  dl                  ;return in in dl: print stream state; 0 for truncation is off, 1 for truncation is on.

  mov  ax,5D08h       ;Set print stream state: sets a new network print stream state.
  mov  dl, zz             ;Entry into dl: zz=0 for truncation is off, zz=1 for truncation is on.
  int  21h
  push  ax                 ;Return in ax: error code if CF is set.

  mov  ax,5D09         ;Truncate print stream: truncates network print streams
  int  21h
  push  ax                  ;Retrun in ax: error code if CF is set.

  mov  ax,5D0Ah       ;Set extended error information: sets the DOS extended or additional error information
                               ;concerning errors returned during execution of a DOS int 21h function call.
  mov  ds:dx,zz         ;Address of DPL zz.
  int  21h
  push  ax                 ;Return in ax: error code if CFis set.

  mov  ax,5E00h       ;Get machine name: function is used to determine the computer name.
  mov  ds:si,xx          ;Entry into ds:si: address xx of name buffer.
  int  21h
  push  ax                 ;Return in ax: error code if CF is set.
  push  ch                 ;Return in ch: name flag:bit 0 for 0=no name set, 1=name set.
  push  cl                  ;Return in cl: NETBIOS name number when ch bit 0 is 1. Format of the buffer at ds:si:
                                    ;xx  DB   "computer name ", 0  :15 character ASCIIZ string.

  mov  ax,5E01h       ;Set machine name: used to establish the computer name.
  mov  cl,zz              ;Entry into cl: NETBIOS name number zz.
  mov  ds:si, xx         ;Entry into ds:si: address of name.
  int  21h
  push  ax                 ;Return in ax: error code if CF is set. Format of the buffer at ds:si:
                                 ;xx   DB   "computer name",0   ;15 character ASCIIZ string.

  mov  ax,5E02h       ;Set printer setup: used to set a unique printer mode when multiple users are accessing
                               ;the same printer.
  mov  bx,zz             ;Redirection index zz.
  mov  cx,xx             ;String length xx.
  mov  ds:si,cc           ;Addtess cc of string.
  int   21h
  push  ax                 ;Return in ax: error code if CF is set.

  mov  ax,5E03h       ;Get printer setup: gets current printer setup string.
  mov  bx,zz             ;Redirection index zz.
  mov  ds:si,xx          ;Address xx of buffer.
  int  21h
  push  ax                ;Return in ax: error code if CF is set.
  push  cx                ;Return in cx: string length.

  mov  ax,5E04h      ;Set printer mode: used to set the current printer text or binary mode.
  mov  bx,zz            ;Redirection index zz.
  mov  dx,xx            ;Print stream mode: print stream mode: bot 0 for 0=print stream is text data,
                              ;1=print stream is binary data.
  int  21h
  push  ax                ;Return in ax: error code if CF is set. 

  mov  ax,5E05h      ;Get printer mode: used to get current printer text or binary data.
  mov  bx,zz            ;Redirection index zz.
  int  21h
  push  ax               ;Return in ax: error code if CF is set.
  push  dx               ;Return in dx: print stream mode: bit 0 for 0= text mode, 1=binary mode.

  mov  ax,5F00h      ;Get redirection mode.
  mov  bl,zz             ;Redirerction type: zz=3 selects printers, 4 selects drives.
  mov  bh,xx            ;Redirection state: xx=0 for redirection off, xx=1 for redirection on.
  int  21h
  push  ax                ;Return in ax: error code if CF is set.
  push  bh                ;Return in bh: redirection state: 0=redirection off, 1=redirection on.

  mov  ax,5F01h       ;Set redirection mode: set a new redirection mode: when off the redirection of a
                              ;device is paused, when on the redirected local device is used.
  mov  bl,zz             ;Redirection type: zz=3 selects printers, 4=selects drives.
  mov  bh,xx            ;Redirection state: xx=0 for redirection off, xx=1 for redirection on.
  int  21h
  push  ax                ;error code if CF is set.

  mov  ax,5F03h      ;Redirect a device: used to connect a local device across a netwrok by establishing a
                              ;redirector to server association.
  mov  bl,zz             ;Device type: zz=3 for device is a printer, zz=4 for device is a disk drive
  mov  cx,0              ;User value set to 0.
  mov  ds:si,NET_DEVICE   ; Address of device.
  mov  es:di,xx         ;Address xx of network definition.
  int  21h
  push  ax                ;Return in ax: error code if CF is set.
     NET_DEVICE   DB  "PRN",0                   ;1 to 8 characters: PRN, LPT1, LPT2, or LPT3.
     NET_DEST      DB  "\\computer name or drive name", 0
                             DB  "password",  0           ;1 to 8 character password.

    NET_DRIVE    DB     'f:',0         ;1 character name,
    NET_DEST      DB   "\\computer or drive name",0
                           DB  "password",0                ;1 to 8 character password.
 

   mov ah,62h       ;Get PSP
   int 21h              ; Return in bx=segment address of PSP.


  mov ax,xx              ;Turns text into uppcase letters: xx=6520h for capitalize dl, xx=6521h for capitalize 
                               ;fixed string, xx=6522h for captialize ASCIIZ string.
  mov  dl,zz              ;caharcter zz for funtion 6520h only.
  mov  cx,cc              ;String length cc for funtion 6521h only.
  mov  ds:dx,vv          ;Address vv of string for funtion 6521h or 6522h only.
  int   21h
  push  ax                 ;Return in ax: eror code if CF isset.
  push  dl                  ;Return in dl: capitalized character for funtion 6520h only.

  mov  ax,6523h        ;Yes or no check: used to determine if a character indicates a yes or no response.
  mov  dl,zz               ;Character zz.
  mov  dh,xx              ;Second character only if DBCS= double byte character support..
  int  21h
  push  ax                  ;Return in ax: CF set = not yes or no, 0=no, 1=yes.


    mov rr,dx                  ;Examples for storing into variables like rr, or ww.
    mov ww,ds


                               
   int   05h                    ;Interrupt 05h: print-screen service
  
                                    ;Obtain amount free space that is available on floppy disk drive A.
   mov   ah,36h               ;Entry in ah: function 36h.
   mov   dl,1                    ;Entry in dl, drive specification:  0=default, 1=drive A: want free space in drive A=1.
   int    21h                     ;Start 36h: invoke interupt.
   cmp   ax, 0ffffh           ;Test return code for error.
   je     err_rtn               ;Specified drive is invalid, if error is indicated branch to this error handler subpgrogram err_rtn .
   mov  sec_clu,ax           ;Return value is ax; sectors or clusters or FFFFh if drive specification is invalid; save                                   
                                              ;sectors per cluster in variable sec_clu.
   mov   avl_clu,bx          ;Return in ax; available clusters or free space: save available cluster in avl_clu.
   mov   byt_sec,cx         ;Reurn in cx; number of bytes or sector,save bytes per sector in variable byt_sec.
   mov   xx_h,dx             ;Return in dx: clusters or drive.

 mov ah,3Ch          ;Make a file.
 int 21h
  mov ah,5Bh          ;Make a new file and fail if file exists.

  mov ah,5Ah          ;Make a unique file.

  mov ah,3Dh          ;Open file.

  mov ah,6Ch          ;Extended open and make file: combines services of funtions
                              ;3Dh, 3Ch and 5Bh.

  mov ah,3Eh          ;Close file.

  mov ah,41h          ;Delete a file from a specific directory.

  mov ah,45h          ;Get new duplicate file handle.

  mov ah,43h          ;Change file mode.

  mov ah,46h          ;Force duplication of existing file handle.

  mov ah,4Eh          ;Find first matching file.

  mov ah,4Fh          ;Find next matching file.

  mov ah,56h          ;Rename a file.

  mov ah,57h          ;Get or set a file's date and time.

  mov ah,67h          ;Set file handle count.

  mov ah,68h          ;Clear file data and update directory entry.

                          Int 33h Mouse DOS Functions   mov ax,0               ;Reset mouse (screen cursor control) function, initialize mouse .
   int 33h                   ;0 into ax if there is no mouse connection.
   mov ax,bx              ;Number of mouse butons into ax from bx


   mov ax,1               ;Turn on mouse. Display text mode mouse cursor.
   int 33h

   mov ax,2               ;Remove text mode cursor from screen.
   int 33h 

   mov ax,3               ;Get mouse position and button status
   int 33h              
   mov ax,bx              ;Return button status from bx into ax, 1 for left button press, 2 for right mouse button press, 4 for center button press.
   mov bx,x               ;Return x=[EBP+8] mouse position
   mov WORD PTR [bx],cx   ;from cx.
   mov bx,y               ;Returnn y=[EBP+12] mouse position< STRONG> .
   mov WORD PTR [bx],dx   ;from dx.