Case Study Assemblers For X85 and X86
Case Study Assemblers For X85 and X86
Case Study Assemblers For X85 and X86
INTRODUCTION TO ASSEMBLERS
If an assembler’s speed is important, this two-step process can be done in one pass over
the assembly file with a technique known as backpatching. In its pass over the file, the
assembler builds a (possibly incomplete) binary representation of every instruction. If the
instruction references a label that has not yet been defined, the assembler records the
label and instruction in a table. When a label is defined, the assembler consults this table
to find all instructions that contain a forward reference to the label. The assembler goes
back and corrects their binary representation to incorporate the address of the label.
Backpatching speeds assembly because the assembler only reads its input once.
However, it requires an assembler to hold the entire binary representation of a program in
memory so instructions can be backpatched. This requirement can limit the size of
programs that can be assembled. The process is complicated by machines with several
types of branches that span different ranges of instructions. When the assembler first sees
an unresolved label in a branch instruction, it must either use the largest possible branch
or risk having to go back and readjust many instructions to make room for a larger
branch.
ASSEMBLY LANGUAGE
RISC CISC
Means Reduced Instruction Set Computer. A Means Complex instruction set architecture.
RISC system has reduced number of A CISC system has complex instructions
instructions and more importantly it is load such as direct addition between data in two
store architecture where pipelining can be memory locations. Ex-8085
implemented easily. Ex-ATMEL AVR
RISC architecture is not widely used. CISC architecture is widely used At least
75% of the processor use CISC architecture.
RISC puts a greater burden on the software. CISC, software developers no need to write
Software developers need to write more lines more lines for the same tasks
for the same tasks
Mainly used for real time applications Mainly used for real time applications
Mainly used in normal PC’s, Workstations
and servers
This does not provides more code flexibility This provides more code flexibility but
but increases the overall speed efficiency reduces the overall speed efficiency
DIFFERENCE BETWEEN 8085 AND 8086 ARCHITECTURE
8085 8086
The Intel 8085 is an 8 bit microprocessor The Intel 8086 is a 16 bit microprocessor
created in 1977. created in 1978.
8085 is a 8 bit processor, number of flags 8086 is a 16 bit processor, number of flags
are 5 and memory capacity is 64KB are 9 and memory capacity is 1 MB.
8085 is based on Von-Neumann The 8086 was the first chip to start the X86
architecture in which the data and architecture family. 8086 is a 16 bit
instructions are in the same memory space processor. Has got 20 address lines.
without any distinction between them.8085 Operates upto 5MHz8085 consists 74
is CISC (Complex Instruction Set instructions.8086 consists 117 instructions
Computer.8085 is a 8 bit processor i.e 8 bit in 8086 four 16 bit registers are available
data bus. Has got 16Address Lines. and pin no 33- min/(~max) it selects
Maximum Operating speed is 3MHz. 8085- minimum mode when this pin is high
AOperates upto a maximum of 5MHz. otherwise it selects maximum mode.
8085 μp
8086 has a 20 bit address bus can access up to 220 memory locations (1 MB).
It can support up to 64K I/O ports.
It provides 14, 16 -bit registers.
It has multiplexed address and data bus AD0- AD15 and A16 – A19.
It requires single phase clock with 33% duty cycle to provide internal timing.
8086 is designed to operate in two modes, Minimum and Maximum.
It can prefetches upto 6 instruction bytes from memory and queues them in order to
speed up instruction execution.
It requires +5V power supply.
A 40 pin dual in line package.
MOV Move
Arithmetic Group:
Logical Group:
CMP Compare
Jump unconditionally
JMP Jump
Jump conditionally
JC Jump on Carry CY = 1
JP Jump on positive S = 0
JM Jump on minus S = 1
JZ Jump on zero Z = 1
Call unconditionally
CALL Call
Call conditionally
CC Call on Carry CY = 1
CP Call on positive S = 0
CM Call on minus S = 1
CZ Call on zero Z = 1
Return conditionally
RET Return
Return unconditionally
RC Return on Carry CY = 1
RP Return on positive S = 0
RM Return on minus S = 1
RZ Return on zero Z = 1
HLT Halt
NOP No Operation
8086 Instruction Set
Data Transfer Instructions
MOV -Move byte or word to register or memory
IN, OUT -Input byte or word from port, output word to port
LEA Load effective address
LDS, LES Load pointer using data segment, extra segment
PUSH, POP Push word onto stack, pop word off stack
XCHG Exchange byte or word
XLAT Translate byte using look-up table
Logical Instructions
NOT Logical NOT of byte or word (one's complement)
AND Logical AND of byte or word
OR Logical OR of byte or word
XOR Logical exclusive-OR of byte or word
TEST Test byte or word (AND without storing)
Arithmetic Instructions
ADD, SUB Add, subtract byte or word
ADC, SBB Add, subtract byte or word and carry (borrow)
INC, DEC Increment, decrement byte or word
NEG Negate byte or word (two's complement)
CMP Compare byte or word (subtract without storing)
MUL, DIV Multiply, divide byte or word (unsigned)
IMUL, IDIV Integer multiply, divide byte or word (signed)
CBW, CWD Convert byte to word, word to double word (useful before multiply/divide)
DAA, DAS Decimal adjust for addition, subtraction (binary coded decimal numbers)
Transfer Instructions
JMP Unconditional jump
Conditional jumps:
JA (JNBE) Jump if above (not below or equal), +127, -128 range only
JAE (JNB) Jump if above or equal (not below), +127, -128 range only
JB (JNAE) Jump if below (not above or equal), +127, -128 range only
JBE (JNA) Jump if below or equal (not above), +127, -128 range only
JE (JZ) Jump if equal (zero), +127, -128 range only
JG (JNLE) Jump if greater (not less or equal), +127, -128 range only
JGE (JNL) Jump if greater or equal (not less), +127, -128 range only
JL (JNGE) Jump if less (not greater nor equal), +127, -128 range only
JLE (JNG) Jump if less or equal (not greater), +127, -128 range only
JC, JNC Jump if carry set, carry not set, +127, -128 range only
JO, JNO Jump if overflow, no overflow, +127, -128 range only
JS, JNS Jump if sign, no sign, +127, -128 range only
JNP (JPO) Jump if no parity (parity odd), +127, -128 range only
JP (JPE) Jump if parity (parity even), +127, -128 range only
Loop control:
LOOP Loop unconditional, count in CX, short jump to target address
LOOPE (LOOPZ) Loop if equal (zero), count in CX, short jump to target address
LOOPNE (LOOPNZ) Loop if not equal (not zero), count in CX, short jump to target
address
JCXZ Jump if CX equals zero (used to skip code in loop)
String Instructions
MOVS Move byte or word string
MOVSB, MOVSW Move byte, word string
CMPS Compare byte or word string
SCAS Scan byte or word string (comparing to A or AX)
LODS, STOS Load, store byte or word string to AL or AX
Repeat instructions (placed in front of other string operations):
REP Repeat
REPE, REPZ Repeat while equal, zero
REPNE, REPNZ Repeat while not equal (zero)