IMAGE PROCESSING

marsboleΤεχνίτη Νοημοσύνη και Ρομποτική

6 Νοε 2013 (πριν από 3 χρόνια και 8 μήνες)

71 εμφανίσεις


1




1.1
INTRODUCING
68K

EXPERIMENT
BOARDS


As you learned from lectures at class in the previous 3 weeks, we will
program Moto
rola 68000
(M68K) microprocessor during lab sessions. The low
-
level programming of M68K will be
generally
introduced during next f
ew weeks. It is important to note that the lab schedule will be a
co
ndensed

version of previous
-
year
first two
labs.

In
-
depth learning is
of
-
course
adherent to
personal efforts.

(DO ALL THE WORK YOURSELF)


We will use “KAYCOMP II, 68000 TRAINER SYSTEM” exp
eriment
boards
. E
ach

board
include many peripherals such as communication ports, externa
l memory, power unit, and others
in addition to a Motorola 68000 (M68K) microprocessor on it.


The
boards

have 27256x2 bytes of memory on each. (27256 upper
-
bytes on a
memory chip and
27256 lower
-
bytes on another memory chip)

But,
default user
-
code area in
this
memory dump is
starting from the address
$00400400
. Hence
, we will u
se this default
start
address for your
codes to
be
load and run. Be sure not to exceed 4K byte
s from this start address for your code to
run stable (in other words
,

fair
-
play area is from $00400400
to $0040
1400)
.


-

See References (end of this document) for the programs and instruction set.


1.1.1

Connecting sets to PCs






Powe
r
-
up your PC and als
o

power
-
up the
board

using the same adapter that is used for
MC11
. Then

connect the board to your PC via RS232 (female to female) connector cable.
Note

that the c
onnect
o
r cable s
hould be plugged into PORT A of
the
board
.




Open a hyper
-
t
erminal window and set
options
as 9600
-
8
-
N
-
1.




Push the reset button
(hold it
about 0.5 seconds
)
.

Then press “Enter” a few times.


PORT A

RESET BT.

EEM489
MICROPROCESSORS II


m68k
LAB 1


2



If everything is ok, a

screen display

of “
K>
” prompt on the HyperTerminal window
sh
ould occur
.

This means the communication i
s established. We are in!




Type “he” while the “K>” prompt occurs. This will show the list of commands avaiable.




The rest is similar to that of HC11. You can

-

Load s
-
file, using LT command;

-

Display the memory dump, using PR command;

-

Display the targe
t registers, using RD command;

and etc...




1.1.2 Loading S
-
files




Before loading an s
-
file, we should
generate

it
using assembly compiler.




Save your assembly code as a text file with extension ‘
ASM

, such as

m68klab1.asm
’.




Then, from a dos
-
console,
run assembly compiler directly using the filename without
extension.




currentdir:
\
> asm68k
.exe

m68klab1




T
he compiler will generate three files a HEX, a LST and an OBJ file

in the same folder of
the ASM file.

If an error is listed after running the compile
r, you can look it up from text
-
based LST file, and correct the code in ASM file. After re
-
compilation, if no errors
occurred, then your file to be loaded on the board is the HEX file.




You should load th
e no
-
error generated
HEX file using LT command.




Aft
er all, you can run the loaded code using GO command...



Next, we have some practical works to do. Go on...








3


1.2

BIT OPERATIONS


(
IMAGE PROCESSING
)



The program of this exercise deals with image processing and bit manipulation. The program
defines an

image of 16x16 pixels entered to the memory as a 16 consecutive words each of which
represent a 16
-
bit line of the image. The program also allocates empty storage for the results of
the image manipulations performed by the three subroutines. The overall p
rogram structure
should be as follows:


ORG

$0400400

;start program at this address

LAB
1



BSR

NEG


;call subroutine negative

BSR

USD


;call subroutine up side down

BSR

VSH


;call subroutine vertical shrink

TRAP

#11


;stop the program

DC.W

0


NE
G


... ...


;create the negative subroutine

USD


... ...


;create the up side down subroutine

VSH


... ...


;create the vertical shrink subrou
tine


ORG

$0400600 ;at this address, create an image

IMAGE

DC.W

$0000 ;................

DC.W

$0000 ;....
............

DC.W

$3FE0 ;..
11
1111111.....

DC.W

$3FF0 ;..1111111111....

DC.W

$3878 ;..111....1111...

DC.W

$3838 ;..111.....111...

DC.W

$3838 ;..111.....111...

DC.W

$3870 ;..111....111....

DC.W

$3FE0 ;..111111111.....

DC.W

$3FE0 ;..111111111.....

DC.
W

$3870 ;..111....111....

DC.W

$3870 ;..111....111....

DC.W

$3838 ;..111.....111...

DC.W

$3838 ;..111.....111...

DC.W

$0000 ;................

DC.W

$0000 ;................

DC.L

$C
0
C
0
C
0
C
0

;a marker at the end of image


ORG

$0400700 ;at this address

I
M
NEG

DS.W

16 ;allocate space for negative image

