1 / 17

Chapter 8 Introduction to Video and Keyboard Processing

Chapter 8 Introduction to Video and Keyboard Processing. INT 10H functions 02H set cursor 06H scroll screen INT 21H functions 02H display character 09H display string 0AH input from keyboard 3FH input from keyboard 40H display string. (00,00) or (00H,00H) (00,79) or (00H,4FH).

shauna
Télécharger la présentation

Chapter 8 Introduction to Video and Keyboard Processing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 8 Introduction to Video and Keyboard Processing

  2. INT 10H functions 02H set cursor 06H scroll screen INT 21H functions 02H display character 09H display string 0AH input from keyboard 3FH input from keyboard 40H display string

  3. (00,00) or (00H,00H) (00,79) or (00H,4FH) (12,39/40) or (0CH,27H/28H) (24,00) or (18H,00H) (24,79) or (18H,4FH) SCREEN FEATURES Cursor locations: The system provides space in memory for a Video Display Area. In text mode, the video display area requires 4K bytes of memory, 2K for characters, and 2K for attributes, such as reverse video, blinking, high intensity and underlining.

  4. Setting the cursor INT 10H functions 02H BIOS operation for screen handling. Set the cursor to row 08, column 15: MOV AX, 02H ;set cursor MOV BH, 00 ;page number 0 MOV DH, 08 ;row 8 MOV DL, 15 ;column 15 INT 10H ;call interrupt service MOV DX,080FH

  5. Clearing the screen INT 10H functions 06H AH = function 06H AL = number of lines to scroll, or 00H for the full screen BH = attribute (color, blinking, etc.) CX = starting row : column DX = ending row : column Set the full screen to white background (attribute 7) with blue foreground (attribute 1): MOV AX, 0600H ;AH=06 (scroll), AL=00 (full screen) MOV BH, 71H ;white background(7), blue foreground(1) MOV CX, 0000H ;upper left row : column MOV DX, 184FH ;lower right row: column INT 10H

  6. Screen Display INT 21H functions 09H CUST_MSG DB ‘Customer names?’,’$’ MOV AH,09H ;request display LEA DX, CUST_MSG ;load address of prompt INT 21H ;call interrupt service

  7. TITLE A08DISAS (COM) Display ASCII character set .MODEL TINY 0000 .CODE ORG 100H 0100 EB 02 BEGIN: JMP SHORT A10MAIN 0102 00 24 ASCHAR DB 00, '$' ; Main procedure: .286 ; -------------- 0104 A10MAIN PROC NEAR 0104 E8 000B CALL B10SCREEN ;Clear screen 0107 E8 0018 CALL C10CURSOR ;Set cursor 010A E8 0021 CALL D10DISPLY ;Display characters 010D B8 4C00 MOV AX,4C00H ;End processing 0110 CD 21 INT 21H 0112 A10MAIN ENDP ; Clear screen and set attribute: ; ------------------------------ 0112 B10SCREEN PROC NEAR 0112 60 PUSHA ;Preserve general registers 0113 B8 0600 MOV AX,0600H ;Scroll full screen 0116 B7 07 MOV BH,07 ;Attribute: white on black 0118 B9 0000 MOV CX,0000 ;Upper left location 011B BA 184F MOV DX,184FH ;Lower right location 011E CD 10 INT 10H ;Call BIOS 0120 61 POPA ;Restore general registers 0121 C3 RET ;Return to caller 0122 B10SCREEN ENDP

  8. ; Set cursor to 08,00: ; ------------------- 0122 C10CURSOR PROC NEAR 0122 60 PUSHA ;Preserve general registers 0123 B4 02 MOV AH,02H ;Request set cursor 0125 B7 00 MOV BH,00 ;Page number 0 0127 BA 0800 MOV DX,0800H ;Row 8, column 0 012A CD 10 INT 10H ;Call BIOS 012C 61 POPA ;Restore general registers 012D C3 RET ;Return to caller 012E C10CURSOR ENDP ; Display ASCII characters 00H - FFH, ; bypass if between 08H and 0DH: ; ---------------------------------- 012E D10DISPLY PROC 012E 60 PUSHA ;Preserve general registers 012F B9 0100 MOV CX,256 ;Initialize 256 iterations 0132 8D 16 0102 R LEA DX,ASCHAR ;Initialize address of ASCHAR 0136 80 3E 0102 R 08 D20: CMP ASCHAR,08H ;Character below 08H? 013B 72 07 JB D30 ; yes, accept 013D 80 3E 0102 R 0D CMP ASCHAR,0DH ;Below or equal 0DH? 0142 76 04 JBE D40 ; yes, bypass 0144 B4 09 D30: MOV AH,09H ;Display ASCII character 0146 CD 21 INT 21H 0148 FE 06 0102 R D40: INC ASCHAR ;Increment for next character 014C E2 E8 LOOP D20 ;Decrement CX, loop nonzero 014E 61 POPA ;Restore general registers 014F C3 RET ;Return to caller 0150 D10DISPLY ENDP END BEGIN

  9. The program bypass displaying characters between 08H and 0DH. 08H: backspace 09H: tab 0AH: line feed 0DH: carriage return 24H: dollar sigh $ not displayed under function 09H

  10. KEYBOARD INPUT INT 21H functions 0AH The input data for keyed-in characters requires a parameter list. Example defining a parameter list for a keyboard input area: PARA_LIST LABEL BYTE ;start of parameter list MAX_LEN DB 20 ;maximum number of input characters ACT_LEN DB ? ;actual number of input characters KB_DATA DB 20 DUP(‘ ‘) ;characters entered To request keyboard input: MOV AH, 0AH ;request keyboard input LEA DX, PARA_LIST ;load address of parameter list INT 21H ;call interrupt service

  11. IF you key in a name such as Wilson + <Enter>: ASCII: 20 6 W i l s o n # … Hex: 14 06 57 69 6C 73 6F 6E 0D 20 20 20 … It accepts and acts on the Backspace character and doesn’t add it to the count. If a user enters 20 characters without pressing <Enter>, the operation causes the speaker to beep; at this point, it accepts <Enter> only. It bypasses extended function keys such as F1, HOME, PgUp, and Arrows.

  12. TITLE A08CTRNM (EXE) Accept names from keyboard, ; center them on screen, sound bell .MODEL SMALL .STACK 64 .DATA PARLIST LABEL BYTE ;Name parameter list: MAXNLEN DB 20 ; maximum length of name ACTULEN DB ? ; no. of characters entered KBNAME DB 21 DUP(' ') ; entered name PROMPT DB 'Name? ', '$' ;------------------------------------------------------- .CODE .386 ;Directive for MOVZX A10MAIN PROC FAR MOV AX, @data ;Initialize segment MOV DS,AX ; registers MOV ES,AX CALL Q10CLEAR ;Clear screen

  13. A20: MOV DX,0000 ;Set cursor to 00,00 CALL Q20CURSOR CALL B10INPUT ;Provide for input of name CALL Q10CLEAR ;Clear screen CMP ACTULEN,00 ;Name entered? JE A30 ; no, exit CALL C10CENTER ;Set bell and '$' and center CALL D10DISPLY ;Display name JMP A20 ;Repeat A30: MOV AX,4C00H ;End processing INT 21H A10MAIN ENDP

  14. ; Display prompt and accept input of name: ; -------------------------------------- B10INPUT PROC NEAR PUSH AX ;Preserve used PUSH DX ; registers MOV AH,09H ;Request display LEA DX,PROMPT ; of user prompt INT 21H MOV AH,0AH ;Request keyboard LEA DX,PARLIST ; input INT 21H POP DX ;Restore POP AX ; registers RET B10INPUT ENDP

  15. ; Set bell and '$' delimiter and ; set cursor at center of screen: ; -------------------------------- C10CENTER PROC NEAR ;Uses BX and DX MOVZX BX,ACTULEN ;Replace 0DH (<Enter>) MOV KBNAME[BX],07 ;with 07H (bell) MOV KBNAME[BX+1],'$' ;Set display delimiter MOV DL,ACTULEN ;Locate center column: SHR DL,1 ; divide length by 2, NEG DL ; reverse sign, ADD DL,40 ; add 40 MOV DH,12 ;Center row CALL Q20CURSOR ;Set cursor RET C10CENTER ENDP ; Display centered name: ; --------------------- D10DISPLY PROC NEAR ;Uses AH and DX MOV AH,09H LEA DX,KBNAME ;Display name INT 21H RET D10DISPLY ENDP

  16. ; Clear screen and set attribute: ; ----------------------------- Q10CLEAR PROC NEAR PUSHA ;Preserve general registers MOV AX,0600H ;Request scroll screen MOV BH,30 ;Color attribute MOV CX,0000 ;From 00,00 MOV DX,184FH ; to 24,79 INT 10H POPA ;Restore general registers RET Q10CLEAR ENDP ; Set cursor row, column: ; --------------------- ;DX set on entry Q20CURSOR PROC NEAR ;Uses AH and BH MOV AH,02H ;Request set cursor MOV BH,00 ;Page #0 INT 10H RET Q20CURSOR ENDP END A10MAIN

  17. Exercise: • Revise Program A08CTRNM for the following changes: • Allow for names up to 25 characters • Set the cursor at row 07 • Clear screen from rows 0 through 07 and use attribute 16H

More Related