Q. State and Explain steps involved in program development. [w-08, w-10, s-12, w-11]

Similar documents
Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

8086 ALP TOOLS (CH 2) CHAPTER 2

ORG ; TWO. Assembly Language Programming

Assembling, Linking and Executing 1) Assembling: .obj obj .obj.lst .crf Assembler Types: a) One pass assembler:

UNIT 4. Modular Programming

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)

Constants and Expressions. Lecture 7: Assembly Language Programs. Constants and Expressions (cont.) Statements. Names. Assembly Directives

Assembler Programming. Lecture 10

Lecture 16: Passing Parameters on the Stack. Push Examples. Pop Examples. CALL and RET

Experiment 3 3 Basic Input Output

Computer Architecture and System Software Lecture 07: Assembly Language Programming

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program.

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000

Assembly Language Fundamentals. Chapter 3

Constants and. Lecture 7: Assembly Language Programs. Expressions (cont.) Constants and. Statements. Expressions

EEM336 Microprocessors I. Data Movement Instructions

db "Please enter up to 256 characters (press Enter Key to finish): ",0dh,0ah,'$'

The Stack. Lecture 15: The Stack. The Stack. Adding Elements. What is it? What is it used for?

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Computer Structure and Organization

Lesson 4. Stack, Procedures and Macros

Intel 8086: Instruction Set

Basic Assembly SYSC-3006

Experiment 8 8 Subroutine Handling Instructions and Macros

The statement above assumes that the PCMAC.INC file is in the current directory. The full path of the file can also be given:

Experiment #5. Using BIOS Services and DOS functions Part 1: Text-based Graphics

PHY4635/5635 Spring Lecture 8: Program Control Instructions

ADVANCE MICROPROCESSOR & INTERFACING

Code segment Stack segment

EC 333 Microprocessor and Interfacing Techniques (3+1)

Experiment N o 3 Segmentation and Addressing Modes

CS-202 Microprocessor and Assembly Language

Computer Architecture and System Software Lecture 06: Assembly Language Programming

Macros in Pentium. Assembly Language. October 25

ELEC 242 Using Library Procedures

Assembly Language: g Part III. First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Chapter 3: Addressing Modes

How to write an assembly language program.

Midterm Exam #2 Answer Key


Computer Architecture 1 ح 303

Experiment N o 3. Segmentation and Addressing Modes

Microcomputer Architecture..Second Year (Sem.2).Lecture(2) مدرس المادة : م. سندس العزاوي... قسم / الحاسبات

Lecture (05) x86 programming 4

US06CCSC04: Introduction to Microprocessors and Assembly Language UNIT 1: Assembly Language Terms & Directives

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut

Chapter Three Addressing Mode MOV AX, BX

b) List the 16 Bit register pairs of 8085?(Any 2 pair, 1 Mark each) 2M Ans: The valid 16 bit register pair of 8085 are

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

16.317: Microprocessor Systems Design I Fall 2013

Chapter 3. Assembly Language Programming with 8086

SHEET-2 ANSWERS. [1] Rewrite Program 2-3 to transfer one word at a time instead of one byte.

LABORATORY WORK NO. 8 WORKING WITH MACROS AND LIBRARIES

Topics Introduction to Microprocessors. Chapter 5 Macros and modules. What is macro? How to use macro? (I) How to use macro?

Microprocessor and Assembly Language Week-5. System Programming, BCS 6th, IBMS (2017)

.code. lea dx,msg2. Page 1/8. Problem 1: Programming in Assembly [25 Points]

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

UNIVERSITY OF CALIFORNIA, RIVERSIDE

Lab 3: Defining Data and Symbolic Constants

Video processing The INT instruction enables program to interrupt its own processing. Use INT instruction to handle inputs and outputs

Computer Architecture and System Software Lecture 04: Floating Points & Intro to Assembly

COE 205 Lab Manual Experiment N o 12. Experiment N o Using the Mouse

