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

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

Experiment 3 3 Basic Input Output

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

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

EC 333 Microprocessor and Interfacing Techniques (3+1)

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

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

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

Intel 8086: Instruction Set

PESIT Bangalore South Campus

BLDEA S V.P. DR. P.G. HALAKATTI COLLEGE OF ENGINEERING & TECHNOLOGY, VIJAYAPURA

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

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

UNIT 4. Modular Programming

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.

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

CS-202 Microprocessor and Assembly Language

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

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

ELEC VIDEO BIOS ROUTINES

COMPUTER ENGINEERING DEPARTMENT

ADVANCE MICROPROCESSOR & INTERFACING

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

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Chapter 3: Addressing Modes

FACULTY OF ENGINEERING LAB SHEET

8086 INSTRUCTION SET

Assignment no:4 on chapter no :3 : Instruction set of 8086

Arithmetic and Logic Instructions And Programs

MOV CX,80 MOV CX,100. For example, MOV DI, OFFSET TEXT_STRING ;DI points to the TEXT_STRING in the extra segment ; Byte to be scanned in AL

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

Arithmetic Instructions

Computer Architecture and System Software Lecture 07: Assembly Language Programming

Computer Architecture and System Software Lecture 06: Assembly Language Programming

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

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

UNIVERSITY OF CALIFORNIA, RIVERSIDE

EEM336 Microprocessors I. Data Movement Instructions

Week /8086 Microprocessor Programming II

Code segment Stack segment

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

FACULTY OF ENGINEERING LAB SHEET

Signed number Arithmetic. Negative number is represented as

Lecture (08) x86 programming 7

EC-333 Microprocessor and Interfacing Techniques

LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS

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

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

Experiment #2. Addressing Modes and Data Transfer using TASM

Submitted To. Submitted By. Department Of Computer Science And Engineering. Dr. Md. Rabiul Islam. Name: Ashadullah Shawon.

Programming in Assembler. Laboratory manual. Exercise 3

Week /8086 Microprocessor Programming I

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

16.317: Microprocessor Systems Design I Fall 2013

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

Programs for Assembly Language Programming

COMPUTER ENGINEERING DEPARTMENT

Lecture (09) x86 programming 8

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

Summer 2003 Lecture 4 06/14/03

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

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Electronics and Communication

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

PESIT Bangalore South Campus

1-Operand instruction types 1 INC/ DEC/ NOT/NEG R/M. 2 PUSH/ POP R16/M16/SR/F 2 x ( ) = 74 opcodes 3 MUL/ IMUL/ DIV/ DIV R/M

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

Instructions moving data

Week /8086 Microprocessor Programming

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

9/25/ Software & Hardware Architecture

Experiment 8 8 Subroutine Handling Instructions and Macros

8086 programming Control Flow Instructions and Program Structures

CSCI516: Program 1 - October 11, 2010 The Program is due: October 25, 2010 in the beginning of the class

Lecture (06) x86 programming 5

A4 Sample Solution Ch3

X86 Addressing Modes Chapter 3" Review: Instructions to Recognize"

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

16.317: Microprocessor Systems Design I Spring 2014

Lecture 9. INC and DEC. INC/DEC Examples ADD. Arithmetic Operations Overflow Multiply and Divide

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

if 2 16bit operands multiplied the result will be

IBM PC Hardware CPU 8088, Pentium... ALU (Arithmetic and Logic Unit) Registers. CU (Control Unit) IP.

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

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

EEM336 Microprocessors I. Addressing Modes

3: 4: 5: 9: ',0 10: ',0 11: ',0 12: 13:.CODE 14: INCLUDE

LABORATORY WORK NO. 8 WORKING WITH MACROS AND LIBRARIES

Overview: 1. Overview: 2

Babu Madhav Institute of Information Technology, UTU

Lesson 1. Fundamentals of assembly language

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

ORG ; TWO. Assembly Language Programming

Q1: Multiple choice / 20 Q2: Protected mode memory accesses

WINTER 12 EXAMINATION Subject Code : Model Answer Page No : / N. a) Describe the function of SID and SOD pins of 8085 microprocessor

ELEC 242 Time Delay Procedure

8086 ALP TOOLS (CH 2) CHAPTER 2

Basic Assembly SYSC-3006

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

Assignment 3. Problem Definition:

8088/8086 Programming Integer Instructions and Computations

Transcription:

Problem : Programming in Assembly [ Points] The following assembly program is supposed to: receive three integer numbers from the console, call a function, name sort, function sort arranges the three input numbers in non-decreasing order, then, the program should print the resulting list and ends. Note. Function sort takes three integers as input. Example: if the program receives 0 as input, it should print 0. Five parts of the program have been replaced with five empty boxes; and, in each box, you need to write ONE complete instruction (not more or less) such that the program works properly..model large.stack 0h.data msg db "This program receives integer numbers and sorts them in decreasing order.$" msg db "Enter the first number (00-): $" msg db "Enter the second number (00-): $" msg db "Enter the third number (00-): $" msg db "The sorted numbers are: $" cr db 0dh, 0ah, '$' n dw? n dw? n dw? array db dup (?) decimal_ db dup (?) decimal_ db dup (?) decimal_ db dup (?).code.startup mov ax, @data mov ds, ax ;set segment registers lea dx, msg ;print message mov ah, lea dx, cr ;carriage return and newline lea dx,msg lea dx, msg ;print message "Enter the first number: " mov bx, offset n call storenumber mov ah, lea dx, cr ;carriage return and newline lea dx, msg ;print message "Enter the second number: " mov bx, offset n call storenumber Page /8

