Vous êtes sur la page 1sur 9

8086 PROGRAMING

The x86 assembly has an unconditional jump operation, jmp, which can take an immediate address, a register or an indirect address as a parameter (note that most RISC processors only support a link register or short immediate displacement for jumping). Also supported are several conditional jumps, including je (jump on equality), jne (jump on inequality), jg (jump on greater than, signed), jl (jump on less than, signed), ja (jump on above/greater than, unsigned), jb (jump on below/less than, unsigned). These conditional operations are based on the state of specific bits in the (E) FLAGS register. Many arithmetic and logic operations set, clear or complement these flags depending on their result. The comparison cmp (compare) and test instructions set the flags as if they had performed a subtraction or a bitwise AND operation, respectively, without altering the values of the operands. There are also instructions such as clc (clear carry flag) and cmc (complement carry flag) which work on the flags directly. Floating point comparisons are performed via FCOM or FICOM instructions which eventually have to be converted to integer flags. Each jump operation has three different forms, depending on the size of the operand. A short jump uses an 8-bit signed operand, which is a relative offset from the current instruction. A near jump is similar to a short jump but uses a 16-bit signed operand (in real or protected mode) or a 32-bit signed operand (in 32-bit protected mode only). A far jump is one that uses the full segment base:offset value as an absolute address. The matching return from interrupt instruction is iret, which restores the flags after returning. Soft Interrupts of the type described above are used by some operating systems for system calls, and can also be used in debugging hard interrupt handlers. Hard interrupts are triggered by external hardware events, and must preserve all register values as the state of the currently executing program is unknown. In Protected Mode, interrupts may be set up by the OS to trigger a task switch, which will automatically save all registers of the active task. Examples "Hello world!" program for DOS in MASM style assembler
.MODEL Small .STACK 100h .DATA msg db 'Hello, world!$' .CODE start: mov ah, 09h lea dx, msg int 21h mov ax,4C00h int 21h end start

Using the flags register Flags are heavily used in the x86 architecture, for comparisons. A comparison is made between two data and the CPU set the relevant flag or flags, then conditional jump instructions can be used to check for expected flags and branch to code that should run in that case, e.g.: cmp eax, ebx

jne do_something Flags are also used in the x86 architecture to turn on and off certain features or execution modes. For example, to disable the processing of interrupts you can use the command: cli The flags register can also be directly accessed. The low 8 bits of the flag register can be loaded into AH using the LAHF instruction. The entire flags register can also be moved on and off the stack using the instructions PUSHF, POPF, INT (including INTO) and IRET. [edit] Using the instruction pointer register The instruction pointer is ip or in 32-bit mode, eip. The eip register points to the memory address which the processor will next attempt to execute; it cannot be directly accessed but a sequence like the following can be written to put the address of next_line into (e)ax: call next_line next_line: pop eax This works even in position-independent code because call takes an (e)ip-relative immediate operand. Writing to (e)ip is simple: jmp eax

6800 PROGRAMING
7 15 15 15 A 0 X PC SP 7 CCR 7 B 0 0 0 0 0

A - Accumulator A B - Accumulator B X - Index register PC - Program Counter SP - Stack Pointer CCR - Conditional Code Register: Half carry, Interrupt mask, Negative, Zero, oVerflow and Carry The 6800 is a standard "8-bit" 2's complement microprocessor, like the Intel 8080. It supports 8-bit bytes, 16-bit addresses and 64KB of memory. Like the 8080, code can be placed in ROM. This is an important feature compared to some of the minicomputers of the time, especially the PDP-8, which used a linked-list embedded in the code for subroutine linkage. The 6800 had a 16-bit stack pointer, so the stack can be located anywhere and can grow to any length up to the size of the memory. Compare this with the 6502 which had only an 8-bit stack pointer and which mapped the stack into the second page (addresses 256 - 511). Like the 8080, the 6800 supports multi-precision arithmetic using a carry flag and the ADC (add with carry) and SBC (subtract with carry) instructions. Decimal arithmetic is supported in a fashion similar to the 8080: there is a DAA (decimal adjust accumulator) instruction, which