EC-333 Microprocessor and Interfacing Techniques

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

PESIT Bangalore South Campus

Summer 2003 Lecture 15 07/03/03

Programming in Module. Near Call

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

Parameter Passing. Procedure line. Calling procedure line. Most subroutines require parameters Can sometimes pass parameters via registers

LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS

Microprocessors (A) DOS Services

Memory Organization. 27 December 2016 Pramod Ghimire. Slide 1 of 21

CPU. IBM PC and compatible Memory Structure

Mating Assembly with C

Machine and Assembly Language Principles

Summer 2003 Lecture 4 06/14/03

Objectives. ICT106 Fundamentals of Computer Systems Topic 8. Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8

Lecture-30 Assemblers To assemble a program automatically the assembler needs information in the form of assembler direct that controls the assembly.

PESIT Bangalore South Campus

ELEC VIDEO BIOS ROUTINES

Procedures and the Stack. Chapter 4 S. Dandamudi

A4 Sample Solution Ch3

Transfer of Control. Lecture 10 JMP. JMP Formats. Jump Loop Homework 3 Outputting prompts Reading single characters

Experiment #2. Addressing Modes and Data Transfer using TASM

Mr. Sapan Naik 1. Babu Madhav Institute of Information Technology, UTU

Writing 32-Bit Applications

CSE 505 Lecture 8: Introduction to Assembly Language

CS499. Intel Architecture

Lecture 6. Assembler Directives

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-11: 80x86 Architecture

Assignment 3. Problem Definition:

ELCT 707 Micro Computer Applications Final-term Exam, Winter 2009

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

ELEC 242 Time Delay Procedure

2003 LXI H, 42F2H ; this instruction store 42F2 in to the HL pair POP H ; store data from top of the stack to HL pair

Defining and Using Simple Data Types

Assembly Language Lab #5

MICROPROCESSOR & MICROCONTROLLER

MICROPROCESSOR. Question Bank

Assembly Language Each statement in an assembly language program consists of four parts or fields.

Transcription:

Q. State and Explain steps involved in program development. [w-08, w-10, s-12, w-11] Answer: 1. Defining Problem 2. Algorithm 3. Flowchart 4. Initialization of checklist 5. Choosing instructions 6. Converting algorithm into program. Q. what is algorithm? What is flowchart? Sketch symbols of flowchart. Answer: [refer techmax] Q. Explain Assembler, linker, editor, debugger. [Most important questions. Always ask in exam] Answer:[Refer manual and Techmax] Assembler directives: [note: all the directives are important. But concentrate on those directives which are given in important questions] Assembler directives help the assembler to correctly understand the assembly language programs to prepare the machine codes. Assembly language programs are composed of two types of statements: i) The instructions, which are translated to machine code by the assembler. ii) The directives that direct the assembler during the assembly process, for which no machine code is generated. Directive is a statement which gives direction to the assembler. The directives are also called pseudo instructions and are not translated into machine language. The directives are necessary for the assembler to assemble efficiently and correctly.

2.1.1. Data Definition and Storage Allocation Directives: Data definition directives are used to define the program variables and allocate a specified amount of memory to them. a) DB: Define Byte: The DB directive is used to reserve byte or bytes of memory locations in the available memory. Name of the variable DB Initialization Value i) RANKS DB 01H, 02H, 03H, 04H This statement direct the assembler to reserve four memory locations for a list named RANKS and initializes them with the above specified four values. ii) MESSAGE DB GOOD MORNING This makes the assembler to reserve the number of bytes of memory equal to the number of characters in the string names MESSAGE and initialize those locations by the ASCII equivalent of these characters. b) DW: Define Word: The DW directive serves the same purposes as the DB directive, but it now makes the assembler the number of memory words (16-bit) instead of bytes. Name of the variable DW Initialization Value

