home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
- November 15, 1985
-
- INLINE ASSEMBLER
-
-
- OVERVIEW
-
- INLINE.COM is an assembler designed to produce Inline 8086/8088
- code for Turbo Pascal (tm) version 3 programs. Like other
- assemblers, INLINE accepts as input an assembly language source
- file and produces an object file. However, in this case, the
- 'object' file is an ASCII file consisting of Inline statements
- which may be inserted into the Turbo Pascal program.
-
- Figure 1 illustrates a Pascal function with Inline code generated
- by INLINE using the source file of Figure 2.
-
-
- LOADING AND RUNNING INLINE
-
- INLINE is called at the DOS prompt with two filename parameters
- specifying the names of the source and object files. If no
- extensions are given, .ASM and .OBJ are used by default. For
- instance,
-
- INLINE ABC DEF
-
- will cause INLINE to look for a source file, ABC.ASM, and create
- an object file, DEF.OBJ. Files with no extension may be input or
- created by using a simple '.' for the extension.
-
- If one or more filenames are missing from the command line, they
- will be requested once execution starts.
-
- Once execution begins, INLINE will run to completion with the
- only console output being error messages.
-
-
- SYNTAX
-
- The appendix lists the mnemonics accepted by INLINE. Syntax and
- mnemonics correspond to that used by most assemblers but note
- should be made of the following:
-
- 1. Turbo Pascal symbols may be used within instruction entries
- by preceding the symbol with a '>' (16 bit symbol) or a '<'
- (8 bit symbol). The characters '+' and '-' are considered
- part of the symbol. This allows computations using symbols
- to be passed on to the compiler where the computation can be
- made. For instance in
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
-
- MOV AX,[>SYMBOL+4] ;'>SYMBOL+4' is passed on
- MOV AX,[BP+>SYMBOL+4] ;again '>SYMBOL+4' is passed on
- MOV AX,>SYMBOL+4[BP] ;also acceptable
-
- Note that
-
- MOV AX,[>SYMBOL+4+BP]
-
- is not correct since the wrong instruction will be generated
- and '>SYMBOL+4+BP' will be passed on.
-
- 2. Labels (for use with jump instructions) may be defined
- simply by appending a ':' to the first item on a line.
-
- 3. Numerical entries are assumed to be decimal unless preceded
- by a '$' indicating a hexadecimal entry. Characters within
- single quotes may be used for numerical entries as:
-
- CMP AL,'a'
-
- 4. Square brackets are used to indicate 'contents of'. If no
- square brackets are used, an immediate operand is assumed.
-
- MOV AX,[>DATA] ;Load AX with the contents of DATA.
- MOV AX,>DATA ;Load AX with DATA.
-
- 5. Instruction prefixes and segment override prefixes may
- precede the instruction on the same line or may be included
- on a previous line.
-
- 6. Comments may be include in the source. They are delimited
- by a ';'.
-
- 7. Instructions which don't clearly specify the data size
- require that BYTE PTR or WORD PTR be used. These may be
- abbreviated to BY or WO.
-
- INC BYTE PTR [>BDATA]
- DEC WO >WARRAY[DI]
-
- 8. JMP instructions may use SHORT, NEAR, or FAR (they should
- not be abbreviated). In the absence of one of these words, a
- SHORT jump will be encoded if the label is already defined
- and is within range. If the label is not defined, a NEAR
- JMP will be encoded unless SHORT is used.
-
- A FAR CALL or JMP may be made to a direct address by stating
- both the segment and offset separated by a colon.
-
- CALL FAR $1234:$5678
-
-
-
-
- 2
-
-
-
-
-
-
-
-
-
-
-
- RESTRICTIONS
-
- The object file is limited to 32k. This includes comments and
- spaces.
-
- Symbols (including any addons from + and -) are limited to 32
- characters.
-
- Labels may be used in jump statements only and not as data
- references. While there is a DB pseudo-opcode, it is not very
- useful with this restriction.
-
- The number of statement labels that may be defined is limited
- only by the heap space available.
-
-
- Please report all bugs, suggestions, and problems to Dave
- Baldwin, CompuServe ID #76327,53.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 3
-
-
-
-
-
-
-
-
-
-
-
-
- FUNCTION SCAN(LIMIT :INTEGER; CH :CHAR; VAR T ): INTEGER;
- {SCAN LIMIT CHARACTERS FOR CH. RETURN THE NUMBER OF CHARACTERS
- SKIPPED TO FIND A MATCH. IF NOT FOUND, RETURN RESULT=LIMIT.
- LIMIT MAY BE NEGATIVE FOR A BACKWARDS SCAN.}
- BEGIN {SCAN MUST BE FAST--USE ASSEMBLY LANGUAGE}
- Inline(
- $FC { CLD ;ASSUME FORWARD}
- /$8A/$46/<CH { MOV AL,<CH[BP] ;CHAR TO SEARCH FOR}
- /$8B/$4E/<LIMIT { MOV CX,<LIMIT[BP];BYTES TO SEARCH}
- /$09/$C9 { OR CX,CX ;CHECK SIGN}
- /$9C { PUSHF ;SAVE FLAGS}
- /$79/$03 { JNS X1}
- /$F7/$D9 { NEG CX ;MAKE POSITIVE}
- /$FD { STD ;BUT SEARCH IN REVERSE}
- /$89/$CA {X1: MOV DX,CX ;SAVE FULL COUNT}
- /$C4/$7E/<T { LES DI,<T[BP] ;PTR TO START}
- /$F2/$AE { REPNE: SCASB ;SEARCH}
- /$75/$01 { JNE X2}
- /$41 { INC CX ;FOUND A MATCH}
- /$29/$CA {X2: SUB DX,CX ;FIND COUNT TO MATCH}
- /$9D { POPF}
- /$79/$02 { JNS X3}
- /$F7/$DA { NEG DX ;MAKE NEGATIVE IF REVERSE}
- /$89/$56/$0C {X3: MOV [BP+$C],DX ;PUT IN FUNCTION RESULT}
- );
- END;
-
- Figure 1: Pascal Function using Inline Code
-
-
- CLD ;ASSUME FORWARD
- MOV AL,<CH[BP] ;CHAR TO SEARCH FOR
- MOV CX,<LIMIT[BP];BYTES TO SEARCH
- OR CX,CX ;CHECK SIGN
- PUSHF ;SAVE FLAGS
- JNS X1
- NEG CX ;MAKE POSITIVE
- STD ;BUT SEARCH IN REVERSE
- X1: MOV DX,CX ;SAVE FULL COUNT
- LES DI,<T[BP] ;PTR TO START
- REPNE: SCASB ;SEARCH
- JNE X2
- INC CX ;FOUND A MATCH
- X2: SUB DX,CX ;FIND COUNT TO MATCH
- POPF
- JNS X3
- NEG DX ;MAKE NEGATIVE IF REVERSE
- X3: MOV [BP+$C],DX ;PUT IN FUNCTION RESULT
-
- Figure 2: INLINE Input File
-
-
-
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
- APPENDIX
-
- 8086/8088 Opcode Mnemonics Recognized by INLINE
-
- AAA HLT JNE LOOPNZ ROR
- AAD IDIV JNG LOOPZ SAHF
- AAM IMUL JNGE MOV SAL
- AAS IN JNL MOVSB SAR
- ADC INC JNLE MOVSW SBB
- ADD INT JNO MUL SCASB
- AND INTO JNP NEG SCASW
- CALL IRET JNS NOP SHL
- CBW JA JNZ NOT SHR
- CLC JAE JO OR SS
- CLD JB JP OUT STC
- CLI JBE JPE POP STD
- CMC JC JPO POPF STI
- CMP JCXZ JS PUSH STOSB
- CMPSB JE JZ PUSHF STOSW
- CMPSW JG LAHF RCL SUB
- CS JGE LDS RCR TEST
- CWD JL LEA REP WAIT
- DAA JLE LES REPE XCHG
- DAS JMP LOCK REPNE XLAT
- DB JNA LODSB REPNZ XOR
- DEC JNAE LODSW REPZ
- DIV JNB LOOP RET
- DS JNBE LOOPE RETF
- ES JNC LOOPNE ROL
-
-
-
-
-
- Turbo Pascal is a trademark of Borland International Inc.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 5
-
-
-
-
-