corrects the result of the 2's complement ADD on two packed decimal digits. Unlike the 6502, the 6800 also provided add and subtract without carry (ADD and SUB instructions). Arithmetic instructions set the usual 2's complement flags: Sign, Zero, oVerflow and Carry. Unlike the 8080 and the 6502, the 6800 had a complete set of branch instructions, basically identical to those provided on the PDP-11, for comparing both signed and unsigned quantities. For example, if you want to compare i with j, then load i into an accumulator (LDAA i), compare or subtract with j (CMPA j or SUBA j) and then branch: BEQ - Branch if i equals j BNE - Branch if i does not equal j BHI - Branch if i is greater than j (unsigned) BHS - Branch if i is higher or same as j (unsigned) BLO - Branch if i is lower than j (unsigned) BLS - Branch if i is lower than or equal to j (unsigned) BGT - Branch if i is greater than j (signed) BGE - Branch if i is greater than or equal to j (signed) BLT - Branch if i is less than j (signed) BLE - Branch if i is less than or equal to j (signed) BPL - Branch if plus (positive or zero) BMI - Branch if minus (negative) BCC - Branch if Carry clear (same as BHS) BCS - Branch if Carry set (same as BLO) BVS - Branch if oVerflow set BVC - Branch if oVerflow clear BRA - Branch always Unlike the PDP-11, 6502 and 8080 the 6800 was big endian, as was the IBM 360. Unlike the PDP-11 and 6502, but like the 8080, the 6800 used borrow carry: the carry flag is set on a borrow during subtraction instead of clear. Unlike the 8080 and especially the PDP-8, but like the PDP-11, the 6800 had no special purpose I/O instructions. Instead, all I/O devices share the same address space as memory. Unlike the 8080, the 6800 had indexing, which allowed it to directly support data structures. The base address of a data structure is loaded into the index register, and then an 8-bit unsigned offset from the second byte of indexing instructions is added to it to read different items from the structure. The 6800 had four addressing modes: immediate, indexed, extended and direct (or zero-page). The zero-page mode allows faster direct access to the first 256 bytes of memory and is similar to the zero-page mode of the PDP-8. The zero-page can be thought of as an extension of the register set, an idea taken much further with the zero-page indirect modes of the 6502. The instruction set mnemonics owe a great deal to the PDP-11, and are burned into the brains of many assembly language programmers and computer architects. Many CPUs, including the ARM remained close to the form of the 6800 mnemonics.

THE FEATURE AVAILABLE IN THE MDA 8086 KIT

FEATURES

Program debugging function by PC. Program Download and trace function. Display to register contents. Memory contents modification and dump function. Various command function. Include with step motor interface circuit. Dot matrix experiment LCD(Liquid Crystal Display) 16 X 2 line experiment. D/A and A/D converter experiment. Sound experiment by speaker. Interrupt experiment. A/D converter experiment by thermistor. D/A converter experiment by Level meter. Key board experiment. External interface connector. LED display of current system bus status. +5V, +12V, -12V S.M.P.S(Free Voltage) Power(110V/220V).

CPU(CENTRAL PROCESSING Using Intel 8086, Using 4.9152Mhz. UNIT) ROM(READ ONLY MEMORY) SRAM(STATIC RANDOM ACCESS MEMORY) DISPLAY KEYBOARD SPEAKER RS-232C DOT MATRIX LED A/D CONVERTER D/A CONVERTER

It has program to control user's key input, LCD display, user's program. 64K Byte, it has data communication program. Range of ROM Address is F0000~FFFFFH. Input user's program & data. Address of memory is 00000H~0FFFFH, totally 64K Byte. It is LCD (Liquid Crystal Display), 16(Character)2(Line) It is used to input machine language and has 16 of hexa-decimal keys and 8 of function keys. Able to test sound using with speaker and further more able to test synthesizer. It is ready to do data communication with IBM compatible personal computer. To understand & test of dot matrix structure and principle of display it is interfaced to 8255A(PPI). Convert analog signal to digital signal using with ADC0804. Convert digital signal to analog signal using with DAC0800 and it is interfaced so as to more Level meter.

STEP MOTOR INTERFACE POWER

So as to control step motor driver circuit of step motor is interfaced. AC 110~220V, DC +5V 3A, +12V 1A, -12V 0.5A SMPS.(110V/220V)

THE ARCHITECTURAL DIFFERENCE BETWEEN THE INTEL 8085/8086/8088 & MOTOROLA 6800 WITH REFERENCE OF THE REGISTERS, ADDRESSING MODES PROGRAMMING FEATURES

8085
REGISTERS
ACCUMULATOR or A register is an 8-bit register used for arithmetic, logic, I/O and load/store operations. FLAG is an 8-bit register containing 5 1-bit flags: Sign - set if the most significant bit of the result is set. Zero - set if the result is zero. Auxiliary carry - set if there was a carry out from bit 3 to bit 4 of the result. Parity - set if the parity (the number of set bits in the result) is even. Carry - set if there was a carry during addition, or borrow during subtraction/comparison.

GENERAL registers:

8-bit B and 8-bit C registers can be used as one 16-bit BC register pair. When used as a pair the C register contains low-order byte. Some instructions may use BC register as a data pointer. 8-bit D and 8-bit E registers can be used as one 16-bit DE register pair. When used as a pair the E register contains low-order byte. Some instructions may use DE register as a data pointer. 8-bit H and 8-bit L registers can be used as one 16-bit HL register pair. When used as a pair the L register contains low-order byte. HL register usually contains a data pointer used to reference memory addresses.

STACK pointer is a 16 bit register. This register is always incremented/decremented by 2.

PROGRAM COUNTER is a 16-bit register.

INSTRUCTION SET

8085 instruction set consists of the following instructions:


