Project Report
Project Report
Project Report
Group 6:
Dr Sylvester Namuye
USIU-A
Spring 2018
02/04/2018
2
Abstract
The project was set out to create a controlled robot using assembly (emu8086) that would respond to
various inputs made by the user. In order for our project to be a success, our objective was to get an
in-depth understanding of the programming language as well as create a programmed robot that
moves upon input from the user using the keyboard. This involved creation of code that would be
able to start the robot, virtual device. Memory was allocated for the program to run and made use of
loops, procedures and conditional jumps and labels that would instruct the robot to turn left, right,
move forward and switch on or off lamps. The program waited for input from the user and it was
found out that when the user keyed in an input from the keyboard the robot responded as we
intended in the program. That is, either moved forward, turned left or right or switch the lamps on or
off.
3
Table of Contents
Abstract ................................................................................................................................................. 2
Introduction ........................................................................................................................................... 4
Objectives.............................................................................................................................................. 4
Apparatus .............................................................................................................................................. 5
Procedure .............................................................................................................................................. 5
Observations and results ....................................................................................................................... 6
Move the robot forward .................................................................................................................... 7
Turn the robot left ............................................................................................................................. 8
Turn the robot right ........................................................................................................................... 8
Switch on a lamp ............................................................................................................................... 9
Switch off a lamp .............................................................................................................................. 9
Discussion ........................................................................................................................................... 10
Limitation ............................................................................................................................................ 10
Conclusion .......................................................................................................................................... 11
References ........................................................................................................................................... 12
Appendix A ......................................................................................................................................... 13
Appendix B ......................................................................................................................................... 19
Table of Figures
Introduction
A robot is a virtual mechanical creature that can be controlled by sending data to input/output port 9.
Controlling the robot requires a complex algorithm to be used to achieve maximum efficiency.
Emulator supports user-created virtual devices that can be accessed from assembly language
program using in and out instructions. Some of the input/output ports used to control the virtual
The port 9 is the command register upon which setting values to this port will make the robot
perform a specific task as per instructed in the code. The second port which is port 10 is the data
register, this register is set after the robot completes the examine command as instructed in the
program. The third port, port 11 is a status register which determines the state of the robot. External
Therefore this experiment was set out to create a controlled robot that ran as a virtual device in
emu8086 and that could execute instructions from inputs made by the user.
Objectives
The project had the following objectives:
4. To instruct the robot to perform one of the following tasks, depending on the key entered
by the user:
a) Move forward
b) Turn right
c) Turn left
d) Switch lamp on
Apparatus
emu8086 emulator.
Procedure
Using the example given on the robot in the emu8086 emulator, a thorough understanding of the
virtual device was attained. The following steps were then followed to create the program. Refer to
1. A component was written with code that starts the virtual device, in this case a robot.
3. In the main section of the program, an eternal loop was created that included asking the
user for a keystroke input, calls to other procedures and conditional jumps to labels.
6
4. A procedure was created to check whether the robot was busy or not using port 11
5. A procedure was created to check whether the robot whether the robot found anything in
front of it using port 10 (Appendix B). The robot returned if it found something new.
9. A procedure was written to instruct the robot to switch on the lamp, if there is a switched-
10. A procedure was written to instruct the robot to switch off the lamp, if there is a
Once the program was run, it waited for the user to enter a key as shown in figure 1 below.
7
The program was then tested for the scenarios illustrated in the following sections.
As seen in figures 2 and 3 below, the robot moved forward when the user pressed the up arrow key.
As seen in figures 4 and 5 below, the robot made a 90 degree left turn when the user pressed the left
arrow key.
As seen in figures 6 and 7 below, the robot made a 90 degree right turn when the user pressed the
Switch on a lamp
As seen in figures 8 and 9 above, the robot switched on the lamp when the user pressed the space bar
key.
As seen in figures 10 and 11 above, the robot switched off the lamp when the user pressed the space
bar key.
Discussion
The project was deemed a success as it enabled a user to control the robot manually. This was done
by pressing either the up arrow key, left arrow key, right arrow key or the spacebar key. The arrow
keys are for movement of the robot (move forward, left turn, right turn), while the spacebar key is to
switch the lamp on/off. Once a substantial understanding of the example for the robot given in
Separate procedures for each operation were created for the robot as previously mentioned. These
were called once the program determined which key the user had pressed. This made the robot
perform a certain task, as opposed to random turns and tasks automatically carried out by the robot
Limitation
The challenge faced by the group in this project was attaining an understanding of how a virtual
device, in this specific case a robot, functions. The group learned that, apart from movement
(moving forward, turning left and turning right) and switching the lamps on/off, the robot was not
Conclusion
This project demonstrates that a virtual robot that can be controlled manually in emu8086. The
source code of the virtual robot can be modified to include other functionality specific to the
program being created. The project also suggests that assembly language can be used in the
development of physical robots for various tasks, which can be implemented in numerous sectors,
for example controlling robotic arms for surgical purposes in the medical industry.
12
References
http://www.uobabylon.edu.iq/eprints/publication_1_26408_35.pdf
Assembly Language for x86 Processors. (2014). Upper Saddle River: Pearson Education Inc.
https://en.wikipedia.org/wiki/X86_assembly_language
13
Appendix A
Program Code
The following are segments of code, each for a specific function. The comments, preceded with a ‘;’
Initialling the Robot and creating the stack for the Robot.
The following code segment initialized the robot in emu8086 and creates a stack for its operations.
; group 6 project
; This code allows the user to move the robot.
; The user can use the robot to switch the lamps on and off.
name "robot"
#make_bin#
#cs = 500#
#ds = 500#
#ss = 500# ; stack
#sp = ffff#
#ip = 0#
r_port equ 9 ; give value of robot base i/o port(9) to constant r_port
14
Eternal Loop
The following code segment is the eternal loop which keeps repeating once the program is run until
eternal_loop:
call wait_robot ; call wait_robot procedure
cmp ah, 4Bh ; compare value of keystroke to value of left arrow key
je left ; if equal jump to left
cmp ah, 4Dh ; compare value of keystroke to value of right arrow key
je right ; if equal jump to right
cmp al, 32d ; compare value of keystroke to value of space bar key
je switch ; if equal jump to switch
forward:
call move_forward
jmp last
left:
call left_turn
jmp last
right:
call right_turn
jmp last
switch:
call wait_exam ; call wait_exam procedure
call switch_off_lamp
jmp last
last:
jmp eternal_loop ; loop back to the start
Wait_robot procedure
This procedure checks whether the robot is busy or not from the status register. It only returns once
the robot is not busy, so that it can receive the next command.
16
wait_robot endp
Wait_exam procedure
This procedure examines if there is anything in front of the robot. It returns when there is new data
wait_exam endp
Switch_off_lamp procedure
This procedure instructs the robot to switch off the lamp in front of it.
switch_off_lamp endp
Switch_on_lamp procedure
This procedure instructs the robot to switch on the lamp in front of it.
switch_on_lamp endp
Left_turn procedure
left_turn proc
mov al, 2
out r_port, al ; send signal to robot to turn left
ret
left_turn endp
Right_turn procedure
right_turn proc
mov al, 3
out r_port, al ; send signal to robot to turn right
ret
right_turn endp
Move_forward procedure
move_forward proc
move_forward endp
19
Appendix B
The following table displays the possible values set to port 9 to instruct the robot to perform the
Table 1
Decimal Binary
Action
value value
0 00000000 Do nothing.
This register is set after robot completes the examine command. The following table displays the
possible values in the data register (8086 assembler tutorial for beginners, n.d).
20
Table 2
0 00000000 nothing
The values present in this register is read to determine the state of the robot, where each bit has a
specific property. The following table displays the bit number and what its bit value represents (8086
Table 3
Bit
Description
number
Zero when there is no new data in data register, one when there is new data in data
bit #0
register.
Zero when robot is ready for next command, one when robot is busy doing some
bit #1
task.
Zero when there is no error on last command execution, one when there is an error
bit #2 on command execution (when robot cannot complete the task: move, turn, examine,
switch lamp on/off).