AX -T AX=0148 BX=0148 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0108 NV UP EI PL NZ NA PO NC 13C6:0108 03D8 ADD BX,AX -T AX=0148 BX=0290 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=010A NV UP EI PL NZ AC PO NC 13C6:010A 8BCB MOV CX,BX -T AX=0148 BX=0290 CX=0290 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=010C NV UP EI PL NZ AC PO NC 13C6:010C 2BC8 SUB CX,AX -T AX=0148 BX=0290 CX=0148 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0100 NV UP EI PL NZ AC PO NC 13C6:010E 2BC0 SUB AX,AX -T AX=0000 BX=0290 CX=0148 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0110 NV UP EI PL ZR NA PO NC 13C6:0110 90 NOP -T AX=0000 BX=0290 CX=0148 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0111 NV UP EI PL ZR NA PO NC 13C6:0111 CB RETF - Assembler dlya IBM PC. Programmy. 13 -D CS:100 13C6:0100 B8 23 01 05 25 00 8B D8-03 D8 8B CB 2B C8 2B C0 .#..%.......+.+. 13C6:0110 90 CB 8D 46 14 50 51 52-FF 76 28 E8 74 00 8B E5 ...F.PQR.v(.t... 13C6:0120 B8 01 00 50 FF 76 32 FF-76 30 FF 76 2E FF 76 28 ...P.v2.v0.v..v( 13C6:0130 E8 88 15 8B E5 BF 36 18-12 FF 36 16 12 8B 76 28 ......6...6...v( 13C6:0140 FF 74 3A 89 46 06 E8 22-CE 8B E5 30 E4 3D 0A 00 .t:.F.."...0.=.. 13C6:0150 75 32 A1 16 12 2D 01 00-8B 1E 18 12 83 DB 00 53 u2...-.........S 13C6:0160 50 8B 76 28 FF 74 3A A3-16 12 89 1E 18 12 E8 FA P.v(.t:......... 13C6:0170 CD 8B E5 30 E4 3D 0D 00-74 0A 83 06 16 12 01 83 ...0.=..t....... -Q Assembler dlya IBM PC. Programmy. 14 D>DEBUG -E DS:23 01 25 00 00 -E DS:2A 2A 2A -E CS:100 A1 00 00 03 06 02 00 -E CS:107 A3 04 00 CB -D DS:0 13C6:0000 23 01 25 00 00 9A 2A 2A-2A F0 F5 02 2C 10 2E 03 #.%...***...,... 13C6:0010 2C 10 BD 02 2C 10 B1 0D-01 03 01 00 02 FF FF FF ,...,........... 13C6:0020 FF FF FF FF FF FF FF FF-FF FF FF FF EF 0F 64 00 ..............d. 13C6:0030 61 13 14 00 18 00 C7 13-FF FF FF FF 00 00 00 00 a............... 13C6:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13C6:0050 CD 21 CB 00 00 00 00 00-00 00 00 00 00 20 20 20 .!........... 13C6:0060 20 20 20 20 20 20 20 20 00 00 00 00 00 20 20 20 ..... 13C6:0070 20 20 20 20 20 20 20 20-00 00 00 00 00 00 00 00 ........ -R AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0100 NV UP EI PL NZ NA PO NC 13C6:0100 A10000 MOV AX,[0000] DS:0000=0123 -T AX=0123 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0103 NV UP EI PL NZ NA PO NC 13C6:0103 03060200 ADD AX,[0002] DS:0002=0025 -T AX=0148 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0107 NV UP EI PL NZ NA PE NC 13C6:0107 A30400 MOV [0004],AX DS:0004=9A00 -T AX=0148 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0108 NV UP EI PL NZ NA PO NC 13C6:010A CB RETF -D DS:0 13C6:0000 23 01 25 00 00 9A 2A 2A-2A F0 F5 02 2C 10 2E 03 #.%...***...,... 13C6:0010 2C 10 BD 02 2C 10 B1 0D-01 03 01 00 02 FF FF FF ,...,........... 13C6:0020 FF FF FF FF FF FF FF FF-FF FF FF FF EF 0F 64 00 ..............d. 13C6:0030 61 13 14 00 18 00 C7 13-FF FF FF FF 00 00 00 00 a............... 13C6:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13C6:0050 CD 21 CB 00 00 00 00 00-00 00 00 00 00 20 20 20 .!........... 13C6:0060 20 20 20 20 20 20 20 20 00 00 00 00 00 20 20 20 ..... 13C6:0070 20 20 20 20 20 20 20 20-00 00 00 00 00 00 00 00 ........ -Q CODESG SEGMENT PARA 'CODE' BEGIN PROC FAR 1. ASSUME CS:CODESG,DS:DATASG,SS:STACKG 2. PUSH DS ;Zapisat' DS v stek 3. SUB AX,AX ;Ustanovit' nol' v AX PUSH AX ;Zapisat' nol' v stek Assembler dlya IBM PC. Programmy. 15 4. MOV AX,DATASG ;Zanesti adres MOV DS,AX ; DATASG v DS . . . 5. RET ;Vozvrat v DOS BEGIN ENDP CODESG ENDS END BEGIN page 60,132 TITLE EXASM1 (EXE) Primer registrovyh operacij ;------------------------------------------------ STACKSG SEGMENT PARA SACK 'Stack' DB 12 DUP('STACKSEG') STACKSG ENDS ;------------------------------------------------ CODESG SEGMENT PARA 'Code' BEGIN PROC FAR ASSUME SS:STACKSG,CS:CODESG,DS:NOTHING PUSH DS ;Zapisat' DS v stek SUB AX,AX ;Zapisat' nol' PUSH AX ; v stek MOV AX,0123H ;Zapisat' shest.0123 v AX ADD AX,0025H ;Pribavit' shest.25 k AX MOV BX,AX ;Pereslat' AX v BX ADD BX,AX ;Pribavit' BX k AX MOV CX,BX ;Pereslat' BX v CX SUB CX,AX ;Vychest' AX iz CX SUB AX,AX ;Ochistit' AX NOP RET ;Vozvrat v DOS BEGIN ENDP ;Konec procedury CODESG ENDS ;Konec segmenta END BEGIN ;Konec programmy Assembler dlya IBM PC. Programmy. 16 1 page 60,132 2 TITLE EXASM1 (EXE) Primer registrovyh operacij 3 ;------------------------------------------------ 4 0000 STACKSG SEGMENT PARA SACK 'Stack' 5 0000 0C [ DB 12 DUP('STACKSEG') 6 53 54 41 43 7 4B 53 45 47 8 ] 9 10 0060 STACKSG ENDS 11 ;------------------------------------------------- 12 0000 CODESG SEGMENT PARA 'Code' 13 0000 BEGIN PROC FAR 14 ASSUME SS:STACKSG,CS:CODESG,DS:NOTHING 15 0000 1E PUSH DS ;Zapisat' DS v stek 16 0001 2B C0 SUB AX,AX ;Zapisat' nol' 17 0003 50 PUSH AX ; v stek 18 19 0004 B8 0123 MOV AX,0123H ;Zapisat' shest.0123 v AX 20 0007 05 0025 ADD AX,0025H ;Pribavit' shest.25 k AX 21 000A 8B D8 MOV BX,AX ;Pereslat' AX v BX 22 000C 03 D8 ADD BX,AX ;Pribavit' BX k AX 23 000E 8B CB MOV CX,BX ;Pereslat' BX v CX 24 0010 2B C8 SUB CX,AX ;Vychest' AX iz CX 25 0012 2B C0 SUB AX,AX ;Ochistit' AX 26 0014 90 NOP 27 0015 CB RET ;Vozvrat v DOS 28 0016 BEGIN ENDP ;Konec procedury 29 30 0016 CODESG ENDS ;Konec segmenta 31 END BEGIN ;Konec programmy -------------------------------------------------------------------------- Segments and Groups: N a m e Size Align Combine Class CODESG . . . . . . . . . . . . 0016 PARA NONE 'CODE' STACKSG. . . . . . . . . . . . 0060 PARA STACK 'STACK' Symbols: N a m e Type Value Attr BEGIN. . . . . . . . . . . . . F PROC 0000 CODESG Length=0016 -------------------------------------------------------------------------- Assembler dlya IBM PC. Programmy. 17 1 page 60,132 2 TITLE EXASM2 (EXE) Operacii peresylki i slozheniya 3 ;--------------------------------------------------- 4 0000 STACKSG SEGMENT PARA SACK 'Stack' 5 0000 20 [ DB 32 DUP(?) 6 ???? 7 ] 8 9 0040 STACKSG ENDS 10 ;--------------------------------------------------- 11 0000 DATASG SEGMENT PARA 'Data' 12 0000 00FA FLDA DW 250 13 0002 007D FLDB DW 125 14 0004 ???? FLDC DW ? 15 0006 DATASG ENDS 16 ;--------------------------------------------------- 17 0000 CODESG SEGMENT PARA 'Code' 18 0000 BEGIN PROC FAR 19 ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:NOTHING 20 0000 1E PUSH DS ;Zapisat' DS v stek 21 0001 2B C0 SUB AX,AX ;Zapisat' v stek 22 0003 50 PUSH AX ; nulevoj adres 23 0004 B8 ---- R MOV AX,DATASG ;Pomestit' adres DATASG 24 0007 8E D8 MOV DS,AX ; v registr DS 25 26 0009 A1 0000 R MOV AX,FLDA ;Pereslat' 0250 v AX 27 000C 03 06 0002 R ADD AX,FLDB ;Pribavit' 0125 k AX 28 0010 A3 0004 R MOV FLDC,AX ;Zapisat' summu v FLDC 29 0013 CB RET ;Vernut'sya v DOS 30 0014 BEGIN ENDP 31 0014 CODESG ENDS END BEGIN ---------------------------------------------------------------------------- Segments and Groups: N a m e Size Align Combine Class CODESG . . . . . . . . . . . . 0014 PARA NONE 'CODE' DATASG . . . . . . . . . . . . 0006 PARA NONE 'DATA' STACKSG. . . . . . . . . . . . 0040 PARA STACK 'STACK' Symbols: N a m e Type Value Attr BEGIN. . . . . . . . . . . . . F PROC 0000 CODESG Length=0014 FLDA . . . . . . . . . . . . . L WORD 0000 DATASG FLDB . . . . . . . . . . . . . L WORD 0002 DATASG FLDC . . . . . . . . . . . . . L WORD 0004 DATASG ---------------------------------------------------------------------------- Assembler dlya IBM PC. Programmy. 18 EXASM2 (EXE) Operacii peresylki i slozheniya Symbol Cross Reference (# is definition) Cref-1 BEGIN. . . . . . . . . . . . 18# 30 32 CODE . . . . . . . . . . . . 17 CODESG . . . . . . . . . . . 17# 19 31 DATA . . . . . . . . . . . . 11 DATASG . . . . . . . . . . . 11# 15 19 23 FLDA . . . . . . . . . . . . 12# 26 FLDB . . . . . . . . . . . . 13# 27 FLDC . . . . . . . . . . . . 14# 28 STACK. . . . . . . . . . . . 4 STACKSG. . . . . . . . . . . 4# 9 19 10 Symbols Assembler dlya IBM PC. Programmy. 19 page 60,132 TITLE EXDEF (EXE) Opredelenie dannyh 0000 DATASG SEGMENT PARA 'Data' ; Opredelenie bajta - DB: ; ---------------------- 0000 ?? FLD1DB DB ? ;Neinicializirovan 0001 50 65 72 73 6F 6E FLD2DB DB 'Personal Computer' ;Sim. stroka 61 6C 20 43 6F 6D 70 75 74 65 72 0012 20 FLD3DB DB 32 ;Desyatichnaya konstanta 0013 20 FLD4DB DB 20H ;SHest. konstanta 0014 59 FLD5DB DB 01011001B ;Dvoichnaya konstanta 0015 01 4A 41 4E 02 46 FLD6DB DB 01,'JAN',02,'FEB',03,'MAR' ;Tablica 45 42 03 4D 41 52 0021 33 32 36 35 34 FLD7DB DB '32654' ;Simvol'nye chisla 0026 0A [ 00 ] FLD8DB DB 10 DUP(0) ;Desyat' nulej ; Opredelenie slova - DW: ; ---------------------- 0030 FFF0 FLD1DW DW 0FFF0H ;SHest. konstanta 0032 0059 FLD2DW DW 01011001B ;Dvoichnaya konstanta 0034 0021 R FLD3DW DW FLD7DB ;Adresnaya konstanta 0036 0003 0004 0007 FLD4DW DW 3,4,7,8,9 ;Pyat' konstant 0008 0009 0040 05 [ 0000 ] FLD5DW DW 5 DUP(0) ;Pyat' nulej ; Opredelenie dvojnogo slova - DD: ; ------------------------------- 004A ???????? FLD1DD DD ? ;Neinicializirovano 004E 43 50 00 00 FLD2DD DD 'PC' ;Simvol'naya stroka 0052 3C 7F 00 00 FLD3DD DD 32572 ;Desyatichnoe znachenie 0056 11 00 00 00 FLD4DD DD FLD3DB - FLD2DB ;Raznost' adresov 005A 0E 00 00 00 31 00 FLD5DD DD 14,49 ;Dve konstanty 00 00 ; Opredelenie uchetverennogo slova - DQ: ; ------------------------------------ 0062 ???????????????? FLD1DQ DQ ? ;Neinicializirovano 006A 47 4D 00 00 00 00 FLD2DQ DQ 04D47H ;SHest. konstanta 00 00 0072 3C 7F 00 00 00 00 FLD3DQ DQ 32572 ;Desyatich. konstanta 00 00 ; Opredelenie desyati bajt - DT: ; ---------------------------- 007A ?????????????????? FLD1DT DT ? ;Neinicializirovano ?? 0084 43 50 00 00 00 00 FLD2DT DT 'PC' ;Simvol'naya stroka 00 00 00 00 008E DATASG ENDS END ----------------------------------------------------------------------------- Assembler dlya IBM PC. Programmy. 20 Segments and Groups: N a m e Size Align Combine Class DATASG . . . . . . . . . . . . 008E PARA NONE 'DATA' Symbols: N a m e Type Value Attr FLD1DB . . . . . . . . . . . . L BYTE 0000 DATASG FLD1DD . . . . . . . . . . . . L DWORD 004A DATASG FLD1DQ . . . . . . . . . . . . L QWORD 0062 DATASG FLD1DT . . . . . . . . . . . . L TBYTE 007A DATASG FLD1DW . . . . . . . . . . . . L WORD 0030 DATASG FLD2DB . . . . . . . . . . . . L BYTE 0001 DATASG FLD2DD . . . . . . . . . . . . L DWORD 004E DATASG FLD2DQ . . . . . . . . . . . . L QWORD 006A DATASG FLD2DT . . . . . . . . . . . . L TBYTE 0084 DATASG FLD2DW . . . . . . . . . . . . L WORD 0032 DATASG FLD3DB . . . . . . . . . . . . L BYTE 0012 DATASG FLD3DD . . . . . . . . . . . . L DWORD 0052 DATASG FLD3DQ . . . . . . . . . . . . L QWORD 0072 DATASG FLD3DW . . . . . . . . . . . . L WORD 0034 DATASG FLD4DB . . . . . . . . . . . . L BYTE 0013 DATASG FLD4DD . . . . . . . . . . . . L DWORD 0056 DATASG FLD4DW . . . . . . . . . . . . L WORD 0036 DATASG FLD5DB . . . . . . . . . . . . L BYTE 0014 DATASG FLD5DD . . . . . . . . . . . . L DWORD 005A DATASG FLD5DW . . . . . . . . . . . . L WORD 0040 DATASG Length =0005 FLD6DB . . . . . . . . . . . . L BYTE 0015 DATASG FLD7DB . . . . . . . . . . . . L BYTE 0021 DATASG FLD8DB . . . . . . . . . . . . L BYTE 0026 DATASG Length =000A ------------------------------------------------------------------------------- Assembler dlya IBM PC. Programmy. 21 D:\ D>DEBUG D:EXDEF.EXE -D 1421:0000 00 50 65 72 73 6F 6E 61-6C 20 43 6F 6D 70 75 74 .Personal Comput 1421:0010 65 72 20 20 59 01 4A 41-4E 02 46 45 42 03 4D 41 er Y.JAN.FEB.MA 1421:0020 52 33 32 36 35 34 00 00-00 00 00 00 00 00 00 00 R32654.......... 1421:0030 F0 FF 59 00 21 00 03 00-04 00 07 00 08 00 09 00 ..Y.!........... 1421:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 43 50 ..............CP 1421:0050 00 00 3C 7F 00 00 11 00-00 00 0E 00 00 00 31 00 ..<...........1. 1421:0060 00 00 00 00 00 00 00 00-00 00 47 4D 00 00 00 00 ..........GM.... 1421:0070 00 00 3C 7F 00 00 00 00-00 00 00 00 00 00 00 00 ..<............. -D 1421:0080 00 00 00 00 43 50 00 00-00 00 00 00 00 00 33 33 ....CP........33 1421:0090 3E 36 33 33 73 00 00 00-0A 0E 00 00 3E 63 63 30 >633s.......>cc0 1421:00A0 1C 06 63 63 3E 00 00 00-0A 0E 00 00 FF DB 99 18 ..cc>........... 1421:00B0 18 18 18 18 3C 00 00 00-0A 0E 00 00 63 63 63 63 ....<.......cccc 1421:00C0 63 63 63 63 3E 00 00 00-0A 0E 00 00 C3 C3 C3 C3 cccc>........... 1421:00D0 C3 C3 66 3C 18 00 00 00-0A 0E 00 00 C3 C3 C3 C3 ..f<............ 1421:00E0 DB DB FF 66 66 00 00 00-0A 0E 00 00 C3 C3 66 3C ...ff.........f< 1421:00F0 18 3C 66 C3 C3 00 00 00-0A 0E 00 00 C3 C3 C3 66 .<f............f -Q Assembler dlya IBM PC. Programmy. 22 page 60,132 TITLE EXIMM (EXE) Primer neposredstvennyh operandov ; (Kodiruetsya dlya assemblirovaniya, ; no ne dlya vypolneniya) 0000 DATASG SEGMENT PARA 'Data' 0000 ?? FLD1 DB ? 0001 ???? FLD2 DW ? 0003 DATASG ENDS 0000 CODESG SEGMENT PARA 'Code' 0000 BEGIN PROC FAR ASSUME CS:CODESG,DS:DATASG ; Operacii peresylki i sravneniya: ; ------------------------------ 0000 BB 0113 MOV BX,275 ;Peresylka 0003 3C 19 CMP AL,H ;Sravnenie ; Arifmeticheskie operacii: ; ----------------------- 0005 14 05 ADC AL,5 ;Slozhenie s perenosom 0007 80 C7 0C ADD BH,12 ;Slozhenie 000A 1C 05 SBB AL,5 ;Vychitanie s zaemom 000C 80 2E 000 R 05 SUB FLD1,5 ;Vychitanie ; Rotaciya i sdvig (tol'ko na 1 bit): ; --------------------------------- 0011 D0 D3 RCL BL,1 ;Rotaciya vlevo s perenosom 0013 D0 DC RCR AH,1 ;Rotaciya vpravo s perenosom 0015 D1 06 0001 R ROL FID2,1 ;Rotaciya vlevo 0019 D0 C8 ROR AL,1 ;otaciya vpravo 001B D1 E1 SAL CX,1 ;Sdvig vlevo 001D D1 FB SAR BX,1 ;Arifm. sdvig vpravo 001F D0 2E 0000 R SHR FLD1,1 ;Sdvig vpravo ; Logicheskie operacii: ; ------------------- 0023 24 2C AND AL,00101100B ;AND (registr) 0025 80 CF 2A OR BH,2AH ;OR (registr) 0028 F6 C3 7A TEST BL,7AH ;TEST (registr) 002B 80 36 0000 R 23 OR FLD1,23H ;XOR (pamyat') 0030 BEGIN ENDP 0030 CODESG ENDS END Assembler dlya IBM PC. Programmy. 23 page 60,132 TITLE XCOM1 COM-programma dlya peresylki i slozheniya CODESG SEGMENT PARA 'Code' ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:CODESG ORG 100H ;Nachalo v konce PSP BEGIN: JMP MAIN ;Obhod cherez dannye ; --------------------------------------------------- FLDA DW 250 ;Opredelenie dannyh FLDB DW 125 FLDC DW ? ; --------------------------------------------------- MAIN PROC NEAR MOV AX,FLDA ;Pereslat' 0250 v AX ADD AX,FLDB ;Pribavit' 0125 k AX MOV FLDC,AX ;Zapisat' summu v FLDC RET ;ernut'sya v DOS MAIN ENDP CODESG ENDS END BEGIN page 60,132 TITLE EXJUMP (COM) Organizaciya cikla s pomoshch'yu JMP 0000 CODESG SEGMENT PARA 'Code' ASSUME CS:CODESG,DS:CODESG,SS:CODESG 0100 ORG 100H 0100 MAIN PROC NEAR 0100 B8 0001 MOV AX,01 ;Inicializaciya AX, 0103 BB 0001 MOV BX,01 ; BX, 0106 B9 0001 MOV CX,01 ; i CX 0109 A20: 0109 05 0001 ADD AX,01 ;Pribavit' 01 k AX 010C 03 D8 ADD BX,AX ;Pribavit' 01 k BX 010E D1 E1 SHL CX,1 ;Udvoit' CX 0110 EB F7 JMP A20 ;Perehod na A20 0112 MAIN ENDP 0112 CODESG ENDS END MAIN Assembler dlya IBM PC. Programmy. 24 page 60,132 TITLE EXLOOP (COM) Organizaciya cikla komandoj LOOP 0000 CODESG SEGMENT PARA 'Code' ASSUME CS:CODESG,DS:CODESG,SS:CODESG 0100 ORG 100H 0100 BEGIN PROC NEAR 0100 B8 0001 MOV AX,01 ;Inicializaciya AX, 0103 BB 0001 MOV BX,01 ; BX, 0106 BA 0001 MOV DX,01 ; i DX 0109 B9 000A MOV CX,10 ;CHislo ciklov 010C A20: 010C 40 INC AX ;Pribavit' 01 k AX 010D 03 D8 ADD BX,AX ;Pribavit' AX k BX 010F D1 E2 SHL DX,1 ;Udvoit' DX 0111 E2 F9 LOOP A20 ;Umen'shit' CX i povtorit' ; cikl, esli nenul' 0113 C3 RET ;Zavershit' rabotu 0114 BEGIN ENDP 0114 CODESG ENDS END BEGIN +-------------------------+ | CODESG SEGMENT PARA | +-------------------------+ | BEGIN PROC FAR | | . | | . | | CALL B10 | | CALL C10 | | RET | | BEGIN ENDP | +-------------------------+ | B10 PROC NEAR | | . | | . | | RET | | B10 ENDP | +-------------------------+ | C10 PROC NEAR | | . | | . | | RET | | C10 ENDP | +-------------------------+ | CODESG ENDS | | END BEGIN | +-------------------------+ Assembler dlya IBM PC. Programmy. 25 TITLE CALLPROC (EXE) Vyzov procedur 0000 STACKSG SEGMENT PARA STACK 'Stack' 0000 20 [ ???? ] DW 32 DUP(?) 0040 STACKG ENDS 0000 CODESG SEGMENT PARA 'Code' 0000 BEGIN PROC FAR ASSUME CS:CODESG,SS:STACKSG 0000 1E PUSH DS 0001 2B C0 SUB AX,AX 0003 50 PUSH AX 0004 E8 0008 R CALL B10 ;Vyzvat' B10 ; ... 0007 CB RET ;Zavershit' programmu 0008 BEGIN ENDP ;-------------------------------------- 0008 B10 PROC 0008 E8 000C R CALL C10 ;Vyzvat' C10 ; ... 000B C3 RET ;Vernut'sya v 000C B10 ENDP ; vyzyvayushchuyu programmu ;---------------------------------------------- 000C C10 PROC ; ... 000C C3 RET ;Vernut'sya v 000D C10 ENDP ; vyzyvayushchuyu programmu ;---------------------------------------------- 000D CODESG ENDS END BEGIN Assembler dlya IBM PC. Programmy. 26 page 65,132 TITLE EXMOVE (EXE) Operacii rasshirennoj peresylki ;------------------------------------------------------ STACKSG SEGMENT PARA STACK 'Stack' DW 32 DUP(?) STACKSG ENDS ;------------------------------------------------------ DATASG SEGMENT PARA 'Data' NAME1 DB 'ABCDEFGHI' NAME2 DB 'JKLMNOPQR' NAME3 DB 'STUVWXYZ*' DATASG ENDS ;------------------------------------------------------- CODESG SEGMENT PARA 'Code' BEGIN PROC FAR ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG PUSH DS SUB AX,AX PUSH AX MOV AX,DATASG MOV DS,AX MOV ES,AX CALL B10MOVE ;Vyzvat' JUMP podprogrammu CALL C10MOVE ;Vyzvat' CALL podprogrammu RET ;Zavershit' programmu BEGIN ENDP ; Rasshirennaya peresylka (JUMP-podprogramma), ; ispol'zuyushchaya perehod po usloviyu: ; ----------------------------------------- B10MOVE PROC LEA SI,NAME1 ;Inicializaciya adresov LEA DI,NAME2 ; NAME1 i NAME2 MOV CX,09 ;Pereslat' 9 simvolov B20: MOV AL,[SI] ;Pereslat' iz NAME1 MOV [DI],AL ;Pereslat' v NAME2 INC SI ;Sleduyushchij simvol v NAME1 INC DI ;Sleduyushchaya poziciya v NAME2 DEC CX ;Umen'shit' schetchik cikla JNZ B20 ;Schetchik > 0? Da - cikl RET ;Esli schetchik = 0, to B10MOVE ENDP ; vernut'sya ; Rasshirennaya peresylka (LOOP-podprogramma), ; ispol'zuyushchaya komandu LOOP: ; -----------------------------------------; C10MOVE PROC LEA SI,NAME2 ;Inicializaciya adresov LEA DI,NAME3 ; NAME2 i NAME3 MOV CX,09 ;Pereslat' 9 simvolov C20 Assembler dlya IBM PC. Programmy. 27 MOV AL,[SI] ;Pereslat' iz NAME2 MOV [DI],AL ;Pereslat' v NAME3 INC DI ;Sleduyushchij simvol v NAME2 INC SI ;Sleduyushchaya poziciya v NAME3 LOOP C20 ;Umen'shit' schetchik, ; esli ne nol', to cikl RET ;Esli schetchik = 0, to C10MOVE ENDP ; vernut'sya CODESG ENDS END BEGIN TITLE CASE (COM) Perekodirovka v zaglavnye bukvy 0000 CODESG SEGMENT PARA 'CODE' ASSUME CS:CODESG,DS:CODESG,SS:CODESG 0001 ORG 100H 0001 EB 1C 90 BEGIN: JMP MAIN ; ------------------------------------------- 0003 43 68 61 6E 67 65 TITLEX DB 'Change to uppercase letters' 20 74 6F 20 75 70 70 65 72 63 61 73 65 20 6C 65 74 74 65 72 73 ; ------------------------------------------- 011E MAIN PROC NEAR 011E 8D 1E 0104 R LEA BX,TITLEX+1 ;Adres pervogo simvola 0122 B9 001F MOV CX,31 ;CHislo simvolov 0125 B20: 0125 8A 27 MOV AH,[BX] ;Simvol iz TITLEX 0127 80 FC 61 CMP AH,61H ;|to 012A 72 0A JB B30 ; propisnaya 012C 80 FC 7A CMP AH,7AH ; bukva 012F 77 05 JA B30 ; ? 0131 80 E4 DF AND AH,11011111B ;Da - preobrazovat' 0134 88 27 MOV [BX],AH ;Zapisat' v TITLEX 0136 B30: 0136 43 INC BX ;Sleduyushchij simvol 0137 E2 EC LOOP B20 ;Povtorit' cikl 31 raz 0139 C3 RET 013A MAIN ENDP 013A CODESG ENDS END BEGIN Assembler dlya IBM PC. Programmy. 28 page 60,132 TITLE ALLASC (COM) Vyvod na ekran ASCII-simvolov 00-FF CODESC SEGMENT PARA 'Code' ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:NOTHING ORG 100H BEGIN: JMP SHORT MAIN CTR DB 00,'S' ; Osnovnaya procedura: ; ------------------ MAIN PROC NEAR CALL B10CDR ;Ochistit' ekran CALL C10SET ;Ustanovit' kursor CALL D10DISP ;Vyvesti simvol na ekran RET MAIN ENDP ; Ochistka ekrana: ; -------------- B10CLR PROC MOV AX,0600H MOV BH,07 MOV CX,0000 ;Levaya verhnyaya poziciya MOV DX,184FH ;Pravaya nizhnyaya poziciya INT 10H RET B10CLR ENDP ; Ustanovka kursora v 00,00: ; ------------------------- C10SET PROC MOV AN,02 MOV BN,00 MOV DX,0000 INT 10H RET C10SET ENDP ; Vyvod na ekran ASCII simvolov: ; ----------------------------- D10DISP PROC MOV CX,256 ;256 iteracij LEA DX,CTR ;Adres schetchika D20 MOV AH,09 ;Funkciya vyvoda simvola INT 21H INC CTR ;Uvelichit' schetchik LOOP D20 ;Umen'shit' CX, ; cikl, esli ne nol' RET ;Vernut'sya D10DISP ENDP CODESG ENDS END BEGIN Assembler dlya IBM PC. Programmy. 29 page 60,132 TITLE CTRNAME (EXE) Vvod imen i vyvod v centr ekrana ;-------------------------------------------------------- STSCKSG SEGMENT PARA STACK 'Stack' DW 32 DUP(?) STACKSG ENDS ;-------------------------------------------------------- DATASG SEGMENT PARA 'Data' NAMEPAR LABEL BYTE ;Imya spiska parametrov: MAXNLEN DB 20 ; maks.dlina imeni NAMELEN DB ? ; chislo vvedennyh simvolov NAMEFLD DB 20 DUP(' '),'$' ; imya i ogranichitel' ; dlya vyvoda na ekran PRIMPT DB 'Name? ', '$' DATASG ENDS ;-------------------------------------------------------- CODESG SEGMENT PARA 'Code" BEGIN PROC FAR ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASC PUSH DS SUB AX,AX PUCH AX MOV AX,DATASC MOV DS,AX MOV ES,AX CALL Q10CLR ;Ochistit' ekran A20LOOP: MOV DX,0000 ;Ustanovit' kursor v 00,00 CALL Q20CURS CALL B10PRMP ;Vydat' tekst zaprosa CALL D10INPT ;Vvesti imya CALL Q10CLR ;Ochistit' ekran CMP NAMELEN,00 ;Imya vvedeno? JE A30 ; net - vyjti CALL E10CODE ;Ustanovit' zvukovoj signal ; i ogranichitel' '$' CALL F10CENT ;Centrirovanie i vyvod JMP A20LOOP A30: RET ;Vernut'sya v DOS BEGIN ENDP ; Vyvod teksta zaprosa: ; -------------------- B10PRMP PROC NEAR MUV AN,09 ;Funkciya vyvoda na ekran LEA DX,PROMPT INT 21H RET B10PRMP ENDP ; Vvod imeni s klaviatury: ; ----------------------- D10INPT PROC NEAR Assembler dlya IBM PC. Programmy. 30 MOV AN,0AN ;Funkciya vvoda LEA DX,NAMEPAR INT 21H RET D10INPT ENDP ; Ustanovka signala i ogranichitelya '$': ; ------------------------------------ E10CODE PROC NEAR MOV BN,00 ;Zamena simvola Return (0D) MOV BL,NAMELEN ; na zv.signal (07) MOV NAMEFLD[BX],07 MOV NAMEFLD[BX+1],'$' ;Ustanovit' ogranichitel' RET E10CODE ENDP ; Centrirovanie i vyvod imeni na ekran: ; ------------------------------------ F10CENT PROC NEAR MOV DL,NAMELEN ;Opredelenie stolbca: SHR DL,1 ; razdelit' dlinu na 2, NEG DL ; pomenyat' znak, ADD DL,40 ; pribavit' 40 MOV DH,12 ;Central'naya stroka CALL Q20CURS ;Ustanovit' kursor MOV AN,09 LEA DX,NAMEFLD ;Vyvesti imya na ekran INT 21H RET F10CENT ENDP ; Ochistit' ekran: ; -------------- Q10CLR PROC NEAR MOV AX,0600H ;Funkciya prokrutki ekrana MOV BH,30 ;Cvet (07 dlya ch/b) MOV CX,0000 ;Ot 00,00 MOV DX,184FH ;Do 24,79 INT 10H ;Vyzov BIOS RET Q10CLR ; Ustanovka kursora (stroka/stolbec): ; ---------------------------------- Q20CURS PROC NEAR ;DX uzhe ustanovlen MOV AH,02 ;Funkciya ustanovki kursora MOV BH,00 ;Stranica #0 INT 10H ;Vyzov BIOS RET Q20CURS ENDP CODESG ENDS END BEGIN Assembler dlya IBM PC. Programmy. 31 page 60,132 TITLE NMSCROLL (EXE) Invertirovanie, miganie, prokrutka ; ------------------------------------------------------- STACKSG SEGMENT PARA STACK 'Stack' DW 32 DUP(?) STACKSG SEGMENT PARA STACK 'Stack' DW 32 DUP(?) STACKG ENDS ; ------------------------------------------------------- DATASG SEGMENT PARA 'Data' NAMEPAR LABEL BYTE ;Imya spiska parametrov: MAXNLEN DB 20 ; maks.dlina imeni ACTNLEN DB ? ; chislo vvedennyh simvolov NAMEFLD DB 20 DUP(' ') ; imya COL DB 00 COUNT DB ? PROMPT DB 'Name? ' ROW DB 00 DATASG ENDS ; ------------------------------------------------------- CODESG SEGMENT PARA 'Code' BEGIN PROC FAR ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG PUSH DS SUB AX,AX PUSH DS MOV AX,DATASG MOV ES,AX MOV AX,0600H CALL Q10CLR ;Ochistit' ekran A20LOOP: MOV COL,00 ;Ustanovit' stolbec 0 CALL Q20CURS CALL B10PRMP ;Vydat' tekst zaprosa CALL D10INPT ;Vvesti imya s klaviatury CMP ACTNLEN,00 ;Net imeni? (t.e. konec) JNE A30 MOV AX,0600H CALL Q10CLR ;Esli da, to ochistit' ekran, RET ; i zavershit' programmu A30: CALL E10NAME ;Vyvesti imya na ekran JMP A20LOOP BEGIN ENDP ; Vyvod teksta zaprosa: ; -------------------- B10PRMP PROC NEAR LEA SI,PROMPT ;Adres teksta MOV COUNT,05 B20: MOV BL,70H ;Videoinversiya Assembler dlya IBM PC. Programmy. 32 CALL F10DISP ;Podprogramma vyvoda INC SI ;Sleduyushchij simvol v imeni INC COL ;Sleduyushchij stolbec CALL Q20CURS DEC COUNT ;Umen'shenie schetchika JNZ B20 ;Povtorit' n raz RET B10PRMP ENDP ; vod imeni s klaviatury: ; ---------------------- D10INPT PROC NEAR MOV AN,0AH LEA DX,NAMEPAR INT 21H RET D10INPT ENDP ; Vyvod imeni s miganiem i inversiej: ; ---------------------------------- E10NAME PROC NEAR LEA SI,NAMEFLD ;Adres imeni MOV COL,40 ;Ustanovit' stolbec E20: CALL Q20CURS ;Ustanovit' kursor MOV BL,0FOH ;Miganie i inversiya CALL F10DISP ;Podprogramma vyvoda INS SI ;Sleduyushchij simvol v imeni INS COL ;Sleduyushchij stolbec na ekrane DES ACTNLEN ;Umen'shit' schetchik dliny JNZ E20 ;Ciklit' n raz CMP ROW,20 ;Poslednyaya stroka ekrana? JAE E30 ; net INC ROW RET E30: MOV AX,0601H ; da -- CALL Q10CLR ; ochistit' ekran RET E10NAME ENDP ; Vyvod simvola na ekran: ; ---------------------- F10DISP PROC NEAR ;BL (atribut) uzhe ustanovlen MOV AN,09 ;Funkciya vyvoda na ekran MOV AL,[SI] ;Poluchit' simvol iz imeni MOV BH,00 ;Nomer stranicy MOV CX,01 ;Odin simvol INT 10H ;Vyzov BIOS RET F10DISP ENDP ; Ochistka ekrana: ; -------------- Q10CLR PROC NEAR ;AX ustanovlen pri vyzove MOV BH,07 ;Normal'nyj ch/b MOV CX 0000 MOV DX,184FH Assembler dlya IBM PC. Programmy. 33 INT 10H ;Vyzov BIOS RET Q10CLR ENDP ; Ustanovit' kursor (stroka/stolbec): ; ---------------------------------- Q20CURS PROC NEAR MOV AN,02 MOV BH,00 MOV DH,ROW MOV DL,COL INT 10H RET Q20CURS ENDP CODESG ENDS END BEGIN Rasshirennaya funkciya Sken-kod Alt/A do Alt/Z 1E - 2C F1 do F10 3B - 44 Home 47 Strelka vverh 48 PgUp 49 Strelka vlevo 4B Strelka vpravo 4D End 4F Strelka vniz 50 PgDn 51 Ins 52 Del 53 Assembler dlya IBM PC. Programmy. 34 TITLE GRAPHIX (COM) Primer cveta i grafiki CODESG SEGMENT PARA 'Code' ASSUME CS:CODESG,DS:CODESG,SS:CODESG ORG 100H MAIN PROC NEAR MOV AN,00 ;Ustanovka rezhima grafiki MOV AL,0DH ; dlya EGA (CGA=04) MOV AH,0BH ;Ustanovit' palitru MOV BH,00 ;Fon MOV BL,02 ;Zelenyj INT 10H MOV BX,00 ;Nachal'nye cvet, MOV CX,00 ; stolbec MOV DX,00 ; i stroka A50: MOV AH,0CH ;Funkciya vyvoda tochki MOV AL,BL ;Ustanovit' cvet INT 10H ;BX, CX, i DX sohranyayutsya INC CX ;Uvelichit' stolbec CMP CX,320 ;Stolbec 320? JNE A50 ; net - cikl, MOV CX,00 ; da - sbrosit' stolbec INS BL ;Izmenit' cvet INS DX ;Uvelichit' stroku CMP DX,40 ;Stroka 40? JNE A50 ; net - cikl, RET ; da - zavershit' MAIN ENDP CODESG ENDS END MAIN