i) WORDS DW 1234H, 4567H, 78AH, 045CH This makes the assembler to reserve four words in memory (8 bytes), and initialize the words with the specified values in the statements. During the initialization, the lower bytes are stored in the lower memory addresses, which the upper bytes are stored in the higher addresses. Another option of the DW directive is explained with the DUP operator. ii) WDATA DW 5 DUP (6666H) This statement reserves five words, i.e., 10-bytes of memory for a word label WDATA and initializes all the word locations with 6666H. c) DQ: Define Quad word: This directive is used to direct the assembler to reserve 4 words (8 bytes) of memory for the specified variable and may initialize it with the specified values. Name of the variable DQ Initialization Value TOTAL DQ 0 Reserves 8 bytes of memory for the variable TOTAL and initializes with 0. d) DD: Define Double: The directive DD is used to define a double word (4 bytes) variable. Name of the variable DD Initialization value

TOTAL DD 0 Reserves 4 bytes of memory for the variable TOTAL and initializes with 0. e) DT: Define Ten bytes: Name of the variable DT Initialization Value The DT directive directs the assembler to define the specified variable requiring 10 bytes for its storage and initialize the 10 bytes with the specified values. ACODE DT 0 The above statement informs the assembler to reserve 10 bytes of memory for a variable named ACODE and initialize with 0. 2.1.2. STRUCTURE DECLARATION: STRUCT: The directive strut is used to declare the data types, which is a collection of programming primary data types, i.e., DB, DW, DT, DT and DQ. Structurename Strut : : : Sequence of DB, DW, DQ, DD for declaration fields :

: Structurename ENDS Student Strut Roll-no DW? Name DW 10 DUP (?) Class DB? Branch DB 10 DUP (?) Student ENDS 2.1.3. PROGRAM ORGANIZATION DIRECTIVES: The 8086 programs are organized as a collection of logical segments. The directives used to organize the program segments are: SEGMENT, ASSUME, ENDS etc. a) SEGMENT: The directive SEGMENT is used to indicate the beginning of a logical segment. The directive segment follows the name of the segment. To end the segment, SEGMENT must be ended with ENDS statement. DATA SEGMENT program data definition

DATA ENDS b) ENDS: The directive ENDS informs the assembler the end of the segment. The directives ENDS and SEGMENT must enclose the segment data or code of the program. Segmentname ENDS. c) ASSUME: The directive assume informs the assembler the name of the logical segment that should be used for a specified segment when program is loaded and the processor segment registers should point to the respective logical segments. ASSUME segreg : segname,.., segreg : segname. i) ASSUME CS : _code ii) ASSUME CS : _code, DS : _Data, SS : _stack 2.1.4. END: End of program: Program termination directive and it is used to inform the assembler the physical end of the program. The statement after the directive END will be ignored by the assembler. 2.1.5. VALUE RETURNING ATTRIBUTE DIRECTIVES: The task of programming can be made easier by assigning assembler to compute the size of the data items it is performed using the directives LENGTH, SIZE, OFFSET and TYPE. a) LENGTH: The directive LENGTH informs the assembler about the number of elements in a data item such as an array. If an array is defined with DB then it returns the number of bytes

allocated to a variable. If an array is defined with DW then it returns the number of words allocated to the array variable. LENGTH Variablename DATA Segment Name DB 100 dup (?) A DW 50 dup (?) Total DW? DATA ENDS AX, LENGTH Name then AX = 100 bytes i.e., array size BX, LENGTH A then BX = 50 words i.e., array size. b) SIZE: The directive size is same as length except that it returns the number of bytes allocated to the data item instead of the number of elements in it. SIZE variablename DATA Segment Name DB 100 DUP (?) A DW 50 DUP (?) TOTAL DW? DATA ENDS AX, Size Name

