This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: UNIT 3 ASSEMBLY LANGUAGE 1 PROGRAMMING (PART -I) I 1 Structure I 3.0 Introduction 3.1 Objectives I 3.2 Simple Assembly Programs 3.2.1 Data Transfer 3.2.2 Simple Arithmetic i 3.2.3 Shift Operations 3.2.4 Larger Of The Two Numbers 3.3 Programming With Loops and Comparisons 3.3.1 Simple Program Loops b 3.3.2 Find The Largest And The Smallest Array Values 3.3.3 Character Coded Data 3.3.4 Code Conversion 3.4 Programming for Arithmetic and String Operations 3.4.1 String Processing 3.4.2 Arithmetic Problems 3.5 Summary 3.6 Model Answers 3.1 INTRODUCTION After discussing about few essential directives, program developmental tools and simple programs, let us discuss more about assembly language programs. In this unit, we will start our discussions with simple assembly programs which fullils simple task such as data transfer, arithmetic operations, shift operations. A kcy example here will be about finding larger of two numbers. T b r e a f ~ e r , we will discuss about more complex programs showing how loops and various comparisons are used to implement tasks like code conversion, coding characters, finding largcs~ in array etc. Finally, we will discuss about more complex arithmetic and string operations. You must refer to further reading for more discussions on these programming concepts. 3.1 OBJECTIVES At the end of this unit, you should be able to: write assembly programs with simple arithmetic logical and shift operations implement loops use comparisons for implementing various comparison function write simple assembly program for code conversion a write simple assembly program for implementing arrays 3.2 SIMPLE ASSEMBLY PROGRAMS As part of this unit, we will discuss to write assembly language programs. We shall start with very simple programs, and later graduate to more complex ones. 32.1 Data Transfer Two most basic data transfer instructions are MOV and'XCHG. Let us consider the following program which'uses both these instructions, to exchange two memory variables. Microprocessor and Assembly Language Programming DATA SEGMENT VALUEl DB OAh VALUE2 DB 14h ; Initialize Variables DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA MOV AX, DATA MOV DS, AX MOV AL,VALUEl ; Load Value1 into AL XCHG VALUE2,AL ; exchange AL with Value2 MOV VALUE1,AL ; Store Al in Value1 MOV AX,4COOh ; Halt INT 21h CODE ENDS END MOV instruction has already been described in detail in the Unit 1. We shall only revise some of the limitations on types of operands for this type of data transfer instructions: - CS and IP may never be destination operands. - Immediate data and variables may not be moved to segment registers. - The source and the destination operands may be of the same size. - Both these operands cannot be memory locations....
View Full Document
- Fall '10