You are on page 1of 5

FACULTY OF INFORMATION TECHNOLOGY

BACHELOR OF COMPUTER SCIENCE


END OF SEMESTER EXAMINATION
ICS 3203: ASSEMBLY LANGUAGE PROGRAMMING
DATE: 21ST JANUARY, 2022 TIME: 2 Hours
INSTRUCTIONS:
i. This paper contains FIVE questions.
ii. You are required to answer THREE questions, that is, QUESTION ONE which is
COMPULSORY and any other TWO questions.
iii. All questions carry equal marks i.e. 20 MARKS each.
QUESTION ONE (20 MARKS)
Assembly Language Gains in Popularity
Programming in assembly language -- getting down to the direct manipulation of bytes and even
bits -- is gaining in popularity, according the latest ranking by TIOBE, apparently spurred by the
Internet of Things (IoT).
The TIOBE Index for July 2016 reports that assembly has cracked its list of the top 10 most popular
programming languages, after an absence of undetermined length.
While not referencing the IoT by name, TIOBE indicated the growth of billions of small-footprint
connected devices around the globe is the probable cause of the increased popularity.
"Why would anyone write code at such a low level, being far less productive if compared to using
any other programming language and being vulnerable to all kinds of programming mistakes?"
TIOBE said in a recent post. "The only reasonable explanation for this is that the number of very
small devices that are only able to run assembly code is increasing. Even your tooth brush or coffee
machine are running assembly code nowadays."
One other possible explanation, TIOBE said, is performance. While C and C++ are often cited for
their close-to-the-metal functionality that enables developers to eke out every last bit of speed,
assembly takes that to a whole new level, literally.
Assembly, or asm, features "a very strong (generally one-to-one) correspondence between the
language and the architecture's machine code instructions," according to Wikipedia. "Today
assembly language is still used for direct hardware manipulation, access to specialized processor
instructions, or to address critical performance issues. Typical uses are device drivers, low-level
embedded systems, and real-time systems."
Those "critical performance issues" are another possible driver of assembly's ascendance, TIOBE
said. "If performance is key, nobody can beat assembly code," it said in the July ranking post.
Along with the TIOBE index, the re-emergence of assembly has been noted elsewhere, such as a
Hacker News post just published 10 days ago.

1
"It's kind of weird, my day job is writing high-level code in a Clojure Web app, but I'm drawn to
low-level languages, e.g. I like writing C code in my free time," reads the post from "sdegutis."
"Lately I've been really interested in learning assembly. (And from the posts on HN lately, it seems
I'm not the only one.)"
Assembly was also in the news recently when the "Original Apollo 11 Guidance Computer (AGC)
source code for the command and lunar modules" -- written in assembly -- was posted to GitHub.
While assembly cracked the top 10, Objective-C fell out, as it continues to be supplanted by Swift
as Apple's official go-to programming language for iOS apps.
Other index movements of note include big jumps for Tcl, CFML (ColdFusion) and Maple, though
they remained far down the list.

a) With reference to the above cases, briefly discuss whether the author is right in his
statement. (4 marks)

b) List describe any four types of sensors that can be used with an 8086 processor based
microcontroller according to the above case. (4 marks)

c) Based on the above case develop a proposal on an IoT microcontroller based idea which
the education and health sectors can embrace to help with the implementation of the
containment measures and reduce infection rate in the current technology era.
(6 marks)

d) Assuming the output in the system above is a motor to be controlled by the four sensors,
implement it in hardware and software form (using 8086 assembly language) explaining
what it possibly does. (6 marks)

QUESTION TWO (20 MARKS)


a) Draw and describe the diagram representing a simplified processor logic of the AVR
processor. (4 marks)

b) Develop a 20-bit control word structure that can be used to manage the AVR processor.
(4 marks)

c) Assuming the AVR processor is to be used in a washing machine, propose an instruction


set that can be used to run it. (4 marks)

d) Based on the instruction set in d) above, write a program to implement one of the most
commonly used functions of the washing machine. (4 Marks)

e) Explain the other applications of the AVR processor. (4 Marks)

2
QUESTION THREE (20 MARKS)
a) Identify and describe the system represented by Fig. Q3a. (4 marks)

START

Delay 10sec

Red

Delay 10sec

Delay 10sec
Amber

Delay 10sec

Green

NO Program
Closed?

YES

END

Fig. Q3a

b) Write 8086 Assembly Program for the system in a) above. Remember to include comments
and state any assumptions made. (10 marks)

c) With appropriate examples, explain how the ‘for loop’ can be implemented in the 8086
assembly language programming. (6 marks)

QUESTION FOUR (20 MARKS)


a) Write 8086 assembly language program to add the following 16-bit numbers: 277DH and
46AEH. The data segment begins at memory location 1304H while the code segment starts
from memory location 1200H. (6 marks)

b)Explain what is achieved by the following assembly language programming statements:


(4 marks)
i. CMP AL, BL;
ii. DEC AL;
iii. LEA SI, OUTPUT;
iv. XCHG AX, DX;
c) Write assembly language instructions for each of the following comments. (4 marks)

; indicate start of code segment


; Load the 8-bit data 02AH to register AX

3
; Load the 16-bit data 008EH to register AX
; Initialize count register CX to 8-bit value of 05H
; Transfer content of register AX to SI
; Transfer content of register BX to DI
; Transfer content of register CX to BP
; end of file

d) The following is a sample assembly language program. Re-write the program together with
a loop and insert comments to explain what each line achieves. (6 marks)

data DB 45
op1 DB 6
start:
MOV DL, 0H
MOV CL, op1
MOV AL, data
step:
CMP AL, op1
JC label1
SUB AL, op1 ;
INC DL
JMP step
label1:
MOV AH, DL
HLT

QUESTION FIVE (20 MARKS)


a) Write an 8086 assembly program to subtract two numbers and display the result in decimal.
Your program should include direct, register and immediate addressing modes.
(4 Marks)

b) Write an 8086 assembly program to divide a decimal number by 8 using the shift
instruction. (2 Marks)

c) Suppose in C++ Q = R+S where Q, R and S are 16-bit variables. (4 Marks)


i. Assuming Q, R and S represent memory locations, show how the operation can be
implemented using 8086 assembly language.
ii. Repeat for Q = T*(R+S); where T is a constant = 250.

d) Fig. Q5 d) shows a section of Intel 8086 microprocessor architecture. Discuss how it may
be useful in assembly language program required to add two 16 bit numbers 2345H and
8888H and store the result in memory. Assume that the two numbers are also stored in
memory. State any other assumptions made. (10 Marks)

4
Fig.Q5 d) 8086 Architecture

You might also like