Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc

09.06.2013 Views

XENIX Programming as: Assembler Branch Instructions The XENIX assembler has a new class of instructions, called branch instructions, that test a condition and branch to an instruction address further than 128 bytes away. These instructions take the same kind of operand as the normal jmp instruction but provide a test to see whether or not the jump should occur. The following is a list of the branch instructions. beq bge bgt bhi bhis ble blo blos blt bne br The branch instructions, when assembled, consist of two 8086/286 jump instructions. The first jump tests for the inverse of the condition specified by the branch. The second jump is the unconditional jump instruction jmp. If the branch condition is true, the first jump is ignored and the second jump taken. If the branch condition is false, the first jump is taken. The first jump passes control to the next statement after the second jump. For example, the statement bne subtest is equivalent to the statements no: je no jmp subtest String Instructions The XENIX assembler uses a subset of the string instructions normally available for the 8086/286 processor. In particular, the assembler accepts only those string instructions that do not take operands. These are essentially the byte and word forms of the string instructions with implied destination. To indicate this restriction, some instruction mnemonics no longer contain the "s" for string. The following is a list of the string instructions: cmpsb cmps lodb lodw movsb movs scab scaw stob stow The assembler also accepts the rep, repnz, and repz instructions for repeating string operations. Note that these instructions must appear alone on a line; they cannot be combined on the same line with a string instruction. 7-17

as: Assembler XENIX Programming lntersegment Instructions The XENIX assembler has redefined call and jump instructions to create a new class of instructions called intersegment instructions. These allow calls and unconditional jumps to locations across 8086/286 segment boundaries. {These are physical segments, not the text, data, and bss segments described earlier.) There are the following intersegment instructions: calli jmpi reti The calli and jmpi instructions can have either a locally or globally defined symbol as an operand. In this case, an appropriate segment address is provided automatically when the program is linked. If an indirect address operand is used, an appropriate segment address must be explicitly provided. The reti instruction has operands similar to the ret instruction. Input/Output Instructions The XENIX assembler has modified the in and out instructions to include the new forms inw and outw. The in and out instructions now operate strictly on byte values; inw and outw operate on words. Furthermore, these instructions take only one operand--the port number. The al or ax register is accessed as appropriate and must not be given as an operand. 80286 Instructions Assembly language programmers who wish to use 80286 instructions can insert the binary opcode of a given instruction into the instruction stream using the .byte and .word directives. For example, the directive .byte /6a, * 1 places the binary opcode of the pushi (for push immediate) instruction in the instruction stream. This code is equivalent to the 80286 instruction pushi * 1 A programmer can also use the power of the C language preprocessor to create macros for the 80286 instructions. For example, if the macro definition #define PUSHI(x) .byte /6a, *x is included in an assembly language source, then the macro call PUSHI(1) may be used for a pushi instruction in place of the .byte directive. In this case, you must invoke the C preprocessor using the cc command to resolve this macro. Note that privileged 80286 instructions are not available to user programs. 7-18

as: Assembler <strong>XENIX</strong> Programming<br />

lntersegment Instructions<br />

The <strong>XENIX</strong> assembler has redefined call and jump instructions to create a new class of<br />

instructions called intersegment instructions. These allow calls and unconditional jumps<br />

to locations across 80<strong>86</strong>/<strong>2<strong>86</strong></strong> segment boundaries. {These are physical segments, not the<br />

text, data, and bss segments described earlier.) There are the following intersegment<br />

instructions:<br />

calli<br />

jmpi<br />

reti<br />

The calli and jmpi instructions can have either a locally or globally defined symbol as an<br />

operand. In this case, an appropriate segment address is provided automatically when<br />

the program is linked. If an indirect address operand is used, an appropriate segment<br />

address must be explicitly provided. The reti instruction has operands similar to the ret<br />

instruction.<br />

Input/Output Instructions<br />

The <strong>XENIX</strong> assembler has modified the in and out instructions to include the new forms<br />

inw and outw. The in and out instructions now operate strictly on byte values; inw and<br />

outw operate on words. Furthermore, these instructions take only one operand--the port<br />

number. The al or ax register is accessed as appropriate and must not be given as an<br />

operand.<br />

80<strong>2<strong>86</strong></strong> Instructions<br />

Assembly language programmers who wish to use 80<strong>2<strong>86</strong></strong> instructions can insert the<br />

binary opcode of a given instruction into the instruction stream using the .byte and<br />

.word directives. For example, the directive<br />

.byte /6a, * 1<br />

places the binary opcode of the pushi (for push immediate) instruction in the instruction<br />

stream. This code is equivalent to the 80<strong>2<strong>86</strong></strong> instruction<br />

pushi * 1<br />

A programmer can also use the power of the C language preprocessor to create macros<br />

for the 80<strong>2<strong>86</strong></strong> instructions. For example, if the macro definition<br />

#define PUSHI(x) .byte /6a, *x<br />

is included in an assembly language source, then the macro call<br />

PUSHI(1)<br />

may be used for a pushi instruction in place of the .byte directive. In this case, you<br />

must invoke the C preprocessor using the cc command to resolve this macro.<br />

Note that privileged 80<strong>2<strong>86</strong></strong> instructions are not available to user programs.<br />

7-18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!