then AX= 100 bytes i.e., array size. BX, Size A then BX= 100 bytes i.e., array size CX, Size TOTAL then CX= 2 bytes c) OFFSET: The directive OFFSET informs the assembler to determine the displacement of the specified variable with respect to the base of the segment. It is usually used to load the offset of a variable into the register using this OFFSET value a variable can be referenced using indexed addressing modes. OFFSET VariableName DATA Segment MSG DB Hello World A DW 50 DUP (?) DATA ENDS DX, OFFSET MSG DX= offset of the variable MSG SI, OFFSET A SI= offset of the array. AX, [SI] AX= element of array pointed to by SI i.e.[si] refers to A[1] [SI+2] refers to A[2]

[SI+4] refers to A[3] d) SEG: SEGMENT: The directive SEG is used to determine the segment in which specified data item is defined. SEG VariableName DATA Segment MSG DB Hello World A DW 50 DUP (?) DATA ENDS DS, SEG MSG DS= segment in which the variable MSG exists DS, SEG A DS= segment in which array A exists. e) TYPE: The directive type is used to determine the type of data type. The assembler allocates one byte to DB. Two bytes to DW and 4 bytes to DD. TYPE Variable name DATA Segment MSG DB A A DW 100 PI DD 3.17 DATA ENDS

ADD BX, TYPE MSG (MSG is DB type) ADD BX, TYPE A (A is DW type) ADD BX, TYPE PI (PI is DD type) 2.1.6. Procedure Definition Directives: The procedure definition directives are used to define subroutines. a) PROC: Procedure: The directive PROC indicates the beginning of the procedure. The directive PROC follows the name of the procedure and the term NEAR or FAR follows the PROC indicating the type of procedure. The directive PROC is used with the directive ENDP to enclose the procedure code. Procedure Name PROC NEAR/FAR ONE PROC NEAR TWO PROC FAR Readint PROC Write procedure code to read integer data

Readint ENDP b) ENDP: End of Procedure: The directive ENDP informs the assembler the end of procedure. Procedure Name ENDP ONE1 ENDP. 2.1.7. Macro Definition Directives: These are used to define macro constants and macro functions. a) EQU: Equate Macro Constant: The directive EQU is used to declare the symbols to which some constant value is assigned such symbols are called as macro symbols and macro assembler will replace every occurrence of the symbol in a program by its value. Macros are used to increase the readability of a program. The advantage of macro is that the modification of the symbol value of the declaration will be reflected throughout the program. Num EQU 100 H AX, Num AX, 100 H b) MACRO: The directive macro informs the assembler the beginning of a macro. It consists of name of the macro followed by a keyword MACRO and macro arguments if any. The directive MACRO and ENDM must enclose the definition, declarations or a small part of the code which have to be substituted at the innocation of a macro. Macroname MACRO (arg1, arg2,, argn)

Printstring MACRO MSG INT AH, 09 H DX, OFFSET MSG 21 H ENDM 2.1.8. Data Control Directives: The data control directives are used to declare the variables used in communication of information between the program modules. a) PUBLIC: The directive PUBLIC informs the assembler that the specified variable of segment can be accessed from other program modules. It helps in managing multiple program modules by sharing global variables (or) procedure. The variables and procedures to be shared must be declared as public in a module in which physically exists. PUBLIC variable 1, variable 2,., variable n PUBLIC XMAX, YMAX. The variables XMAX, YMAX can be accessed from other program modules by declaring them as external using the directive EXTRN. b) EXTRN: External: The directive EXTRN informs the assembler that the data items are labeled following the directive will be used in a program module which is defined in another program module. EXTRN XMAX, YMAX : WORD EXTRN EXTRN Myprint : FAR FACT : NEAR

c) PTR: Pointer: The pointer operator is used to declare the type of a label, variable or memory operand. The operator PTR is prefixed by either BYTE or WORD. If the prefix is BYTE, then the particular label, variable or memory operand is treated as an 8-bit quantity, while if WORD is prefix, then it is treated as a 16-bit quantity. In other words, the PTR operator is used to specify the data type byte or word. i) AL, BYTE PTR [SI] Moves content of memory location addressed by SI (8-bit) to AL. ii) INC BYTE PTR [BX] Increment byte contents of memory location addressed by BX.