1 / 39

COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING

COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING. Visit for more Learning Resources. THE ART OF ASSEMBLY LANGUAGE PROGRAMMING. CHAPTER 4. Program development steps. Defining the problem Algorithm Flowchart Initialization checklist Choosing instruction

silviac
Download Presentation

COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING Visit for more Learning Resources

  2. THE ART OF ASSEMBLY LANGUAGE PROGRAMMING CHAPTER 4

  3. Program development steps • Defining the problem • Algorithm • Flowchart • Initialization checklist • Choosing instruction • Converting algorithm to assembly language program

  4. Defining the problem • The first steps in writing program is to think very carefully about the problem that you want to solve. • The problem is given in the form of statement or mathematical expression • Read the problem carefully and understand the problem • Expand the problem to get a clear ,concise and accurate description • E.g: read temperature from sensor

  5. Algorithm • An algorithm is a step-by-step instruction require to solve any problem. • An algorithm consist of a set of explicit , finite steps which when carried out for a given set of initial condition,produce the output.

  6. Flowchart • The flowchart is graphically representation of the program operation • The specific operation is represented by graphical symbol such as circle ,rectangle , diagonal, square, parallelogram.

  7. Initialization checklist • In program there are many variables, constant ,and various part of the system such as segment registers ,flags ,stack , programmable port which must be initialize properly. • The best way to approach the initialization task is to make the checklist of the entire variables, constants, registers , flags &ports

  8. Choosing instructions • Next steps is to choose proper instruction that performs your problem’s operation • This is an important step that breaking down the programming problems sequences of steps  easy to find the instruction solve the problem

  9. Converting algorithm into assembly language • In assembly language program a first step is to set up & declare the data structure that the algorithm will be working with then write down the instruction required for initialization at the start of the code section. • Determine the instruction required to implement the major actions in the algorithm

  10. Assembly language program development tools 1)Editor: • An editor is a program which helps you to construct your assembly language program in right format- translate it correctly in machine language • So you can type your program using editor • Form of the program source program. • DOS based editor such as EDIT ,wordstar &norton editor

  11. Assembler • An assembly is a program that translate the program-into binary code for each instruction .i.e: machine code and generate the file called as object file with extension .obj • Example: tasm ,masm

  12. Linker • A linker is a program which combines if requested more than one separately assembled module into one executable program • Example: Tlink

  13. Debugger • Debugger is a program that allows the execution of program in single step mode under the control of the user. • The process of locating & correcting errors using a debugger is known as debugging • Example: DOS debug command , borland’s turbo debugger.

  14. Program development process • Source file creation • Object code generation • Executable file creation • Program running • Program testing • Program debugging

  15. Data definition direction 1) DB • The directive DB  to define a byte type variable • It can be used to single or multiple byte variable. • The range of values that can be stored in a byte is 0 to 255 for unsigned number & -128 to +127 for signed numbers • Name_of_variable DB initalization_value(s)

  16. Dw: define word • The directive Dw to define a word type • It can be used to define single or multiple word variables • The range is 0 to 65535 for unsigned numbers & -32768 to +32767 • General form: Name of variable DW initialization value(,s)

  17. DD: define double word • DD used to define a double word type • Can be used to define single or multiple double word variable i.e 4 byte • Range is 0 to 2^32-1 for unsigned numbers • -2^32-1 to 2^32-1-1for signed numbers • General form: Name_of_variable DD Initalization_value(,s) Example: NUM DD ?=allocate four memory locations

  18. DQ: define quad word • DQ is used to define a quad word type • It can be used to define single or multiple quad word variable • Range is 0 to 2^64-1 for unsigned numbers • -2^64-1 to 2^64-1-1 for signed numbers • It is used in the math coprocessor instruction where large no are used in computation • General form: Name_of _variable DQ initalization_value(,s) Example: NUM DQ ? = allocate 8 memory location

  19. DT: define ten byte • DT: used to define a ten byte type variable • Can be used to define a single or multiple 10 byte variable. • Range 0 to 2^80-1 for unsigned number • -2^80-1 to 2^80-1-1 for signed integer numbers • The floating point numbers range from 10^-4932 to 10^4932 • The DT type variables useful in math coprocessor instruction where large numbers are used in computation

  20. -General form: • Name_Of _ variable DT Initalization_Value( , s) • Example: • NUM DT ? = allocate ten memory locations • TABLE DT 1,2,3,564,5689 = allocate fifty memory location -

  21. LABEL • The directive LABEL enables you to redefine the attribute of a data variable or instruction label. • General form: Variable_name LABEL type_specifier Example: • TEMP LABEL BYTE • NUM LABEL WORD

  22. ALIGN : alignment of memory address • The directive ALIGN - to force the assembler to align the next data item • General form: ALIGN Numeric_value -the number must be a power of 2 such as 2 ,4 ,8 ,16 Example: ALIGN 4

  23. STRUCT: structure declaration • STRUCT - to declare the data type which is primary collection of data type • Structure declaration allows the user to define a variable which has more thatn one data type. • General form: Structure _name STRUCT …………. ; sequence of DW ,DD directives for declaring ; ; field ………… structure_name ENDS • Example: Employee STRUCT emp_num DW ? emp_name DB 25 DUP(0) emp_dept DB 30 DUP (0) Employee ends

  24. Accessing structure variable field: • - The structure variable field can be accessed by using a dot(.) operator known as the structure access operator. • General form: • Structure_variable. Field _name • Example: • here structure variable name is emp1 • emp1.emp_num • emp1. emp_name • emp1.emp_dept

  25. EQU:equate to • The EQU directive  declare the symbols which some constant value is assigned. • Such symbolscalled as macro symbols • Macro assembler will replace every occurrences of the symbols • Macro increase readability of program • General form: symbols_name EQU Expression Example: NUM EQU 100

  26. ORG: originate • ORGassign the location counter with the value specified in the directive • Helps in placing the machine code in the specified location while translating the instruction into machine codes by the assembler. • This feature useful in buliding device drivers • General form: ORG [$] Numeric_value Example: ORG 100h

  27. Program organization directives 1) ASSUME : • Assume informs the assembler the name of the logical segment that should be used for a specified segment. • General form: ASSUME seg_reg: Seg_name,……………..seg_reg:Reg_name Where ASSUME is a assmebler directive Seg_reg is any of the segment register Seg_name is the name of an user defined segment Example: ASSUME CS: code segment, DS: data segment

  28. SEGMENT • Segment is used to indicate the beginning of the logical segment. • Segment follows the name of the segment • Segment &ends must be enclosed the segment data, code ,extra or stack of the program. • General form: segment_name SEGMENT [WORD /PUBLIC] • WORD indicates that the segment has to be located at the next available address. • PUBLIC indicates that the given segment which have the same name.

  29. Example: code segment ……………… ………………. code ends Data segment ………………. ……………… Data endsaa

  30. ENDS:end of the segment • ENDS  informs the assembler the end of the segment • ENDS & SEGMENTmust enclosed the segment data or code of the program. • General form: segment_name ENDS Example: my_data segment ……….. My_data ENDS

  31. END:end of the program • END to inform assembler the end of the program. • General form: END[start_address] • start_address indicates the location in the code segment where execution is to begin.

  32. .CODE:simplified CODE segment directive • This simplified segment directive defines the code segment. • All executable code must be placed in this segment. • General form: .CODE [name]

  33. .DATA:simplified DATA segment directive • This simplified segment directive defines the data segment for initialized near data • All data definition & decalration must be placed in this segment. • General form: .DATA

  34. .STACK : simplified STACK segment directive • It defines the stack segment & default size of the stack is 1024 bytes which you may override. • General form: .STACK 100

  35. .MODEL: memory model decalration for segment • It creates default segment. • General form: .MODEL memory_small Memory model: • TINY=masm 6.0 used for .com program • SMALL= all data in one segmetn & all code in one segment. • LARGE=both data &code in more than one segment

  36. Value returning attribute directives 1) LENGTH: • The Lengthinforms the assemblers about the number of the elements in a data items such as array • If the array is defined in DB it return number of bytes allocated to a variable. • It the array is defined in DW it return the number of word allocated to the array variable.

  37. General form: LENGTH variable_name Example: MOV CX,LENGTH NAME

  38. SIZE • It is same as LENGTH except that it return the number of bytes allocated to the data items instead of the number of element in it • General form: SIZE variable_name Example: MOV AX, SIZE NAME

  39. SEG:segment • The SEG is used to determine the segment in which the specified data items is defined • General form: SEG variable_name Example: MOV DS,SEG MSG For more detail contact us

More Related