Скачать презентацию 7 4 Controlling the Speaker mov DL 7 Скачать презентацию 7 4 Controlling the Speaker mov DL 7

717d44f05def8adde36a491e3f4c8401.ppt

  • Количество слайдов: 7

7. 4 Controlling the Speaker mov DL, 7 mov AH, 2 int 21 h 7. 4 Controlling the Speaker mov DL, 7 mov AH, 2 int 21 h To control the frequency and duration of a sound, three output ports must be written: - output port 61 H, bits 0 and 1 should be set the time the sound has to be generated (gate) - port 43 H sets the count mode of the divider generating the frequency for the speaker - port 42 H has to be written with the value that divides clock frequency (1. 19 MHz) to desired audio frequency (two bytes, in two successive OUTs, least significant byte, first). The most simple way: “display” the “BEL” (bell) ASCII character: mov AL, 0 B 6 h out 43 h, AL mov CX, 1190 mov AL, CL out 42 h, AL mov AL, CH out 42 h, AL in AL, 61 H or AL, 3 out 61 h, AL call DELAY in AL, 61 h and 0 FCh out 61 h, AL ; select counter 2, mode 3, binary counting ; output control-word to counter/timer ; load “divider” value into CX ; output lower byte of divider to counter ; output higher byte of divider to counter ; read current state of parallel port ; set B 0 and B 1 ; output new state to parallel port ; delay of desired sound duration ; read current state of parallel port ; clear B 0 and B 1 ; output new state to parallel port to estimate the time for subroutine DELAY, start from CK frequency (i. e. 200 MHz), consider about 10 -20 CK periods for a simple loop, and compute the necessary number of loop iterations. . . DELAY: mov DX, 5000 WAIT 1: mov CX, 500 WAIT 2: loop WAIT 2 dec DX jnz WAIT 1 ret

7. 5 Controlling the Printer DOS INT 21, function 05 H: Printer Output Specification: 7. 5 Controlling the Printer DOS INT 21, function 05 H: Printer Output Specification: outputs to printer the ASCII code contained by register DL. Input: AH = 05 (function code), DL = the ASCII code to be printed BIOS INT 17, function 00 H: Print Character Specification: similar to INT 21 function 05 but returns in AH a status code. AL contains the ASCII character to be printed, DX specifies the printer number (0 trough 2). Input: AH = 00 (function code), AL = the ASCII code to be printed, DX = the printer number Output: AH = the printer status code: each bit in AH (when 1) means: B 7 = Printer not busy B 3 = I/O error B 6 = Acknowledgement from printer B 2 = reserved B 5 = Out of paper B 1 = reserved B 4 = Printer selected B 0 = Time-out error BIOS INT 17, function 01 H: Initialize Printer Specification: initialize the printer who’s number is specified in DX. Returns in AH the status. Input: AH = 01 (function code), DX = printer number (0 trough 2) Output: AL = Printer Status (similar to function 00). BIOS INT 17, function 02 H: Read Printer Status Specification: reads printer status without affecting it in any way. Input: AH = 02 (function code), DX = printer number (0 trough 2) Output: AL = Printer Status (similar to function 00).

