Assembler Directives 8086 8086 Microprocessor by Ravinder Nath Rajotiya - December 14, 2020March 2, 20210 Assembly Language Programming in 8086 In this article we will know about the 8086 assembler directives, and the the format of the assembly language program in 8086. Memory in 8086 systems is segmented, the segments being code segment, data segment, stack segment and extra segment. While writing the assembly the beginning and end of Different segments are to be Clearly indicated. This is done by segment directive. Also the declaration of data types Also should be in format understandable by the assembler. The following paragraph describes the some of the directives required for writing the 8086 assembly program. So directive in 8086 are the instructions to the assembler, and are not converted into the machine language. Here we discuss various assembler directives:
Processor Control Instruction 8086 8086 Microprocessor by Ravinder Nath Rajotiya - December 14, 2020May 10, 20210 Processor Control Instructions There are certain instructions in 8086 that control the processor flags, i.e. the flags can be set or reset by use of these instructions. Processor control instructions Description Comments/ example FLAG CONTROLS STC Set carry Flag ( CF=1) CLC Clear carry (CF=0) CMC Complement carry flag STD Set Direction flag, thus reverse traverSIng the string, i.e. SI or DI now point at the end of string, In each traverse SI/DI will be decremented Data segment Name db “MyString” Revrse_name db 8 dup(‘ ‘) Data ends Code segment Assume DS:data CS:code MOV AX, data MOV DS,AX CLD LEA SI,Name LEA DI, Reverse_name MOV CX, 08 REP MOVSB; Code ends CLD Clear Direction flag so that string traverse is from beginning, SI/DI will point to beginning of string STI Set interrupt enable flag to 1(enable interrupts) CLI DIsalee interrupts External Synchronization HLT HALT(do nothing) until interrupts WAIT Wait till SIgnal on TEST pin is low ESC Escape to external
String Instructions in 8086 8086 Microprocessor by Ravinder Nath Rajotiya - December 14, 2020May 10, 20210 String Related Instructions A string is nothing but a collection of ascii Characters codes. Many a time it require to perform some operation on strings such as copy a string, compare strings, concatenation of strings etc. 8086 has a powerful set of string related instructions and are DIscussed below: REP GROUP: Instructions Description Example FLAG affected REP It is used as a prefix instruction. Repeat until CX=0, REP decrements CX in each loop REPE / REPZ Repeat the instruction until CX=0 or ZF is not equal to 1. REPE prefix will cause string instruction to be repeated, as long as compared bytes or words are equal or CX is not zero. GenerALly used with CMPS and SCAN REPNE / REPNZ Repeat the following instruction until the compared string are not equal, and CX
Loop Instructions 8086 Microprocessor 8086 Microprocessor by Ravinder Nath Rajotiya - December 14, 2020May 10, 20210 Loop using DEC and JMP Instructions We are familiar with the conditional branch instructions which as shown below could be used for repetitive tasks. Looping using these technique involve more than one instruction as shown in following format MOV CX, N Begin : do some operation operations DEC CX JNZ Begin Loop Instructions in 8086: loop instructions are used to simplify the decrementing, testing and branching portion of the loop. In the above case this portion required two instructions, but in more complicated situation may require more than two instructions. The loop instruction for 8086 all have the form: OPCODE D8 where D8 is byte displacement from current IP. The loop instruction is simplified to: With loop instruction the format for branch become: MOV CX, N Begin: -- -- LOOP Begin The Loop
Branch Type Instructions 8086 8086 Microprocessor by Ravinder Nath Rajotiya - December 14, 2020May 10, 20210 Branch Instruction: The branch instruction is used to transfer the control of the program to a new address. This branch can be Conditional or Unconditional. Once the branch is taken the execution of instructions will take place from this new address called branch address. Usually the Conditional branch is taken after the ADD, SUB, INC, DEC and the instructions used to implement the LOOP. When these types of instructions are executed, the CS and IP registers get loaded with new values of CS and IP corresponding to the location where a branch is required. The branch instruction can be one of the following types. Unconditional Jump instructions: JMP, CALL, RET, INT N, INTO, IRET, LOOP, Conditional Jump instructions: JA/JNBE, JAE/JNB, JB/JNAE, JC, JNC, JE /JZ, JNE