DC.L

$C4C4C4C4 ;a marker at the end of neg. image


ORG

$0400800 ;at this address

IM
USD

DS.W

16 ;allocate for up side down image

DC.L

$C8C8C8C8 ;a marker at the end of image


ORG

$0400900 ;at this addr
ess

IM
VSH

DS.W

16 ;allocate space for shrunk image

DC.L

$CCCCCCCC ;a marker at the end of image



4

STEP 1:

Complete the above 68000 assembly language program by creating the three subroutines.




The
NEG
subroutine computes the negative form of the origin
al image and stores it in the
allocated space.
Result will be as following:


IMNEG

DC.W

$ffff ;1111111111111111

DC.W

$ffff ;1111111111111111

DC.W

$c01f ;11.........11111

DC.W

$c00f

;11..........1111



DC.W

$c787 ;11...1111....111

...

...

DC.W

$c7c7 ;
11...11111...111

DC.W

$c7c7 ;11...11111...111

DC.W

$0000 ;1111111111111111

DC.W

$0000 ;1111111111111111

DC.L

$C4C4C4C4 ;a marker at the end of neg. image




The
USD
subroutine flips the original image up side down and stores it in the allocated
space.
Re
sult will be as following:


IM
USD


DC.W

$0000 ;................

DC.W

$0000 ;................

DC.W

$3838 ;..111.....111...

DC.W

$3838 ;..111.....111...

DC.W

$3870 ;..111....111....

DC.W

$3870 ;..111....111....

...

...

DC.W

$3838 ;..111.....111...

DC.
W

$3878 ;..111....1111...

DC.W

$3FF0 ;..1111111111....

DC.W

$3FE0 ;..111111111.....

DC.W

$0000 ;................

DC.W

$0000 ;................

DC.L

$C8C8C8C8 ;a marker at the end of image




The
VSH
subroutine vertically shrinks the original image from
16 to 8 pixels. The
algorithm is that the two vertical bits are OR

ed to make one bit.

Result will be as
following:


IM
VSH

DC.W

$0000 ;................

DC.W

$3FE0 ;..111111111.....

DC.W

$3878 ;..111....1111...

DC.W

$3838 ;..111.....111...

DC.W

$3FE0 ;
..111111111.....

DC.W

$3870 ;..111....111....

DC.W

$3838 ;..111.....111...

DC.W

$0000 ;................

DC.L

$CCCCCCCC ;a marker at the end of image



5

STEP 2:

Create a new subroutine
(FRM)
which adds a frame to the original image. The frame is
formed b
y making the most outer surrounding bits of the original image all 1’s.

Result
will be as following:



IMFRM

DC.W

$ffff ;1111111111111111

DC.W

$8001 ;1..............1

DC.W

$bFE1 ;1.111111111....1

DC.W

$bFF1 ;1.1111111111...1

DC.W

$b879 ;1.111....
1111..1

...

...

DC.W

$b871 ;1.111....111...1

DC.W

$b839 ;1.111.....111..1

DC.W

$b839 ;1.111.....111..1

DC.W

$8001 ;1..............1

DC.W

$ffff ;1111111111111111

DC.L

$D0D0D0D0D0 ;a marker at the end of image


STEP 3
:

Write a new subroutine

(TRP)

tha
t transposes an image

(rotate image 90
o

anti
-
clockwise)
.



1.
3

LOGIC OPERATIONS & SHIFT COMMANDS

(ADVANCED)



In a program dealing with numbers longer than word
-
length (16 bits), you will probably need to
extend the functions of some instructions. You must

be familiar to this approach from the
Microprocessors I course.


1.2.1 Extension of shift instructions



Consider a 64
-
bit number located
anywhere

in the memory (this means the address of number
will be an input argument to the subroutine, maybe in an
address register). Implement;

I.

A subroutine to rotate a 64
-
bit number left (Extension of ROL)

II.

A subroutine to arithmetic shift right a 64
-
bit number (Extension of ASR)

III.

A subroutine to logical shift left a 64
-
bit number (Extension of LSL)

IV.

A subroutine to rot
ate a 64
-
bit number to right through X
-
bit (Extension of ROXR)



Take Care:

The X and C bits of the CCR must be updated accordingly at the end of the whole
operation.

For the details of the basic shift operations, you can refer to the document (shift.pdf)
attached to the manual.

By completing this part of the experiment, you will be desired to be capable of
commenting on the X
-
bit of the CCR and its difference from the C
-
bit.




6

LAB
G
R
ADI
NGS

(Take a printout of this page for your TA to grade your work)
:



S
TUDENT NAME:


55% BIT OPERATIONS (IMAGE PROCESSING)


10% NEG,




10% VSH,




10% USD,




10% FRM,




15% TRP



45% LOGIC OPERATIONS & SHIFT COMMANDS (ADVANCED)



10% EROL,




10% EASR,




10% ELSL,




15% EROXR














TA:
Şükrü Görgülü


Ana
dolu University, Department of Electrical Engineering,
2007
-
10
-
16