Thursday, April 4, 2019

the use of assembler directives in microprocessor

the use of assembly computer program leadings in micro mainframe computerAbstractThis term paper includes the use of assembly program guidings in microprocessor and the various assembly program guidings employ in Intel microprocessor 8086, its dress with various examples.I) DefinitionAn assembler guiding is a message to the assembler that tells the assembler or sothing it needs to know in order to carry out the assembly process for example, an assemble directive tell the assembler where a program is to be located in re cristal dollar billtiveness. on that point atomic upshot 18 some operating instructions in the assembly row program which are non a part of processor instruction set. These instructions are instructions to the assembler, linker and loader. These are referred to as pseudo-operations or as assembler directives.II) delectation Of Assembler DirectivesThe assembler directives control organization of the program and provide necessary propoundation to the asse mbler to realise assembly diction programs to generate mechanism codes. They indicate how an operand or a section of program is to be processed by the assembler. An assembler supports directives to define data, to organize incisions to control turns, to define macros etc. An assembly language program consists of ii partwrites of statements instructions and directives. The instructions are translated to machine codes by the assembler whereas the directives are not translated to machine codes.III) Assembler Directives For Intel8086 Microprocessor1) AS perfumeEThe ASSUME directives is utilize to inform the assembler the come tos of the logical shares, which are to be assigned to the different segments employ in an assembly language program. In an assembly language program, each(prenominal) segment is wedded a realize by the programmer. For example, the code segment may be given the depict CODE or CODE_SEG or MY_CODE, etc. The data segment may be given the wee-wee data , MY_DATA, DATA_SEG, etc. signfacesi) ASSUME CS CODEThe above directive tells the assembler that the name of the code segment is CODE. This name is a user delineate segment name. The segment named CODE contains the machine codes of the instructions. The code segment register (CS register) is to be loaded with the starting portion out of the code segment, given by the operating system for the tail CODE in the assembly language program.ii) ASSUME DS DATAThe above directive informs the assembler that the name of the data segment is DATA. This is a user defined segment name. It contains data of the program which is being executed. The DS register (data segment register) is to be loaded with the starting address of the data segment, given by the operating system for the label DATA in the program.iii) ASSUME SS circumstancesThe above directive tells the assembler that the name of the stack segment use by the programmer is STACK. This is a user defined segment name. It stores address es and data of the subroutines, saves the contents a specify register or wareho using locations after PUSH instruction, etc. The stack segment register SS holds the starting address of the stack segment allotted by the operating system.iv) ASSUME ES EXTRAThe above directive tells the assembler that the name of the extra segment is EXTRA which is a user defined segment name. In Intel 8086 microprocessor, string instructions may use DI register to point the destination storage address for the data. The EXTRA segment is used to hold the addresses pointed by DI.2) DB (Define Byte)The directive DB a byte type variable. In a given directive statement, in that location may be single sign rate or multiple initial set of the defined variable. If at that place is hotshot initial regard as, one byte of memory set is reserved for each value. The general format is fall upon of Variable DB initial value or nourishs. exercisingsi) VELOCITY DB 0This directive informs assembler to reser ve one byte of memory musculus quadriceps femoris for the variable named VELOCITY and format it with value zero.ii) WEIGHT DB 85This directive informs assembler to reserve one byte of memory space for the variable named WEIGHT and initialize with value 85.iii) FORCE DB ?This directive directs assembler to reserve one byte of memory space for the variable FORCE. Further more(prenominal), the question mark ? In the data definition informs assembler that the value of the variable is not known and hence, it is not to be initialized.iv) ARRAY DB 32, 42, 59, 67, 83This directive informs assembler to reserve five bytes of consecutive memory space for the variable named ARRAY. The memory locations are to be initialized with the values 32, 42, 59, 67 and 83.v) MESSAGE DB THANK YOUThis directive informs the assembler to reserve the number of bytes of memory space equal to the number of characters in the string named MESSAGE, and initialize the memory locations with ASCII codes of the these c haracters.3) DW (Define Word)The directive DW defines a word -type variable. The defined variable may have one or more initial values in the directive statement. If there is one value, two-bytes of memory space are reserved. If there are multiple values, two bytes of memory space are reserved for each value. The general formula isName of variable DW sign Value or Values. typesi) SUM DW 3596.This directive informs the assembler to reserve two bytes (one word) of consecutive memory locations for the variable named SUM and initialize it with the value 3596.ii) NUMBER DW 25The above directive statement informs assembler to reserve two bytes of consecutive memory locations for the variable named NUMBER. The first byte of the memory is to be initialized with the ASCII code of two (32) and the second byte is to be initialized with the ASCII code of five (35). Hence, the two bytes of memory space contain 3235H.iii) DATA DW 5384, 6932, 5 DUP (3456), 7384This directive informs assembler to r eserve 16 bytes of consecutive memory locations. The number 3456 is repeated five times. Memory locations are initialized with 5384,6932, 3456, 3456, 3456,3456, 3456 and 7384.4) DD (Define branched Word)This directive DD defines a double word-type variable. The defined variable may have one or more values in the statement. If there is only one value, four bytes of consecutive memory locations are reserved. If there are multiple values, four bytes of memory locations are reserved for each value. The general format isName of Variable DD Initial value or valuesExampleNUMBER DD 23958634The above directive informs assembler to reserve four bytes of memory locations for the variable named NUMBER and initialize with the number 23958634.5) DQ (Define Quadword)The directive DQ defines a quadword- type variable. The defined variable may have one or more values in the statement. If there is only one value, 8 bytes of consecutive memory locations are reserved. If there are multiple values, 8 b ytes of memory space are reserved for each value. The general format isName of Variable DQ Initial value or valuesExampleNUMBER DQ 1568934893846735The above directive informs assembler to reserve 8 bytes of consecutive memory locations for the variable named NUMBER and initialize with the above mentioned number.6) DT (Define Tenbytes)The directive DT defines a variable of ten bytes. In the directive statement there may be one or more values. If there is only one value, 10 bytes of consecutive memory locations are reserved. If there are multiple values, ten consecutive memory locations are reserved for each value. The general format isName of Variable DT Initial value or valuesExampleNUMBER DT 34968435876934839251The above directive informs assembler to reserve 10 bytes of consecutive memory locations for the variable named NUMBER and initialize with the above specified values.7) ending (End of Program)The directive END informs assembler the end of a program module. This is used aft er the last statement of the program module. This assembler ignores statement(s) after an END directive. Therefore, the programmer should use END directive at the very end of his program module. A carriage return is used after the END directive. Its general format isEND label8) ENDP (End Procedure)The directive ENDP informs assembler the end of a result. In assembly language programming, subroutines are called social functions. A procedure may be an independent program module to give certain result or the unavoidable value to the calling program. A procedure is given a name i.e. a label. The label is used as prefix with directive ENDP. This directive is used together with PROC directive to enclose the procedure. To specify the type of the procedure the term FAR or NEAR is used after the PROC directive. The type FAR indicates that the procedure to be called is in some other segment of memory. font NEAR indicates that the procedure is in the similar segment of memory. If type is not specified, the assembler assumes it NEAR. The general format for ENDP directive isProcedure Name ENDPExampleSPEED_CONTROL PROC FAR Start of Procedure Procedure instructionsSPEED_CONTROL ENDP End of Procedure9) ENDM (End Macro)The directive ENDM is used to inform assembler that this is the end of a macro. The directive ENDM is used with the directive MACRO to enclose macro instructions.ExampleCOMPLIMENT MACRO Start of macro Macro instructionsENDM End of MacroCOMPLIMENT is the name of a macro. The name is given before the directive MCRO which tells the assembler the beginning of a macro.10) ENDS ( End of Segment)The ENDS directive informs assembler that this is the end of the segment. The name of the segment is given using ASSUME directive which has already been explained. The name of the segment is used as the prefix of the ENDS directive. Its general format isSegment Name ENDSExampleCODE_SEG subdivision Start of code segment instructionsCODE_SEG ENDS End of segment11) EQU (Equate)The directive EQU is used to give a name to certain value or attribute. If any value or symbol is used numerous times in an assembly language program, a name is given to the value or symbol to make programming easier and simpler. Each time the assembler finds the given name in the program, it replaces the name with the value or symbol which has already been equated with that name. The general format for the EQU directive isValue Name EQU Valueor orSymbol Name SymbolExampleROOM_TEMP EQU 02HThe above directive tells assembler to replace ROOM_TEMP by 02H. If EQU directive is written in the beginning of the program and later on MOV AL, ROOM_TEMP is written in the program, the assembler will treat this instruction as if it were MOV AL, 02H while giving its machine codes.12) EXTRN (External)This directive informs the assembler that the name, procedures and labels undermentioned this directive have already been defined in some other program modules. The names, procedures an d labels tell as external in one program module must be declared public using PUBLIC directive in the program module in which they have been defined. When the programmer informs assembler that the declared item is an external one, the assembler puts this information in the object code file so that the linker support connect the concerned two program modules together. The general format for EXTRN directive isi) EXTRN Variable Name Type of variableii) EXTRN Procedure Name (NEAR/FAR)For external named variable, procedure or constant its type is to be specified.Examples i) EXTRN multiplier factor WORDIn this directive the variable named MULTIPLIER is an external variable and it is word type variable.ii) EXTRN CORRECTION_FACTOR ABSIn this directive CORRECTION_FACTOR is an external constant. It has been defined with EQU directive in another program module. Constants are identified by type ABS.13) denounce (Label)In an assembly language program labels are used to give names to memor y addresses. When assembler begins assembly process, it initializes a location comeback to keep the track of memory locations i.e. memory addresses. The content of the location counter holds the address of the memory location assigned to an instruction during assembly process. The nock directive is used to give a name to the current value in the location counter i.e. the current memory address which is in the location counter. The type of label is to be specified. The general format of the LABEL directive isLABEL Label Name Label TypeExampleAHEAD LABEL NEARInstructionInstruction AHEADAHEAD Instruction14) LENGTH ( Length)It is an doer to determine the number of elements in a data item such as an array or a string.ExampleDATA SEGMENTARRAY DW 10 DUP(?)NUMBERS DB 10 DUP(?)DATA ENDSThe LENGTH operator can be used as followsi) MOV CX, LENGTH ARRAYii) MOV CX, LENGTH NUMBERSIn both examples i) and ii), the execution of the instruction will move number 10 in the register CX as the number of elements are 10 in both the variables ARRAY as well as NUMBERS.15) PROC (Procedure)The directive PROC indicate the start of a procedure. The type of the procedure FAR or NEAR is to be specified after the directive. The type NEAR is used to call a procedure which is within the program module. The type FAR is used to call a procedure from some other program module. The PROC directive is used with ENDP directive to enclose a procedure. The general format of the PROC directive isName of procedure PROC type of procedureExample i) TEMP_MEAST PROC FARThe above procedure is for temperature measurement and it lies in some other program module.There are other directives also which includes TYPE (Type), STRUCT OR STRUC (Structure Declaration), SIZE (Size), SHORT (Short), SEG (Segment), RECORD (Record), PUBLIC (Public), MACRO, give away (Name), OFFSET (Offset) etc.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.