ENABLE INTERRUPTS
EXCLUSIVE OR IMMEDIATE WITH ACCUMULATOR XRI performs an exclusive OR operation using the contents of the second instruction byte and the contents of
Chapter 3. Instruction Set
X RA Memory with Accumulator
Opcode Operand
XRA M
The contents of the memory location specified by the Hand L registers is exclusive-ORed with the contents of the accumulator. The result is stored in the accumulator. The carry and auxiliary carry flags are reset to zero.
~_O
_ _ O_Cycles:
States:
Addressing:
Flags:
Examples:
2
"1
o
register indirect Z ,S ,P ,CY ,AC
Since any bit exclusive-ORed with itself produces zero, XRA is frequently used to zero the accumulator. The following instructions zero the accumulator and the Band C registers.
XRA A
MOV B,A
MOV C,A
Any bit exclusive-ORed with a one bit is complemented. Thus, if the accumulator contains all ones (OFFH), the instruction XRA B produces the one's complement of the B register in the accumulator.
EXCLUSIVE OR IMMEDIATE WITH ACCUMULATOR XRI performs an exclusive OR operation using the contents of the second instruction byte and the contents of the accumulator. The result is placed in the accumulator. XRI also resets the carry and auxiliary carry flags to zero.
Opcode Operand
XRI data
The operand must specify the data to be used in the OR operation. This data may be in the form of a number, an ASCII constant, the label of some previously defined value, or an expression. The data may not exceed one byte.
The assembler's relocation feature treats all external and relocatable symbols as 16-bit addresses. When one of these symbols appears in the operand expression of an immediate instruction, it must be preceded by either the HIGH or LOW operator to specify which byte of the address is to be used in the evaluation of the expression.
When neither operator is present, the assembler assumes the LOW operator and issues an error message.
Cycles:
States:
Addressing:
Flags:
Summary of Logical Operations
o
data
o
2 7
immediate Z,S,P,CY,AC
AND produces a one bit in the result only when the corresponding bits in the test data and the mask data are ones.
OR produces a one bit in the result when the corresponding bits in either the test data or the mask data are ones.
Exclusive OR produces a one bit only when the corresponding bits in the test data and the mask data are different; i.e., a one bit in either the test data or the mask data - but not both - produces a one bit in the resul t.
AND OR EXCLUSIVE OR
1010 1010 1010 1010 1010 1010 0000 1111 0000 1111 0000 11
n
0000 1010 10101111 10100101
Example:
Assume that a program uses bits 7 and 6 of a byte as flags that control the calling of two subroutines. The program tests the bits by rotating the contents of the accumulator until the desired bit is in the carry flag; a CC instruction (Call if Carry) tests the flag and calls the subroutine if required.
Assume that the control flag byte is positioned normally in the accumulator, and the program must set OFF bit 6 and set bit 7 ON. The remaining bits, which are status flags used for other purposes, must not be altered.
Since any bit exclusive-ORed with a one is complemented, and any bit exclusive-ORed with a zero remains unchanged, the following instruction is used:
XRI
The instruction has the following results:
Accumulator Immediate data
110000008
01 001100 11000000 10001100
XTHL
Chapter 3. Instruction Set
EXCHANGE H&L WITH TOP OF STACK XTHL exchanges two bytes from the top of the stack with the two bytes stored in the Hand L registers. Thus, XTHL both saves the current contents of the Hand L registers and loads new values into Hand L.
Opcode Operand
XTHL
Operands are not allowed with the XTH L instruction.
XTHL exchanges the contents of the L register with the contents of the memory location specified by the SP (Stack Pointer) register. The contents of the H register are exchanged with the contents of SP+ 1.
Cycles:
States:
Addressing:
Flags:
Example:
0 0 0 5
18 (16on8085) register indirect none
Assume that the stack pointer register contains 1 OADH; register H contai ns OBH and L contains 3CH; and memory locations 10ADH and 10AEH contain FOH and ODH, respectively. The following is an illustration of the effect of the XTHL instruction:
Before XTHL After XTHL
10AC FF FF
MEMORY ADDRESS
lOAD 10AE
FO OD
3C OB
H L
lOAF
FF OB 3C
FF OD FO
The stack pointer register remains unchanged following execution of the XTH L instruction.
4. ASSEMBLER DIRECTIVES
This chapter describes the assembler directives used to control the 8080/85 assembler in its generation of object code. This chapter excludes the macro directives, which are discussed as a separate topic in Chapter 5.
Generally, directives have the same format as instructions and can be interspersed throughout your program.
Assembler directives discussed in this chapter are grouped as follows:
GENERAL DI RECTIVES:
• Symbol Definition EQU
SET
• Data Definition DB
DW
• Memory Reservation DS
• Conditional Assembly IF
ELSE ENDIF
• Assembler Termination END
LOCATION COUNTER CONTROL AND RELOCATION:
• Location Counter Control ASEG
DSEG CSEG ORG
• Program Linkage PUBLIC
EXTRN
Three assembler directives - EQU, SET, and MACRO - have a slightly different format from assembly language instructions. The EQU, SET, and MACRO directives require a name for the symbol or macro being defined to be present in the label field. Names differ from labels in that they must not be terminated with a colon (:) as labels are. Also, the LOCAL and ENDM directives prohibit the use of the label field.
The MACRO, ENDM, and LOCAL directives are explained in Chapter 5.