- MEND. , , . . : - ; - ; - . -, ASCII , , , . , , . . ------------------------------------------------------------ . INIT1, EXE-: INIT1 MACRO ; ASSUME CS:CSEG,DS:DSEG,SS:STACK;ES:DSEG ; \ PUSH DS ; \ IBM PC. 20 19 SUB AX,AX ; \ PUSH AX ; \ MOV AX,DSEG ;/ MOV DS,AX ; / MOV ES,AX ; / ENDM ; MACRO , ENDM . - INIT1, . ENDM . MACRO ENDM . , , CSEG, DSEG STACK - . INIT1 , . INIT1, , , . INIT1 , - . , , . .20.1 . , (+), . , ASSUME, . " . ------------------------------------------------------------ ------------------------------------------------------------ .20.1. . ------------------------------------------------------------ : CSEG, DSEG STACK. , , , : INIT2 MACRO CSNAME,DSNAME,SSNAME ; ASSUME CS:CSNAME,DS:DSNAME,SC:SSNAME,ES:DSNAME PUSH DS SUB AX,AX PUSH AX IBM PC. 20 20 MOV AX,DSNAME MOV DS,AX MOV ES,AX ENDM ; . CSNAME, DSNAME SSNAME ASSUME, DSNAME MOV. , . INIT2 . , , : : INIT2 MACRO CSNAME,DSNAME,SSNAME ( ) : | | | INIT2 CSEG,DSEG,STACK () , : - 1: CSEG CSNAME . CSEG CSNAME ASSUME. - 2: DSEG DSNAME . DSEG DSNAME: ASSUME MOV. - 3: STACK SSNAME . STACK SSNAME ASSUME. .20.2. ------------------------------------------------------------ ------------------------------------------------------------ .20.2. . ( , , CX), . , , IBM PC. 20 21 , . , , 120 . ------------------------------------------------------------ . COMMENT , PROMPT: PROMPT MACRO MESSGE ; MOV AH,09H LEA DX,MESSGE INT 21H ENDM , , . , , .LALL ("list all" - ), : .LALL PROMPT MESSAG1 , , - . .LALL. - (;;) - . .XALL, , . , , , . .SALL ("suppress all" - ), , . .LALL, .XALL, .SALL , . , , - , . .20.3 . INIT2 PROMPT, . .SALL IBM PC. 20 22 INIT2 PROMPT. PROMPT .LALL . , , , (;;) PROMPT, . ------------------------------------------------------------ ------------------------------------------------------------ .20.3. . ------------------------------------------------------------ . DOS21, AH DOS INT 21H: DOS21 MACRO DOSFUNC MOV AH,DOSFUNC INT 21H ENDM : LEA DX,NAMEPAR DOS21 0AH , , 02 AH : DISP MACRO CHAR MOV AH,02 MOV DL,CHAR INT 21H ENDM , , DISP '*'. DISP, DOC21: DISP MACRO CHAR MOV DL,CHAR DOS21 02 ENDM , DISP DISP '*', : MOV DL,'*' IBM PC. 20 23 MOV AH,02 INT 21H LOCAL ------------------------------------------------------------ . . - . LOCAL, MACRO, . : LOCAL dummy-1,dummy-2,... ; .20.4. LOCAL. ; 1 , . : COMP - , OUT - . COMP OUT LOCAL . COMP ??0000, OUT - ??0001. DIVIDE , ??0002 ??0003 . , LOCAL . ------------------------------------------------------------ ------------------------------------------------------------ .20.4. LOCAL. ------------------------------------------------------------ , INIT1 INIT2 . , , , MACRO.LIB: INIT MACRO CSNAME,DSNAME,SSNAME . . ENDM PROMPT MACRO MESSGE . . IBM PC. 20 24 ENDM MACRO INCLUDE: INCLUDE C:MACRO.LIB . . INIT CSEG,DATA,STACK MACRO.LIB ( ) C INIT PROMPT. INIT. , C 30 LST-. (+) 31 . , INCLUDE ( ) : IF1 INCLUDE C:MACRO.LIB ENDIF IF1 ENDIF . IF1 . ENDIF IF-. , - . .20.5 IF1, INCLUDE ENDIF, LST- ENDIF. INIT PROMPT MACRO.LIB, .. MACRO.LIB . INCLUDE , . ------------------------------------------------------------ ------------------------------------------------------------ .20.5. . INCLUDE . , INIT, PROMPT DIVIDE, IBM PC. 20 25 INIT. PURGE "" PROMPT DIVIDE : IF1 INCLUDE MACRO.LIB ; ENDIF PURGE PROMRT,DIYIDE ; ... INIT CSEG,DATA,STACK ; ; PURGE , . (&) ------------------------------------------------------------ (&) () . MOVE MOVSB MOVSW: MOVE MACRO TAG REP MOVS&TAG ENDM MOVE B MOVE W. MOVS REP MOVSB REP MOVSW. . : REPT, IRP, IRPC ------------------------------------------------------------ , ENDM. , , ENDM , ENDM - . REPT: REPT ENDM , : REPT N=0 DB N : N = 0 IBM PC. 20 26 REPT 5 N = N + 1 DB N ENDM DB DB 1 DB 5. REPT . MOVSB, REP MOVSB CX 05: REPT 5 MOVSB ENDM IRP: IRP ENDM. : IRP dummy,<arguments> , , , , . . DB 3, DB 9, DB 17, DB 25 DB 28: IRP N,<3, 9, 17, 25, 28> DB N ENDM IRPC: IRPC ENDM. : IRPC dummy,string "string". DW 3, DW 4 ... DW 8: IRPC N,345678 DW N ENDM ------------------------------------------------------------ . IF1 . IBM PC. 20 27 , . IF ENDIF IF- ELSE : IFxx () . } . } ELSE ( ) } . } . } ENDIF ( IF-) ENDIF : "Undeterminated conditional" ( ). , ELSE ELSE - ENDIF. , ELSE, ELSE . : IF , . IFE , . IF1 ( ) , . IF2 ( ) , . IFDEF EXTRN, . IFNDEF EXTRN, . IFB <> , . . IFNB <> , . . IBM PC. 20 28 IFIDN <-1>,<-2> , . . IFDIF<-1>,<-2> , . . IFNB ( ). DOS INT 21H AH, DX. : DOS21 MACRO DOSFUNC,DXADDRES MOV AN,DOSFUNC IFNB <DXADDRES> MOV DX,OFFSET DXADDRES ENDIF INT 21H ENDM DOS21 01 AH: DOS21 01 MOV AH,01 INT 21H. AH 0AH, DX - : DOS21 0AH,IPFIELD MOV INT 21H. EXITM. ------------------------------------------------------------ , . , . EXITM: IFxx [] . . ( ) . EXITM . . IBM PC. 20 29 ENDIF EXITM, ENDM. EXITM REPT, IRP IRPC . , IF IFNDEF ------------------------------------------------------------ .20.6 DIVIDE, . : , , . IFNDEF . CNTR. . , CNTR: IF CNTR ; EXITM CNTR , EXITM . , CNTR , , IFNDEF CNTR , 1. , . DIVIDE , . - ; , . ------------------------------------------------------------ ------------------------------------------------------------ .20.6. IF IFNDEF. , IFIDN- ------------------------------------------------------------ IBM PC. 20 30 .20.7 MOVIF, MOVSB MOVSW . B ( ) W ( ) MOVSB MOVSW MOVS. : MOVIF MACRO TAG IFIDN <&TAG>,<B> IFIDN ( B W) B. , REP MOVSB. (&) - , <TAG> . B W, MOVSB ( ). MOVIF: B, W . , , CX DX . , - . , , . ------------------------------------------------------------ ------------------------------------------------------------ .20.7. IFIDN ------------------------------------------------------------ (MASM). . MACRO, , ENDM . , , . .SALL,.LALL .XALL . LOCAL . LOCAL MACRO. IBM PC. 20 31 , . . . ------------------------------------------------------------ 20.1. : ) , ) , . 20.2. : ) MULTBY ; ) MULTWD . . , . 20.3. 20.2 " ". INCLUDE . 20.4. BIPRINT, BIOS INT 17H . . 20.5. .20.6 ( ). IBM PC. 21 1  21.  ------------------------------------------------------------ : , . ------------------------------------------------------------ . , , , . , . : , , , ; , , ; , ; , . (OBJ) . (LINK) (EXE) . , . , , . .21.1 . . 21.1 () 1, 2 3. . 21.1 () 1 2, 1 3. ------------------------------------------------------------ ------------------------------------------------------------ .21.1. . , "" , , . , , , 1 IBM PC. 21 2 2, 3 , 1. , , , . ------------------------------------------------------------ CALL , .. . CALL ( +127 -128 ) ( ). "" IP , "" . , CALL : E82000. .E8 , 2000 0020 IP. CS IP . RET IP CALL . () . CS , IP . . , CALL : 9A 0002 AF04 .9A 0002 0200 IP, AF04 04AF CS. : 04AF0 IP 0200 04CF0 REP CS IP CALL . EXTRN PUBLIC IBM PC. 21 3 ------------------------------------------------------------ (MAINPROG), (SUBPROG) CALL, .21.2. CALL MAINPROG "", SUBPROG ( , SUBPROG ). EXTRN , SUBPROG FAR, .. . , "" : 9A 0000 ---- E SUBPROG PUBLIC, , "" SUBPROG. , MAINPROG SUBPROG , : LINK: : Object Modules [.OBJ]: B:MAINPROG+B:SUBPROG Run File [filespec.EXE]: B:COMBPROG ( ) List File [NUL.MAP]: CON Libraries [.LIB]: [return] ------------------------------------------------------------ ------------------------------------------------------------ .21.2. . EXTRN PUBLIC . . . . EXTRN EXTRN : EXTRN : [, ... ] ( ) EXTRN. PUBLIC. IBM PC. 21 4 ABS, BYTE, DWORD, FAR, NEAR, WORD. EQU . PUBLIC PUBLIC , : PUBLIC [, ... ] ( ) PUBLIC. ( PROC-), . EQU-, . . : EXTRN PUBLIC ------------------------------------------------------------ .21.3 CALLMUL1 SUBMUL1. , . QTY PRICE. AX PRICE, BX - QTY, . EXTRN SUBMUL . PUBLIC ( ASSUME), , SUBMUL. AX () BX (). DX:AX . 002E 4000. - , . , . , , . , . . , . , SUBMUL FAR External (), - F IBM PC. 21 5 ( FAR) Global (). , , .. . ( ) . , ( ) . (