Assignment 3. Problem Definition:

Similar documents
Experiment 3 3 Basic Input Output

Week /8086 Microprocessor Programming II

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

Week /8086 Microprocessor Programming I

UNIT 4. Modular Programming

Chapter 3: Addressing Modes

EC 333 Microprocessor and Interfacing Techniques (3+1)

Arithmetic and Logic Instructions And Programs

Intel 8086: Instruction Set


PESIT Bangalore South Campus

Signed number Arithmetic. Negative number is represented as

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

ELEC 242 Time Delay Procedure

Computer Architecture and System Software Lecture 06: Assembly Language Programming

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

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

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

Assembly Language Lab # 9

Computer Architecture and System Programming Laboratory. TA Session 3

Kingdom of Saudi Arabia Ministry of Higher Education. Taif University. Faculty of Computers & Information Systems

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

CS401 Assembly Language Solved MCQS From Midterm Papers

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

ORG ; TWO. Assembly Language Programming

Experiment 8 8 Subroutine Handling Instructions and Macros

6/20/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

EEL 3801 Introduction to Computer Engineering Summer Home Work Schedule

EEM336 Microprocessors I. Addressing Modes

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

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

ADVANCE MICROPROCESSOR & INTERFACING

CONTENTS. 1. Display a Message Display a one Digit Number Accept a Character from keyboard and display the character 4

Computer Architecture and System Software Lecture 07: Assembly Language Programming

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

Faculty of Engineering Student Number:

if 2 16bit operands multiplied the result will be

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

Computer Organization & Assembly Language Programming. CSE 2312 Lecture 15 Addressing and Subroutine

EEM336 Microprocessors I. Data Movement Instructions

Defining and Using Simple Data Types

Introduction to 8086 Assembly

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

16-Bit Intel Processor Architecture

3.1 DATA MOVEMENT INSTRUCTIONS 45

8086 ALP TOOLS (CH 2) CHAPTER 2

LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS

A4 Sample Solution Ch3

EC-333 Microprocessor and Interfacing Techniques

Computer Organization and Assembly Language. Lab Session 4

BAHAR DÖNEMİ MİKROİŞLEMCİLER LAB3 FÖYÜ

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB

UNIT 2 PROCESSORS ORGANIZATION CONT.

CS401 Assembly Language Solved Subjective MAY 03,2012 From Midterm Papers. MC

Assembler lecture 5 S.Šimoňák, DCI FEEI TU of Košice

ADDRESSING MODES. Operands specify the data to be used by an instruction

mith College Computer Science CSC231 Assembly Week #5 Fall 2017 Dominique Thiébaut

Come and join us at WebLyceum

Registers. Ray Seyfarth. September 8, Bit Intel Assembly Language c 2011 Ray Seyfarth

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

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 4

8088/8086 Programming Integer Instructions and Computations

complement) Multiply Unsigned: MUL (all operands are nonnegative) AX = BH * AL IMUL BH IMUL CX (DX,AX) = CX * AX Arithmetic MUL DWORD PTR [0x10]

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

Computer Architecture and Assembly Language. Practical Session 3

Instructions moving data

Arithmetic Instructions

Code segment Stack segment

CS401 - Computer Architecture and Assembly Language Programming Glossary By

EEM336 Microprocessors I. Arithmetic and Logic Instructions

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

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

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

CG2007 Microprocessor systems.

SOEN228, Winter Revision 1.2 Date: October 25,

CS/ECE/EEE/INSTR F241 MICROPROCESSOR PROGRAMMING & INTERFACING MODULE 4: 80X86 INSTRUCTION SET QUESTIONS ANUPAMA KR BITS, PILANI KK BIRLA GOA CAMPUS

2. (a) Draw and explain the pin out diagram of (b) Explain the various operations performed by Bus Interfacing unit in 8086.

THE UNIVERSITY OF TRINIDAD & TOBAGO

Assembly Language. Dr. Esam Al_Qaralleh CE Department Princess Sumaya University for Technology. Overview of Assembly Language

LAB WORK NO. 3 TURBO DEBUGGER ENVIRONMENT

Experiment N o 3. Segmentation and Addressing Modes

Q1: Define a character string named CO_NAME containing "Internet Services" as a constant?

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

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

Experiment N o 3 Segmentation and Addressing Modes

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Faculty of Engineering Computer Engineering Department Islamic University of Gaza Assembly Language Lab # 2 Assembly Language Fundamentals

We will first study the basic instructions for doing multiplications and divisions

Binghamton University. CS-220 Spring x86 Assembler. Computer Systems: Sections

8086 INTERNAL ARCHITECTURE

16.317: Microprocessor Systems Design I Spring 2015

Summer 2003 Lecture 4 06/14/03

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

Inline Assembler. Willi-Hans Steeb and Yorick Hardy. International School for Scientific Computing

16.317: Microprocessor Systems Design I Fall 2015

Module 3 Instruction Set Architecture (ISA)

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

Shift and Rotate Instructions

9/25/ Software & Hardware Architecture

Transcription:

Att (2) Perm(5) Oral(3) Total(10) Sign with Date Assignment 3 Problem Definition: Write x86 ALP to convert 4-digit Hex number into its equivalent BCD number and 4-digit BCD number into its equivalent HEX number.make your program user friendly to accept the choice from user for: HEX to BCD BCD to HEX EXIT Display appropriate messages to prompt the user while accepting the input and Displaying the result. 3.1 Prerequisites: Concept of number system 3.2 Learning Objectives: Understand the implementation stack for its conversion of number 3.3 New concept:- 1.3.1 Memory model directives. 1.3.2 Segment directives. 1.3.3 Data type declaration 3.4 Theory 3.4.1 Memory model directives These directives instruct the assembler as to how large the various segment (code, data, stack, etc) can and what sort of segmentation register will be required.

.MODEL <model > Where <model>is one of the following options: Tiny- code and data fit into single 64k and accessed via near pointers. Small- code and segment both less than 64k and accessed via near pointers. Compact Code segment is <64K (near ptr) and data segment is <1MB (far ptr ) Medium- Code segment is <1Mb (far ptr) and data segment is <64K (near ptr) Large- code and data segment both less than 1MB and accessed via far pointers. Huge- Like large model, but also permits arrays larger then 64K 3.4.2 Segmen directives These directives indicate to assembler the order in which to load segment. When it encounter one of these directives, it interprets all subsequent instructor as belonging to the indicated segment (until the ne xt directives is encounter).. data.stack <size>; specified.code 3.4.3 Data type declaration As has been previously discu ssed, data can be of several different lengths and assembler must be able to decide what length a specific constant (or variable) is. This can be down using data type declaration in conjunction with a constant declaration or variable assignment.this is akin to strong typing of variable in high level language.the data types are: Byte (8 bit quantity) synonyms are byte and db Word (16) -- synonyms are word dw Dword (32bit) -- synonyms are dword and dd Qword (64bit) -- synonyms with dq Tword (128bit) -- synonyms with dt An example of their use is: MOV AX, word VAR; moves a 16-bit Variable VAR into AX

3.5 Instruction Used: 1. PUSH:-Push word onto stack. 2. POP:-Pop word off stack. 3. DIV:-Divide byte/word 4. XOR: - Exclusive or byte/word 5. JA/JNBE:-Jump if above/not below or equal 6. JB/JNAE:-Jump if below /not above or equal 7. JG/JNLE:-Jump if /not less nor equal 8. JL/JNGE:-Jump if less /not greater nor equal 9. INT:-It allows ISR to be activated by programmer & external H\W device 3.6 New interrupt used: 1 INT 21h, function 0AH:- Read from keyboard and place into a memory buffer a row of character, until<cr>is pressed. 3.7 New directives used: 1..MODEL 2..STACK 3..DATA 4..CODE 5..OFFSET: - It informs the assembler to determine the offset/displacement of a named data item. 6..PTR: - assign a specific type to variable/label 3.8 Algorithm: 3.8.1 HEX to BCD 1. Define variable on data segment. 2. Display message on screen ENTER 4-DIGIT HEX NO. 3. Accept BCD NO from user. 4. Transfer 0AH as a divisor in one of the register. 5. Divide the no by 0AH 6. PUSH reminder in one of the register 7. Increment Count _1.

8. Repeat Till BCD NO is not zero go to step 5. 9. Pop the content of Reminder. 10. Display result by calling display procedure. 11. Decrement Count _1, till Count is not zero repeat step 9 else go to step 12. 12. Stop 3.8.2 BCD to HEX 1. Define variables in data segment 2. Display message on screen ENTER 5-DIGIT BCD NO. 3. Accept single digit from user 4. Transfer 10000 to multiplier 5. Multiply accepted BCD digit by multiplier & add it to RESULT variable. 6. Accept single digit from user 7. Transfer 1000 to multiplier 8. Multiply accepted BCD digit by Multiplier & Add it to RESULT variable. 9. Accept single digit from user 10. Transfer 100 to multiplier 11. Multiply accepted BCD digit by Multiplier & Add it to RESULT variable. 12. Accept single digit from user 13. Transfer 10 to multiplier 14. Multiply accepted BCD digit by multiplier & add it to RESULT variable. 15. Accept single digit from user 16. Transfer 1 to multiplier 17. Multiply accepted BCD digit by multiplier & add it to RESULT variable. 18. Display result by calling display procedure 19. Stop. 3.8.3 Procedure for accept numbers: (ASCII to HEX) 1. Read a single character/digit from keyboard using function 0AH of INT 21H 2. Convert ASCII to HEX as per following: a. Compare its ASCII with 30H if No is less than 0 (i.e case of -ve no given) then go to step f else go to step c. b. Compare its ASCII with 39H if No is greater than 9 (i.e case of character A F given) then go to step f else go to step c. c. Store the resultant bit in NUM Variable.

d. Check whether four digits (16-bit number) or two digits (8-bit number) are read; if yes then go to display procedure else go to step 1 for next bit e. Till counter is zero go to accept procedure. f. Display massage I/P is invalid BCD number & go to step 17. 3. End of accept procedure. 3.8.4 Procedure for display Result: (HEX to ASCII) 1. Compare 4 bits (one digit) of number with 9 2. If it is <= 9 then go to step 4 else go to step 3 3. Add 07 to that number 4. Add 30 to it 5. Display character on screen using function 02 of INT 21H 6. Return to main routine 7. End of display procedure. HEX to BCD Divide FFFF by 10 --- note this FFFF is as decimal 65535 so Division 65535 / 10 Quotient = 6553 Reminder = 5 6553 / 10 Quotient = 655 Reminder = 3 655 / 10 Quotient = 65 Reminder = 5 65 / 10 Quotient = 6 Reminder = 5 6 / 10 Quotient = 0 Reminder = 6 and we are pushing Reminder on stack and then printing it in reverse order BCD to HEX 1 LOOP : DL = 06 ; RAX = RAX * RBX = 0 ; RAX = RAX + RDX = 06 2 LOOP : DL = 05 ; 60 = 06 * 10 ; 65 = 60 + 5 3 LOOP : DL = 05 ; 650 = 60 * 10 ; 655 = 650 + 5 4 LOOP : DL = 03 ; 6550 = 655 * 10 ; 6553 = 6550 + 3 5 LOOP : DL = 06 ; 65530 = 6553 * 10 ; 65535 = 65530 + 5 Hence final result is in EAX = 65535 which is 1111 1111 1111 1111 and when we print this it is represented as FFFF

3.9 Assignment Questions: 1. Explain various addressing modes of 8086 microprocessor used in this program. 2. Explain Different assembler directives used in this program. 3. Explain various Number Systems used in Digital Electronics. 4. What is HEX Number? Explain the steps to convert HEX No to BCD No 5. What is BCD Number? Explain the steps to convert BCD No to HEX No. 3.10 Oral Questions: 1. Explain the use of SI register in the program. 2. Explain the use of DI register in the program. 3. In above program which Procedure used. 4. Is there any difference between Rotate Bit & Shift Bit Instruction?