Practice questions: 8086 Assembly Language Programming

advertisement
Practice questions: 8086 Assembly Language
Programming
Dr. Wasim A. B.∗
Department of Computer Sciences
University of Kashmir
August 11, 2013
1
prologue
Architecture of 8086 microprocessor by Intel is simple yet elegant, old but
state-of-art design, apparently inevitable however innovative, and off-course
part of the curriculum. This architecture became the basis of next generation of microprocessors from Intel like 80286, 80386, and so on - hence the
name x86 Architecture. From a programmer’s point of view, the 8086 MPU
provides a rich instruction set to program it. Furthermore, the instruction
set of 8086 also became the basis for next generation of microprocessors from
Intel - hence the name ISA-x86. However, instead of re-inventing the wheel,
programmers prefer to use certain OS services to do I/O with devices like
keyboard, video card, storage subsystem, and so on.
In lieu of these arguments it becomes significantly important for a student to
understand the architecture of 8086 MPU and more importantly get his/her
hands dirty with its programming. This draft contains a set of problems for
newbies to kick-start their journey. The problems here aren’t too difficult
to solve as the motive is to get familiar with some common and important
aspects of 8086 ALP.
2
Assumptions
This draft assumes that students are familiar with Tasm assembler i.e. they
know how to assemble & link on Windows platform, how to use segment
∗
wab.cs@uok.edu.in
1
directives, how to use data directives, how to use directives to create procedures, macros, and so on.
Furthermore, the draft assumes that students are familiar with INT 21H
DOS interface to do I/O with keyboard, video and storage subsystem.
3
8086 programming
1. Write a program to get a string from a keyboard restricting keypresses
pertaining to vowels and print it back on screen.
2. Write a program to get a multi-digit number from the keyboard and
store the number in memory in its binary form. Please don’t make use
of stack.
3. Write a program to print on screen a multi-digit number stored in
binary form in memory. Please make use of stack.
4. Write a program to check whether a number inputted via keyboard
is Even or Odd. Please ensure that the program work for multi-digit
numbers.
5. Write a program to check whether an inputted string is palindrome or
not.
6. Write a program to create an array of 10 numbers, get it populated via
keyboard, and perform bubble-sort 1 over the array to sort it.
7. Write a program to create an array of 10 numbers, get it populated via
keyboard, and print all those numbers which are duplicated within the
array.
8. Write a program to create a procedure sum that takes two numbers
as arguments, does their summation and returns the result. Call this
procedure twice in your main program. Make sure to pass arguments
via registers.
9. Write a program to create a procedure sum that takes two numbers
as arguments, does their summation and returns the result. Call this
procedure twice in your main program. Make sure to pass arguments
via stack.
1
For bubble sort please check www.google.co.in/?q=bubble+sort
2
10. Write a program to create a macro sum that takes two numbers as
arguments and does their summation. Use this macro twice in your
main program.
11. Write a program to demonstrate the usage of include directive.
12. Write a program to open an existing file, display every 3rd character
from the file until EOF is encountered. Finally close the file.
13. Write a program to display the size of an existing file. Please don’t
make use of file-size function of int 21h.
14. Write a program to display what character is currently being displayed
on screen at location (2,2). {Hint: Video memory address starts at
B800:0000H and try this on Dos-Box}
4
epilogue
These problems should be attempted in the same sequence in which they
appear so that the redundancy of effort is reduced.
Thanks for reading & good luck with trying! 4
J¶·¸¹º»¼½¾J
3
Download