mov ah, lea dx, cr ;carriage return and newline lea dx, msg ;print message "Enter the third number: " mov bx, offset n call storenumber mov ah, lea dx, cr ;carriage return and newline lea dx, msg ;print message "The sorted numbers are: " mov dx, offset n mov di, offset n mov si, offset n mov ax, n mov bx, n mov cx, n call sort mov ax, n mov bx, offset decimal_ call convert call print mov ax, n mov bx, offset decimal_ call convert call print mov ax, n mov bx, offset decimal_ call convert call print FIN: mov ax, c00h.exit ;call sort procedure ;load ax with the value of n ;load bx with the address of decimal_ array ;call convert to decimal procedure ;call print procedure ;load ax with the value of n ;load bx with the address of decimal_ array ;call convert to decimal procedure ;call print procedure ;load ax with the value of n ;load bx with the address of decimal_ array ;call convert to decimal procedure ;call print procedure ;exit to operating system print proc near ;this procedure prints the numbers mov di, ;load di with for indexing mov cx, ;load the counter with AGAIN: dec di ;decrement di mov ah, ;load ah with for display mov dl, [bx+di] ;load dl with the value of array[bx+di] add dl,0h ;display value on console loop AGAIN ;repeat until the counter reaches 0 mov dl, 0h ret print endp ;load dl with the ASCII value for space ;display a space ;return to caller ;end procedure Page /8

convert proc near ;This procedure converts the hex numbers ;to decimal and stores them in an array mov si, ;load si with the value for dividing mov di, 0 ;load di with 0 for indexing mov cx, ;load the counter with the value L: mov dx, 0 ;load dx with 0 for dividing -bit number div si ;divide dx-ax by si mov [bx+di], dx mov [bx+di], dx ;load the array with the remainder inc di ;increment di to address next element loop L ;repeat until cx reaches 0 ret ;return to caller convert endp ;end procedure storenumber proc near ;This procedure receives the numbers from the user mov di, 0 ;load di with 0 for indexing mov ah, ;load ah with for receiving input READ: ;receive the number and store in al sub al, 0h ;add 0h to the value to convert to ASCII mov array[di], al ;store the value in array[di] inc di ;increment di to address next element cmp di, ;compare di with jb READ ;if below jump to READ mov di, 0 ;set di to 0 for indexing mov ax, 0 ;set ax to 0 mov al, array[di] ;load al with the first digit mov cx, ;load cx with mul cl ;multiply al by mov dx, ax ;store the result in dx mov ax, 0 ;load ax with 0 inc di ;increment di to address next digit mov al, array[di] ;load al with the second digit add dx, ax ;add the second digit to the first mov [bx], dx ;Store in the contents of variable ret ;addressed by bx. ;return to caller storenumber endp ;end procedure sort proc far cmp bx, ax jl LABEL_ cmp cx, bx jl LABEL_ jmp FINISH LABEL_: xchg bx, ax cmp cx, bx ;This procedure sorts the numbers in ascending order. ;compare second number to the first number ;if the second value is lower, jump to LABEL_ ;compare the third value with the second value ;if the third is lower, jump to LABEL_ ;numbers are sorted, jump to FINISH ;exchange the second number with the first ;compare the third number with the second Jl LABEL_ jl LABEL_ jmp FINISH ;the numbers are sorted, jump to FINISH LABEL_: xchg cx, bx ;exchange the third value with the second Page /8

cmp bx, ax ;compare the second value with the third jg FINISH ;if the second value is greater, jump to FINISH xchg bx, ax FINISH: mov n, ax mov n, bx mov n, cx ret sort endp ;exchange the second and first values ;The numbers are sorted ;store the lesser value in n ;store the middle value in n ;store the greater value in n ;return to caller ;end procedure end Page /8

Problem : Design Questions Modify/complete the following figure to select memory address for address range 0F800H-0FFFFH. [ Points] A0--A D0--D U NMCCB A RD A A A A A U ALS 8 0 8 A0 A A A A A A A A8 A A OE CE VPP O0 O O O O O O O A A8 A IO/M UD ALS0 8 Page /8

Problem : Design Questions (continued) a) Without using an inverter gate, modify/complete the following figure to select memory address for address range B0000H-BFFFFH. [ Points] A A A A A A8 A b) What is the memory address range of the th EPROM (the one that is shaded) of above figure? [ Points] BA000H BBFFFH Page /8

Problem : Design Questions (continued) a) Modify/complete the following figure to select memory address for address range 0000H-FFFH. [ Points] D0 -- D A0 -- A U AT U AT U AT A8 #RD A A A A IO/M U A B C G GA GB HCT8 Y0 Y Y Y Y Y Y Y 8 0 8 A0 A A A A A A A A8 A A A A A A OE CE VPP O0 O O O O O O O 8 8 0 8 A0 A A A A A A A A8 A A A A A A OE CE VPP A O0 O O O O O O O 8 8 0 8 A0 A A A A A A A A8 A A A A A A OE CE VPP O0 O O O O O O O 8 b) What is the memory address range of the nd EPROM (the one in the middle) of above figure? [ Points] 8000H FFFFH Page /8

Problem : Short Answer Questions: [ Points] Note: some instruction may not be correct. a) What time is usually used to debounce a keyboard? -0 ms b) Where is the I/O port number stored for a variable I/O instruction? Register DX c) To which register are data input by the bit IN instruction? Register AX d) Which type of JMP instruction assembles if the distance is 00H bytes? Near e) What happens if the.while 0 instruction is placed in a program? Nothing f) How much memory is found in the DOS transient program area? 0 KB g) Which interrupts are available to users? to Page 8/8