0% found this document useful (0 votes)
19 views

Project Report

Uploaded by

pirar89120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Project Report

Uploaded by

pirar89120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

1

Project Report

(Controlling a Robot with Emu8086)

Group 6:

Macharia, Sylvia Waithera 650694

Mendes, Isaac Kennedy 642726

Jethwa, Rahil Jagdish 649201

APT 2022 - Introduction to Assembly Programming

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

Figure 1 – program when run ................................................................................................................ 7

Figure 2 – robot stationary, Figure 3 – robot moves forward ............................................................... 7

Figure 4 – robot stationary, Figure 5 – robot turns left ......................................................................... 8

Figure 6 – robot stationary, Figure 7 – robot turns right....................................................................... 8

Figure 8 – lamp off , Figure 9 – robot switches lamp on ...................................................................... 9

Figure 10 – lamp on, Figure 11 – robot switches lamp off ................................................................... 9


4

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

robot are ports 9, 10 and 11.

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

hardware interrupts can be triggered by external peripheral devices and microcontrollers.

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:

1. To attain an in-depth understanding of assembly programming.

2. To create a program with maximum efficiency.

3. To design the program to enable the user to control the robot.


5

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

e) Switch lamp off

Apparatus

The apparatus that was used for the project was:

 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

the Appendix A for details of the code.

1. A component was written with code that starts the virtual device, in this case a robot.

2. A stack was created for the robot to use.

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

(Appendix B). The robot accepted a command if it was not busy.

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.

6. A procedure was written to instruct the robot to move forward.

7. A procedure was written to instruct the robot to turn left.

8. A procedure was written to instruct the robot to turn right.

9. A procedure was written to instruct the robot to switch on the lamp, if there is a switched-

off lamp in front of it.

10. A procedure was written to instruct the robot to switch off the lamp, if there is a

switched-on lamp in front of it.

Observations and results

Once the program was run, it waited for the user to enter a key as shown in figure 1 below.
7

Figure 1 – program when run

The program was then tested for the scenarios illustrated in the following sections.

Move the robot forward

As seen in figures 2 and 3 below, the robot moved forward when the user pressed the up arrow key.

Figure 2 – robot stationary Figure 3 – robot moves forward


8

Turn the robot left

As seen in figures 4 and 5 below, the robot made a 90 degree left turn when the user pressed the left

arrow key.

Figure 4 – robot stationary Figure 5 – robot turns left

Turn the robot right

As seen in figures 6 and 7 below, the robot made a 90 degree right turn when the user pressed the

right arrow key.

Figure 6 – robot stationary Figure 7 – robot turns right


9

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.

Figure 8 – lamp off Figure 9 – robot switches lamp on

Switch off a lamp

As seen in figures 10 and 11 above, the robot switched off the lamp when the user pressed the space

bar key.

Figure 10 – lamp on Figure 11 – robot switches lamp off


10

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

emu8086 was attained, creating a new program was fairly simple.

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

in the example in emu8086.

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

able to do anything else unless its source code is modified.


11

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

8086 assembler tutorial for beginners [PDF document]. Retrieved from

http://www.uobabylon.edu.iq/eprints/publication_1_26408_35.pdf

Assembly Language for x86 Processors. (2014). Upper Saddle River: Pearson Education Inc.

Documentation for emu8086 - assembler and microprocessor emulator [HTML document].

Retrieved from file:///C:/emu8086/documentation/index.html

X86 assembly language. (2018, March 31). Retrieved from Wikipedia:

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 ‘;’

provide a brief explanation of what that particular line of code does.

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.

#start=robot.exe# ; starts the robot virtual device

name "robot"

#make_bin#
#cs = 500#
#ds = 500#
#ss = 500# ; stack
#sp = ffff#
#ip = 0#

; c:\emu8086\devices\robot.exe uses ports 9, 10 and 11

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

the user stops the program.

eternal_loop:
call wait_robot ; call wait_robot procedure

mov al, 4 ; send signal to examine object in front of the robot


out r_port, al

call wait_exam ; call wait_exam procedure

in al, r_port + 1 ; get result from data register

mov ah, 0 ; get keystroke from user


int 16h

cmp ah, 48h ; compare value of keystroke to value of up arrow key


je forward ; if equal jump to forward

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

jmp last ; jump to last


15

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

in al, r_port + 1 ; get result from data register


cmp al, 7 ; compare to value for a switched on lamp(7)
jne lamp_off ; if not equal, jump to lamp_off

call switch_off_lamp
jmp last

lamp_off: ; lamp is switched off


call switch_on_lamp

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 proc ; procedure to check is robot is busy

busy: in al, r_port + 2 ; check status register if robot busy


test al, 00000010b
jnz busy ; busy, so wait; loop back to busy
ret

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

in the data register.

wait_exam proc ; procedure for robot to carry out examination

busy2: in al, r_port + 2 ; check data register for new data


test al, 00000001b
jz busy2 ; no new data, so wait. loop back to busy2
ret

wait_exam endp

Switch_off_lamp procedure

This procedure instructs the robot to switch off the lamp in front of it.

switch_off_lamp proc ; procedure to switch off the lamp

mov al, 6 ; send signal to robot to switch off lamp


out r_port, al
ret
17

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 proc ; procedure to switch on the lamp

mov al, 5 ; send signal to robot to switch on lamp


out r_port, al
ret

switch_on_lamp endp

Left_turn procedure

This procedure instructs the robot to make a 90 degree left turn.

left_turn proc

mov al, 2
out r_port, al ; send signal to robot to turn left
ret

left_turn endp

Right_turn procedure

This procedure instructs the robot to make a 90 degree left turn.


18

right_turn proc

mov al, 3
out r_port, al ; send signal to robot to turn right
ret

right_turn endp

Move_forward procedure

This procedure instructs the robot to move forward by one space/tile.

move_forward proc

mov al, 1 ; send signal to robot to move forward


out r_port, al
ret

move_forward endp
19

Appendix B

Command Register (port 9)

The following table displays the possible values set to port 9 to instruct the robot to perform the

specified task (8086 assembler tutorial for beginners, n.d).

Table 1

Decimal Binary
Action
value value

0 00000000 Do nothing.

1 00000001 Move forward.

2 00000010 Turn left.

3 00000011 Turn right.

Examine. Examines an object in front using sensor. When robot


4 00000100 completes the task, result is set to data register and bit #0 of status
register is set to 1.

5 00000101 Switch on a lamp.

6 00000110 Switch off a lamp.

Data Register (port 10)

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

Decimal value Binary value Meaning

255 11111111 wall

0 00000000 nothing

7 00000111 switched-on lamp

8 00001000 switched-off lamp

Status Register (port 11)

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

assembler tutorial for beginners, n.d).

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).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy