home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / nor_asm / clib.asm next >
Assembly Source File  |  1989-06-13  |  3KB  |  82 lines

  1. .MODEL    SMALL,C
  2.  
  3. .CODE
  4.  
  5. ;-----------------------------------------------------------------------;
  6. ; This procedure clears the entire screen.                ;
  7. ;-----------------------------------------------------------------------;
  8. CLEAR_SCREEN    PROC
  9.     XOR    AL,AL            ;Blank entire window
  10.     XOR    CX,CX            ;Upper left corner is at (0,0)
  11.     MOV    DH,24            ;Bottom line of screen is line 24
  12.     MOV    DL,79            ;Right side is at column 79
  13.     MOV    BH,7            ;Use normal attribute for blanks
  14.     MOV    AH,6            ;Call for SCROLL-UP function
  15.     INT    10h            ;Clear the window
  16.     RET
  17. CLEAR_SCREEN    ENDP
  18.  
  19. ;-----------------------------------------------------------------------;
  20. ; This procedure writes a string of characters to the screen.  The    ;
  21. ; string must end with        DB    0                ;
  22. ;                                    ;
  23. ;    write_string(string);                        ;
  24. ;    char    *string;                        ;
  25. ;-----------------------------------------------------------------------;
  26. WRITE_STRING    PROC    USES SI, STRING:PTR BYTE
  27.     PUSHF                ;Save the direction flag
  28.     CLD                ;Set direction for increment (forward)
  29.     MOV    SI,STRING        ;Place address into SI for LODSB
  30.  
  31. STRING_LOOP:
  32.     LODSB                ;Get a character into the AL register
  33.     OR    AL,AL            ;Have we found the 0 yet?
  34.     JZ    END_OF_STRING        ;Yes, we are done with the string
  35.     MOV    AH,14            ;Ask for write character function
  36.     XOR    BH,BH            ;Write to page 0
  37.     INT    10h            ;Write one character to the screen
  38.     JMP    STRING_LOOP
  39.  
  40. END_OF_STRING:
  41.     POPF                ;Restore direction flag
  42.     RET
  43. WRITE_STRING    ENDP
  44.  
  45. ;-----------------------------------------------------------------------;
  46. ; This procedure moves the cursor                    ;
  47. ;                                    ;
  48. ;    goto_xy(x, y);                            ;
  49. ;    int    x, y;                            ;
  50. ;-----------------------------------------------------------------------;
  51. GOTO_XY        PROC    X:WORD, Y:WORD
  52.     MOV    AH,2            ;Call for SET CURSOR POSITION
  53.     MOV    BH,0            ;Display page 0
  54.     MOV    DH,BYTE PTR (Y)        ;Get the line number (0..N)
  55.     MOV    DL,BYTE PTR (X)        ;Get the column number (0..79)
  56.     INT    10h            ;Move the cursor
  57.     RET
  58. GOTO_XY        ENDP
  59.  
  60. ;-----------------------------------------------------------------------;
  61. ; This procedure reads on key from the keyboard.            ;
  62. ;                                    ;
  63. ;    key = read_key();                        ;
  64. ;-----------------------------------------------------------------------;
  65. READ_KEY    PROC
  66.     XOR    AH,AH            ;Ask for keyboard read function
  67.     INT    16h            ;Read character/scan code from keyboard
  68.     OR    AL,AL            ;Is it an extended code?
  69.     JZ    EXTENDED_CODE        ;Yes
  70. NOT_EXTENDED:
  71.     XOR    AH,AH            ;Return just the ASCII code
  72.     JMP    DONE_READING
  73.  
  74. EXTENDED_CODE:
  75.     MOV    AL,AH            ;Put scan code into AL
  76.     MOV    AH,1            ;Signal extended code
  77. DONE_READING:
  78.     RET
  79. READ_KEY    ENDP
  80.  
  81.     END
  82.