Data moving instructions. Arithmetic - add, subtract, increment and decrement. Logic - AND, OR, XOR and rotate. Control transfer - conditional, unconditional, call subroutine, return from subroutine and restarts. Input/Output instructions. Other - setting/clearing flag bits, enabling/disabling interrupts, stack operations, etc.

ADDRESSING MODES

8086
REGISTERS
Most of the registers contain data/instruction offsets within 64 KB memory segment. There are four different 64 KB segments for instructions, stack, data and extra data. To specify where in 1 MB of processor memory these 4 segments are located the processor uses four segment registers: CODE SEGMENT (CS) is a 16-bit register containing address of 64 KB segment with processor instructions. The processor uses CS segment for all accesses to instructions referenced by instruction pointer (IP) register. CS register cannot be changed directly. The CS register is automatically updated during far jump, far call and far return instructions. STACK SEGMENT (SS) is a 16-bit register containing address of 64KB segment with program stack. By default, the processor assumes that all data referenced by the stack pointer (SP) and base pointer (BP) registers is located in the stack segment. SS register can be changed directly using POP instruction. DATA SEGMENT (DS) is a 16-bit register containing address of 64KB segment with program data. By default, the processor assumes that all data referenced by general registers (AX, BX, CX, DX) and index register (SI, DI) is located in the data segment. DS register can be changed directly using POP and LDS instructions. EXTRA SEGMENT (ES) is a 16-bit register containing address of 64KB segment, usually with program data. By default, the processor assumes that the DI register references the ES segment in string manipulation instructions. ES register can be changed directly using POP and LES instructions. It is possible to change default segments used by general and index registers by prefixing instructions with a CS, SS, DS or ES prefix. All general registers of the 8086 microprocessor can be used for arithmetic and logic operations. The general registers are: ACCUMULATOR register consists of 2 8-bit registers AL and AH, which can be combined together and used as a 16-bit register AX. AL in this case contains the low-order byte of the word, and AH contains the high-order byte. Accumulator can be used for I/O operations and string manipulation. BASE register consists of 2 8-bit registers BL and BH, which can be combined together and used as a 16-bit register BX. BL in this case contains the low-order byte of the word, and BH contains the high-order byte. BX register usually contains a data pointer used for based, based indexed or register indirect addressing. COUNT register consists of 2 8-bit registers CL and CH, which can be combined together and used as a 16-bit register CX. When combined, CL register contains the low-order byte of the word, and CH contains the high-order byte. Count register can be used as a counter in string manipulation and shift/rotate instructions. DATA register consists of 2 8-bit registers DL and DH, which can be combined together and used as a 16-bit register DX. When combined, DL register contains the low-order byte of the word, and DH contains the high-order byte. Data register can be used as a port number in I/O operations. In integer 32-bit multiply and divide instruction the DX register contains high-order word of the initial or resulting number. The following registers are both general and index registers: STACK POINTER (SP) is a 16-bit register pointing to program stack BASE POINTER (BP) is a 16-bit register pointing to data in stack segment. BP register is usually used for based, based

MOTOROLA 6800

REGISTERS

ACCUMULATOR A (ACCA) is an 8-bit register used for arithmetic and logic operations.

ACCUMULATOR B (ACCB) is an 8-bit register used for arithmetic and logic operations.

INDEX (IX) is a 16-bit register usually used for temporary storage or as an index when indexed addressing is used.

PROGRAM Counter (PC) is a 16-bit register.

STACK POINTER (SP) is a 16-bit register.

CONDITION Code register contains the following flags:

Half carry (H) - set if there was a carry from bit 3 to bit 4 of the result when the result was calculated.

Interrupt mask (I) - set if the IRQ interrupt is disabled.

Negative (N) - set if the most significant bit of the result is set.

Zero (Z) - set if the result is zero.

Overflow (V) - set if there was an overflow during last result calculation.

Carry (C) - set if there was a carry from the bit 7 during last result calculation.

INSTRUCTION SET

6800 instruction set consists of 72 instructions:

Data moving instructions.

Arithmetic - add, subtract, negate, increment, decrement and compare.

Logic - AND, OR, exclusive OR, complement and shift/rotate.

Control transfer - conditional, unconditional, call subroutine and return from subroutine.

Other - clear/set condition flags, bit test, stack operations, software interrupt, etc.

ADDRESSING MODES

IMPLIED - the data value/data address is implicitly associated with the instruction.

ACCUMULATOR - the instruction implies that the data is one of the accumulator registers.

IMMEDIATE - 8-bit or 16-bit data is provided in the instruction.

DIRECT - one-byte operand provided in the instruction specifies the memory address in page zero (0000h - 00FFh) where data is located.

EXTENDED - two-byte operand provided in the instruction specifies the memory address where data is located.

RELATIVE - one byte offset is added to the address of the next instruction (the contents of the program counter register + 2). The offset is a signed number in the range -127 - +127.

INDEXED - one byte operand is added to the contents of the IX register, the resulting 16-bit value is a pointer to memory where data is located.