TASM instruction set extensions
This section gives a brief description of Turbo Assembler's extensions
to the instruction set.
Intelligent code generation
See SMART
Extended jumps
See JUMPS
Additional 80386 LOOP instructions
LOOPW, LOOPWE, LOOPWZ, LOOPWNE, LOOPWNZ count using the CX register.
LOOPD, LOOPDE, LOOPDZ, LOOPDNE, LOOPDNZ count using the ECX register.
The standard LOOPcc mnemonics select the counting register based on
whether the current code segment is 32-bit (ECX) or 16-bit (CX).
Additional 80386 ENTER and LEAVE instructions
ENTERW, LEAVEW use BP,SP as stack frame registers.
ENTERD, LEAVED use EBP,ESP as stack frame registers.
Additional IRET instructions (version T320+)
IRETW always pops word-style.
Extended PUSH and POP instructions
Multiple push or pop instructions per line allowed.
Examples: push ax [bx] cx dx si
pop cx bx ax
push [foo] bx
Push/pop of DWORD-sized pointers on 8086,80186,80286 supported.
Push/pop of PWORD/QWORD-sized pointers on ≥80386 supported.
Pushing constants on the 8086 supported (affects push, extended
call):
Example: P8086 ; Code generated:
push 1234h ; push ax
; push bp
; mov bp,sp
; mov [word bp + 2],1234h
; pop bp
Extended PUSHA,POPA,PUSHF,POPF instructions (version T320+)
PUSHAW,POPAW,PUSHFW,POPFW always push and pop word-style, even in a
32-bit code segment.
Extended shifts
TASM permits shift and rotate instructions to have a constant value
other than 1 when the 8086 processor is selected. TASM accomplishes
this by emitting the appropriate number of single shift/rotate
instructions when the 8086 processor is selected.
Example: ; source ; code generated
SHL AX,4 ; SHL AX,1
; SHL AX,1
; SHL AX,1
; SHL AX,1
Forced segment overrides: SEGxx instructions
TASM provides six instructions that will generate a segment override
prefix byte: SEGCS, SEGSS, SEGDS, SEGES, SEGFS, and SEGGS.
Examples: SEGES XLATB
;
SEGCS
test [byte bx],1
Additional smart flag instructions
TASM has four instructions that manipulate bits in a flag to improve
both code size and efficiency. Use these to enhance the modularity of
records (if the state of the flags are unimportant (except TESTFLAG)).
Instruction Function Corresponds to
FLIPFLAG Complement flag bit(s) XOR
MASKFLAG Mask off flag bit(s) AND
SETFLAG Set flag bit(s) OR
TESTFLAG Test flag bit(s) TEST
Example: RECORD foo r0:1,r1:4,r2:3,r3:1
; ...
TESTFLAG ax,MASK r1
; will generate the most efficient instruction
; regardless of where r1 exists in the record
Additional field value manipulation instructions
TASM can generate specific code sequences for setting and retrieving
values from bit fields specified with the RECORD directive. This lets
you write code that is independent of the actual loction of a field
within a record. Used in conjunction with the ENUM directive, records
can achieve a high degree of modularity in assembly language.
Instruction Function
GETFIELD Sets a value in a record field
SETFIELD Retrieves a value from a record field
Additional fast immediate multiply instruction
TASM provides a special immidiate multiply operation for efficient
array indexing. FASTIMUL addresses a typical problem that occurs when
you create an array of structures. On the 8086, there is no immediate
multiply operation available; even for the more advanced processors,
multiplication using shifts and adds is significantly faster in some
circumstances than using the standard immediate IMUL instruction.
Based on the currently specified processor, the FASTIMUL instruction
chooses between the most efficient sequence of shifts and adds
available, and the current processor's immediate IMUL operation (if
any).
Extensions to necessary 80386 instructions
The 80386 has the ability to operate in both 16-bit and 32-bit mode.
Many of the standard instructions have different meanings in these two
modes. In TASM, you can control the operating size of the instruction
using the SMALL and LARGE overrides in expressions.
SMALL/LARGE affect the following instructions:
push [small | large] segment_register } 16-or 32-bit form of
pop [small | large] segment_register } segment register
fsave [small | large] mem_pointer )
frstor [small | large] mem_pointer )
fstenv [small | large] mem_pointer )
fldenv [small | large] mem_pointer ) Selects 16-bit or
lgdt [small | large] mem_pointer ) 32-bit instruction
sgdt [small | large] mem_pointer )
lidt [small | large] mem_pointer )
sidt [small | large] mem_pointer )
jmp [small | large] mem_pointer } For DWORD-sized addresses:
call [small | large] mem_pointer } FAR 16-bit or NEAR 32-bit
Calling procedures with stack frames
An extended form of the CALL instruction lets you directly call
procedures that use high-level language interfacing conventions:
CALL expression [language] [,argument_list]
Procedures that define some of their arguments with the RETURNS
keyword always expect the caller to POP them. There is no special
extension to the CALL instruction to help pass those arguments
specified in a procedure declaration after the RETURNS keyword. You
must explicitly PUSH these arguments before the CALL, and POP them
afterwards.
Objects
The CALL and JMP instructions, as well as the STRUC directive, have
extensions that support objects.