7. 6 Using the Command-Line Interface The Program Segment Prefix Structure (build by DOS 7. 6 Using the Command-Line Interface The Program Segment Prefix Structure (build by DOS and loaded immediately before the executable code of the. EXE or. COM program): At loading the program in PC’s 0 -1 INT 20 (the code of INT 20 instruction) memory, the 256 bytes Program 2 -3 top of memory Segment Prefix is loaded right 4 -9 reserved before the program code. ES and A-B terminate address IP DS point both the begin of Program C-D terminate address CS Segment Prefix (so the offset to E-F Ctrl-break exit address IP point it’s first byte is “ 0”). 10 -11 Ctrl-break exit address CS This is the reason the program has 12 -13 Critical error exit address IP to load DS with the value for actual 14 -15 Critical error exit address CS data’s segment. 16 -4 F reserved 50 -51 INT 21 (the code of INT 21 instruction) 52 -5 B reserved 5 C-6 B unopened standard FCB 1 6 C-7 B unopened standard FCB 2 80 parameter length 81 -FF Command tail parameters

7. 6 Using the Command-Line Interface ; Program ECHO. ASM: Echo command-line text to 7. 6 Using the Command-Line Interface ; Program ECHO. ASM: Echo command-line text to screen. . MODEL SMALL. DATA TESTSTR DB 'Data declared in DATA segment'. STACK db 100 dup(? ). CODE. STARTUP START: MOV BL, ES: [80 H] ; get character count from PSP CMP BL, 0 ; are there any characters? JZ EXIT MOV SI, 81 H ; set up pointer to command tail EKHO: MOV DL, ES: [SI] ; get command-tail character MOV AH, 2 ; display output (character in DL) INT 21 H ; DOS call INC SI ; advance to next character DEC BL ; finished? JNZ EKHO ; repeat until done EXIT: . EXIT END

7. 6 Using the Command-Line Interface 0000 001 D 0000 0017 001 C 001 7. 6 Using the Command-Line Interface 0000 001 D 0000 0017 001 C 001 F 0021 0024 0027 0029 002 B 002 C 002 E 0030 ; Program ECHO. ASM: Echo command-line text to screen. . MODEL SMALL. DATA 44 61 74 61 20 64 65 63 TESTSTR DB 'Data declared in DATA segment' 6 C 61 72 65 64 20 69 6 E 20 44 41 54 41 20 73 65 67 6 D 65 6 E 74. STACK 0064 [00] db 100 dup(? ). CODE. STARTUP 26: 8 A 1 E 0080 START: MOV BL, ES: [80 H] ; get character count from PSP 80 FB 00 CMP BL, 0 ; are there any characters? 74 0 F JZ EXIT BE 0081 MOV SI, 81 H ; set up pointer to command tail 26: 8 A 14 EKHO: MOV DL, ES: [SI] ; get command-tail character B 4 02 MOV AH, 2 ; display output (character in DL) CD 21 INT 21 H ; DOS call 46 INC SI ; advance to next character FE CB DEC BL ; finished? 75 F 4 JNZ EKHO ; repeat until done EXIT: . EXIT END

2778: 0000 2778: 0003 2778: 0005 2778: 0007 2778: 0009 2778: 000 B 2778: 2778: 0000 2778: 0003 2778: 0005 2778: 0007 2778: 0009 2778: 000 B 2778: 000 D 2778: 000 F 2778: 0011 2778: 0012 2778: 0014 2778: 0016 2778: 0017 2778: 001 C 2778: 001 F 2778: 0021 2778: 0024 2778: 0027 2778: 0029 2778: 002 B 2778: 002 C 2778: 002 E 2778: 0030 2778: 0032 BA 7 B 27 8 EDA 8 CD 3 2 BDA D 1 E 3 FA 8 ED 2 03 E 3 FB 268 A 1 E 8000 80 FB 00 740 F BE 8100 268 A 14 B 402 CD 21 46 FECB 75 F 4 B 44 C CD 21 MOV MOV SUB SHL SHL CLI MOV ADD STI MOV CMP JZ MOV MOV INT INC DEC JNZ MOV INT 7. 6 Using the Command-Line Interface DX=277 B DS=277 B BX=2784 BX=0009 BX=0012 BX=0024 BX=0048 BX=0090 disable INTs SS=277 B SS, DX SP=0490 SP, BX enable INTs BL, BYTE PTR ES: [0080] BL, 00 0030 SI, 0081 DL, BYTE PTR ES: [SI] AH, 02 21 SI BL 0024 AH, 4 C 21 DX, 277 B DS, DX BX, SS BX, DX BX, 1 Register content immediately after loading program in memory AX BX CX DX SP BP SI DI DS ES SS CS IP FL = = = = 0000 0400 0000 2768 2784 2778 0000 0200

7. 6 Using the Command-Line Interface Memory dump showing the Program Segment Prefix (0000 7. 6 Using the Command-Line Interface Memory dump showing the Program Segment Prefix (0000 -00 FF), The Executable Program (0100 -0133) and data (0134 -. . . ) 2768: 0000 CD 2768: 0010 EA 19 2768: 0020 FF 2768: 0030 4 D 17 2768: 0040 07 0 A 2768: 0050 CD 2768: 0060 20 2768: 0070 47 2768: 0080 27 2768: 0090 67 2768: 00 A 0 65 2768: 00 B 0 3 A 2768: 00 C 0 52 2768: 00 D 0 6 F 2768: 00 E 0 00 2768: 00 F 0 4 F 2768: 0100 BA 2768: 0110 E 3 2768: 0120 0 F 2768: 0130 B 4 2768: 0140 64 20 0 B FF 14 00 21 20 52 20 75 64 5 C 4 F 74 43 57 7 B FA BE 4 C 20 00 9 F 00 9 A 00 FA 10 7 B 1 B FF FF 00 18 00 68 27 00 00 00 CB 00 00 00 20 20 41 4 D 20 20 54 68 65 20 6 D 65 6 E 74 20 68 65 72 77 69 6 E 64 4 D 50 54 3 D 64 69 72 3 D 4 F 4 D 53 50 53 5 C 43 4 F 27 8 E DA 8 C 8 E D 2 03 E 3 81 00 26 8 A CD 21 44 61 69 6 E 20 44 F 0 01 FF FF 00 00 20 20 70 73 65 6 F 24 43 45 4 D D 3 FB 14 74 41 FE 1 D F 0 96 01 01 00 01 01 FF FF 00 00 00 20 00 00 00 72 6 F 67 72 20 61 72 65 21 0 D 00 54 77 73 5 C 54 70 24 67 00 3 A 5 C 57 49 43 3 D 43 3 A 4 D 41 4 E 44 2 B DA D 1 E 3 26 8 A 1 E 80 B 4 02 CD 21 61 20 64 65 54 41 20 73 02 08 FF 00 00 00 61 20 45 45 77 4 E 5 C 2 E D 1 00 46 63 65 EA FF 8 C 00 00 00 6 D 73 4 D 4 D 69 44 57 43 E 3 80 FE 6 C 67 19 97 03 Í. Ÿ. šðþ ð– ê — ê. ú { . ÿ 1 B 94 27 ÿÿÿÿÿÿŒ ”' M . . h'ÿÿÿÿ. . . . . 54 48 45 Í!Ë. . THE 50 52 4 F. . . PRO 00 00 00 GRAM. . . . 20 61 72 ' The program ar 74 6 F 72 guments are stor 50 3 D 43 ed here!. . TEMP=C 50 00 50 : windowsTEMP. P 6 E 62 6 F ROMPT=$p$g. winbo 4 F 57 53 otdir=C: WINDOWS 49 4 E 44. COMSPEC=C: WIND 4 F 4 D 00 OWSCOMMAND. COM. D 1 E 3 D 1 º{'ŽÚŒÓ+ÚÑãÑãÑãÑ FB 00 74 ãúŽÒ ãû&Š €. €û. t CB 75 F 4 ¾&Š ´ Í!. FþËuô 61 72 65 ´LÍ!Data declare 6 D 65 6 E d in DATA segmen