Top Banner
Name: Date: 18 April 2014 Number: EENG410/INFE410 - MICROPROCESSORS I Midterm Exam Instructor: Dr. Hasan Demirel Read the Following Instructions Carefully: 1. The duration of the exam is 90 minutes. No extra time will be given. 2. Answer each question to a separate sheet on your answers booklet. Q U E S T I O N S ----------------------------------------------------------------------------------------------------------------------------------------- 1. (%20) What will be the values of the specified registers and flags after the execution of the following instructions? a) MOV CX,0604H MOV AX,0A98H SHL AH,CL ADD CX,AX b) MOV AX,8F0AH MUL AL SUB AH,AL ADC AX,AX AX=?, CX=?, CF=?, PF=?, AF=?, SF=?, ZF=? AX=?, CF=?, PF=?, AF=?, SF=?, ZF=? ----------------------------------------------------------------------------------------------------------------------------------------- 2. (%13) Write the definition of a subroutine that swaps the first and the last members of an array of 10 double-words. Note that the array is pointed by SI. (%12) (b) Write the definition of another subroutine, which multiplies the least significant nibble and the most significant nibble of AX register. The result is to be saved into AL. ----------------------------------------------------------------------------------------------------------------------------------------- 3. (%25) Given the definition of the following data segment, where A and B are ASCII numbers. .DATA A DB ‘28’ B DB ‘54’ ORG 0100H C DB ? Write the required code segment that converts these ASCII numbers to packed BCD and add them up to calculate sum in pack BCD form. Save the result in variable C. Hint: The resulting BCD number is assumed to be a byte. ------------------------------------------------------------------------------------------------------------------------------ 1 2 3 4 T
6

Name: Date: 18 April 2014 3 4 T EENG410/INFE410 ...faraday.ee.emu.edu.tr/eeng410/S13-14-MT-SOL.pdfName: Date: 18 April 2014 Number: EENG410/INFE410 - MICROPROCESSORS I Midterm Exam

Jul 15, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Name: Date: 18 April 2014 3 4 T EENG410/INFE410 ...faraday.ee.emu.edu.tr/eeng410/S13-14-MT-SOL.pdfName: Date: 18 April 2014 Number: EENG410/INFE410 - MICROPROCESSORS I Midterm Exam

Name Date 18 April 2014

Number

EENG410INFE410 - MICROPROCESSORS I

Midterm Exam

Instructor Dr Hasan Demirel

Read the Following Instructions Carefully

1 The duration of the exam is 90 minutes No extra time will be given

2 Answer each question to a separate sheet on your answers booklet

Q U E S T I O N S -----------------------------------------------------------------------------------------------------------------------------------------

1 (20) What will be the values of the specified registers and flags after the execution of the following instructions

a) MOV CX0604H

MOV AX0A98H

SHL AHCL

ADD CXAX

b) MOV AX8F0AH

MUL AL

SUB AHAL

ADC AXAX

AX= CX=

CF= PF= AF= SF= ZF=

AX=

CF= PF= AF= SF= ZF=

-----------------------------------------------------------------------------------------------------------------------------------------

2 (13) Write the definition of a subroutine that swaps the first and the last members of an array

of 10 double-words Note that the array is pointed by SI (12) (b) Write the definition of another subroutine which multiplies the least significant nibble and the most significant nibble of AX register The result is to be saved into AL

-----------------------------------------------------------------------------------------------------------------------------------------

3 (25) Given the definition of the following data segment where A and B are ASCII numbers

DATA

A DB lsquo28rsquo

B DB lsquo54rsquo

ORG 0100H

C DB

Write the required code segment that converts these ASCII numbers to packed BCD and add them up to calculate sum in pack BCD form Save the result in variable C

Hint The resulting BCD number is assumed to be a byte

------------------------------------------------------------------------------------------------------------------------------

1

2

3

4

T

------------------------------------------------------------------------------------------------------------------------------ 4 (30) Write an assembly language program that will process the following sentence as

follows

a) Convert the first letter of each word to upper-case b) Count and save the number of words in the sentence c) Count and save the number of alpha characters (letters) in the sentence

Consider the following sentence in your program ldquoeastern mediterranean university was established in 1979rdquo

The program should be general and work for any sentence ending with a full stop lsquorsquo character

Hint Uppercase characters are ordered between lsquoArsquo (41H) and lsquoZrsquo (5AH) and lowercase characters are ordered between lsquoarsquo (61H) and lsquozrsquo (7AH) in the in the ASCII Code table For lowercase letters bit 5 (d5) of the ASCII code is 1 where for uppercase letters it is 0 For example

Letter Binary ASCII

lsquohrsquo 01101000 68H

lsquoHrsquo 01001000 48H

-----------------------------------------------------------------------------------------------------------------------------------------

~OJ ()( I 060 Lot --

~O-J A ~ lOA iH

5~L A~~L- A~Aol4 I

A CO Dlt I Ar)lt o ~ r -

1 09b I D I 0 0000 l 00 l l ~ 0 0 ~ lt) 6 01- ~ 0000 D lOb COC e 0 ltI

J A 6 cr c () ) () I 0 0 0 L1 0 0 I I I cgt 0

tA)( AOCH ) C)( ~ A 69 c H1 [fF - ltgt Iff ll A(- Cgt II SF- ) ~r- - 0] (]gt

A- AY- =- OA ~ oA 006 t 4 ) A X ee6 Lt l- I

A I I A Lmiddot A - -=- b 0 - 6 Lt -- 1 c -l ) A j q C 6 1 r J

I

b4~ob OOD - ~OO IOl~

1 00 CQ - ltH

cr-=- 0

C r--- r-r f

00 DO 00 ObOCC 6 Lt 00 c ( D a 0 coiC G4

I- 3lt0(1 00 II 000 0 0 100 )

) pr-=- )

q~) ~) A1ULAy~-Vq P r---o~ AI-) (s T) CJ ~X ($1 Ir lJ 0 (Y) C~ 3J 0 ) () ~) l e l - 3-iJ

[51)) ex -OJ ls l~ lj 0gtlt reg0

0) ( 51 ~6) I Ax

~ (s t+ ~J I 2gtX Lamp=shy-

b) N~GLGlpLY AIVlt) AL) of=-

fA-oJ CL J + Sol- tL A - ) lt- shy

v- A ~

q3) ~Cooc IVAr ~ fAoJ

MOJ

f-o J

~o~

A~r

MoJ

S~L

o(L

~oJ

t--cgt J

pJVI)

~-J

~-)-

O(L

(-Q0

AOO

(Vo J

1--0 --J

lJT

Er-JQ

A)(O~r~

OS 1)(

~l OFCS~ T A

4-)0 Lst] A)I- I D~OF H

Cl-) 4

() - cshyAHA L I

0 O~(Sgt~T 0shy

v)t ) Le) Cgt ~ ) o~lt) f 1- eL4

lV-)CLshy

t17L I ~ 1-

A-) 7 shy

~LO c ol~c~ nAL) LI- J

L AL

A- + Lt-CH

(lJ H

M~tJ

bull 0 0 S- S A 1 L

bull gt1~cK G ~

middotOAlA

c- n O-L lo~ r _ ___ 1 _ 1 -_-gt7- 7 ~~- ~ ~ 1W bull co -_- v jlt~ I)

NWCrugt) 0 gt ~

bull LoQ~ -C- ~JltOA)~A N

fv--O-gt O~ I A)ltt

ClC OCgt 1-f-O-I ~c

MOJ ofSET 5T~01 1 (51J~D

ANI) AL IOf

(71)) A Ltv---

I Nt tbL

-IbAC-L A L CSt)~ f- 01 (

LMP A ) bull

1r- ~ t

(p AL6H

jib CGL

cP AoL1 A

SA et-L

~( ~q

cgt 1312 LP AL 4l

S~ o-ll(l-

c~O 1 54 H

j A cCfL2

hJL f11

--p A-f

r- =- jJ GXT INC q L

~OJ A 14 [~lt j C ~ A I-l I ( I ~

3~ AJ~ t

lt-t9 P A~ +A JA N~

ANt) A I OI~

MO-l [st-JAl- NS)(~ bull I~lt bt

) ~~Lll ~ 0-1 N~ ctLJS I ltbL

fV-~J IJL l~stLgt h )

~Ov A 14 -1 L

IN r l

~ bullH) fvA -J

Page 2: Name: Date: 18 April 2014 3 4 T EENG410/INFE410 ...faraday.ee.emu.edu.tr/eeng410/S13-14-MT-SOL.pdfName: Date: 18 April 2014 Number: EENG410/INFE410 - MICROPROCESSORS I Midterm Exam

------------------------------------------------------------------------------------------------------------------------------ 4 (30) Write an assembly language program that will process the following sentence as

follows

a) Convert the first letter of each word to upper-case b) Count and save the number of words in the sentence c) Count and save the number of alpha characters (letters) in the sentence

Consider the following sentence in your program ldquoeastern mediterranean university was established in 1979rdquo

The program should be general and work for any sentence ending with a full stop lsquorsquo character

Hint Uppercase characters are ordered between lsquoArsquo (41H) and lsquoZrsquo (5AH) and lowercase characters are ordered between lsquoarsquo (61H) and lsquozrsquo (7AH) in the in the ASCII Code table For lowercase letters bit 5 (d5) of the ASCII code is 1 where for uppercase letters it is 0 For example

Letter Binary ASCII

lsquohrsquo 01101000 68H

lsquoHrsquo 01001000 48H

-----------------------------------------------------------------------------------------------------------------------------------------

~OJ ()( I 060 Lot --

~O-J A ~ lOA iH

5~L A~~L- A~Aol4 I

A CO Dlt I Ar)lt o ~ r -

1 09b I D I 0 0000 l 00 l l ~ 0 0 ~ lt) 6 01- ~ 0000 D lOb COC e 0 ltI

J A 6 cr c () ) () I 0 0 0 L1 0 0 I I I cgt 0

tA)( AOCH ) C)( ~ A 69 c H1 [fF - ltgt Iff ll A(- Cgt II SF- ) ~r- - 0] (]gt

A- AY- =- OA ~ oA 006 t 4 ) A X ee6 Lt l- I

A I I A Lmiddot A - -=- b 0 - 6 Lt -- 1 c -l ) A j q C 6 1 r J

I

b4~ob OOD - ~OO IOl~

1 00 CQ - ltH

cr-=- 0

C r--- r-r f

00 DO 00 ObOCC 6 Lt 00 c ( D a 0 coiC G4

I- 3lt0(1 00 II 000 0 0 100 )

) pr-=- )

q~) ~) A1ULAy~-Vq P r---o~ AI-) (s T) CJ ~X ($1 Ir lJ 0 (Y) C~ 3J 0 ) () ~) l e l - 3-iJ

[51)) ex -OJ ls l~ lj 0gtlt reg0

0) ( 51 ~6) I Ax

~ (s t+ ~J I 2gtX Lamp=shy-

b) N~GLGlpLY AIVlt) AL) of=-

fA-oJ CL J + Sol- tL A - ) lt- shy

v- A ~

q3) ~Cooc IVAr ~ fAoJ

MOJ

f-o J

~o~

A~r

MoJ

S~L

o(L

~oJ

t--cgt J

pJVI)

~-J

~-)-

O(L

(-Q0

AOO

(Vo J

1--0 --J

lJT

Er-JQ

A)(O~r~

OS 1)(

~l OFCS~ T A

4-)0 Lst] A)I- I D~OF H

Cl-) 4

() - cshyAHA L I

0 O~(Sgt~T 0shy

v)t ) Le) Cgt ~ ) o~lt) f 1- eL4

lV-)CLshy

t17L I ~ 1-

A-) 7 shy

~LO c ol~c~ nAL) LI- J

L AL

A- + Lt-CH

(lJ H

M~tJ

bull 0 0 S- S A 1 L

bull gt1~cK G ~

middotOAlA

c- n O-L lo~ r _ ___ 1 _ 1 -_-gt7- 7 ~~- ~ ~ 1W bull co -_- v jlt~ I)

NWCrugt) 0 gt ~

bull LoQ~ -C- ~JltOA)~A N

fv--O-gt O~ I A)ltt

ClC OCgt 1-f-O-I ~c

MOJ ofSET 5T~01 1 (51J~D

ANI) AL IOf

(71)) A Ltv---

I Nt tbL

-IbAC-L A L CSt)~ f- 01 (

LMP A ) bull

1r- ~ t

(p AL6H

jib CGL

cP AoL1 A

SA et-L

~( ~q

cgt 1312 LP AL 4l

S~ o-ll(l-

c~O 1 54 H

j A cCfL2

hJL f11

--p A-f

r- =- jJ GXT INC q L

~OJ A 14 [~lt j C ~ A I-l I ( I ~

3~ AJ~ t

lt-t9 P A~ +A JA N~

ANt) A I OI~

MO-l [st-JAl- NS)(~ bull I~lt bt

) ~~Lll ~ 0-1 N~ ctLJS I ltbL

fV-~J IJL l~stLgt h )

~Ov A 14 -1 L

IN r l

~ bullH) fvA -J

Page 3: Name: Date: 18 April 2014 3 4 T EENG410/INFE410 ...faraday.ee.emu.edu.tr/eeng410/S13-14-MT-SOL.pdfName: Date: 18 April 2014 Number: EENG410/INFE410 - MICROPROCESSORS I Midterm Exam

~OJ ()( I 060 Lot --

~O-J A ~ lOA iH

5~L A~~L- A~Aol4 I

A CO Dlt I Ar)lt o ~ r -

1 09b I D I 0 0000 l 00 l l ~ 0 0 ~ lt) 6 01- ~ 0000 D lOb COC e 0 ltI

J A 6 cr c () ) () I 0 0 0 L1 0 0 I I I cgt 0

tA)( AOCH ) C)( ~ A 69 c H1 [fF - ltgt Iff ll A(- Cgt II SF- ) ~r- - 0] (]gt

A- AY- =- OA ~ oA 006 t 4 ) A X ee6 Lt l- I

A I I A Lmiddot A - -=- b 0 - 6 Lt -- 1 c -l ) A j q C 6 1 r J

I

b4~ob OOD - ~OO IOl~

1 00 CQ - ltH

cr-=- 0

C r--- r-r f

00 DO 00 ObOCC 6 Lt 00 c ( D a 0 coiC G4

I- 3lt0(1 00 II 000 0 0 100 )

) pr-=- )

q~) ~) A1ULAy~-Vq P r---o~ AI-) (s T) CJ ~X ($1 Ir lJ 0 (Y) C~ 3J 0 ) () ~) l e l - 3-iJ

[51)) ex -OJ ls l~ lj 0gtlt reg0

0) ( 51 ~6) I Ax

~ (s t+ ~J I 2gtX Lamp=shy-

b) N~GLGlpLY AIVlt) AL) of=-

fA-oJ CL J + Sol- tL A - ) lt- shy

v- A ~

q3) ~Cooc IVAr ~ fAoJ

MOJ

f-o J

~o~

A~r

MoJ

S~L

o(L

~oJ

t--cgt J

pJVI)

~-J

~-)-

O(L

(-Q0

AOO

(Vo J

1--0 --J

lJT

Er-JQ

A)(O~r~

OS 1)(

~l OFCS~ T A

4-)0 Lst] A)I- I D~OF H

Cl-) 4

() - cshyAHA L I

0 O~(Sgt~T 0shy

v)t ) Le) Cgt ~ ) o~lt) f 1- eL4

lV-)CLshy

t17L I ~ 1-

A-) 7 shy

~LO c ol~c~ nAL) LI- J

L AL

A- + Lt-CH

(lJ H

M~tJ

bull 0 0 S- S A 1 L

bull gt1~cK G ~

middotOAlA

c- n O-L lo~ r _ ___ 1 _ 1 -_-gt7- 7 ~~- ~ ~ 1W bull co -_- v jlt~ I)

NWCrugt) 0 gt ~

bull LoQ~ -C- ~JltOA)~A N

fv--O-gt O~ I A)ltt

ClC OCgt 1-f-O-I ~c

MOJ ofSET 5T~01 1 (51J~D

ANI) AL IOf

(71)) A Ltv---

I Nt tbL

-IbAC-L A L CSt)~ f- 01 (

LMP A ) bull

1r- ~ t

(p AL6H

jib CGL

cP AoL1 A

SA et-L

~( ~q

cgt 1312 LP AL 4l

S~ o-ll(l-

c~O 1 54 H

j A cCfL2

hJL f11

--p A-f

r- =- jJ GXT INC q L

~OJ A 14 [~lt j C ~ A I-l I ( I ~

3~ AJ~ t

lt-t9 P A~ +A JA N~

ANt) A I OI~

MO-l [st-JAl- NS)(~ bull I~lt bt

) ~~Lll ~ 0-1 N~ ctLJS I ltbL

fV-~J IJL l~stLgt h )

~Ov A 14 -1 L

IN r l

~ bullH) fvA -J

Page 4: Name: Date: 18 April 2014 3 4 T EENG410/INFE410 ...faraday.ee.emu.edu.tr/eeng410/S13-14-MT-SOL.pdfName: Date: 18 April 2014 Number: EENG410/INFE410 - MICROPROCESSORS I Midterm Exam

q~) ~) A1ULAy~-Vq P r---o~ AI-) (s T) CJ ~X ($1 Ir lJ 0 (Y) C~ 3J 0 ) () ~) l e l - 3-iJ

[51)) ex -OJ ls l~ lj 0gtlt reg0

0) ( 51 ~6) I Ax

~ (s t+ ~J I 2gtX Lamp=shy-

b) N~GLGlpLY AIVlt) AL) of=-

fA-oJ CL J + Sol- tL A - ) lt- shy

v- A ~

q3) ~Cooc IVAr ~ fAoJ

MOJ

f-o J

~o~

A~r

MoJ

S~L

o(L

~oJ

t--cgt J

pJVI)

~-J

~-)-

O(L

(-Q0

AOO

(Vo J

1--0 --J

lJT

Er-JQ

A)(O~r~

OS 1)(

~l OFCS~ T A

4-)0 Lst] A)I- I D~OF H

Cl-) 4

() - cshyAHA L I

0 O~(Sgt~T 0shy

v)t ) Le) Cgt ~ ) o~lt) f 1- eL4

lV-)CLshy

t17L I ~ 1-

A-) 7 shy

~LO c ol~c~ nAL) LI- J

L AL

A- + Lt-CH

(lJ H

M~tJ

bull 0 0 S- S A 1 L

bull gt1~cK G ~

middotOAlA

c- n O-L lo~ r _ ___ 1 _ 1 -_-gt7- 7 ~~- ~ ~ 1W bull co -_- v jlt~ I)

NWCrugt) 0 gt ~

bull LoQ~ -C- ~JltOA)~A N

fv--O-gt O~ I A)ltt

ClC OCgt 1-f-O-I ~c

MOJ ofSET 5T~01 1 (51J~D

ANI) AL IOf

(71)) A Ltv---

I Nt tbL

-IbAC-L A L CSt)~ f- 01 (

LMP A ) bull

1r- ~ t

(p AL6H

jib CGL

cP AoL1 A

SA et-L

~( ~q

cgt 1312 LP AL 4l

S~ o-ll(l-

c~O 1 54 H

j A cCfL2

hJL f11

--p A-f

r- =- jJ GXT INC q L

~OJ A 14 [~lt j C ~ A I-l I ( I ~

3~ AJ~ t

lt-t9 P A~ +A JA N~

ANt) A I OI~

MO-l [st-JAl- NS)(~ bull I~lt bt

) ~~Lll ~ 0-1 N~ ctLJS I ltbL

fV-~J IJL l~stLgt h )

~Ov A 14 -1 L

IN r l

~ bullH) fvA -J

Page 5: Name: Date: 18 April 2014 3 4 T EENG410/INFE410 ...faraday.ee.emu.edu.tr/eeng410/S13-14-MT-SOL.pdfName: Date: 18 April 2014 Number: EENG410/INFE410 - MICROPROCESSORS I Midterm Exam

q3) ~Cooc IVAr ~ fAoJ

MOJ

f-o J

~o~

A~r

MoJ

S~L

o(L

~oJ

t--cgt J

pJVI)

~-J

~-)-

O(L

(-Q0

AOO

(Vo J

1--0 --J

lJT

Er-JQ

A)(O~r~

OS 1)(

~l OFCS~ T A

4-)0 Lst] A)I- I D~OF H

Cl-) 4

() - cshyAHA L I

0 O~(Sgt~T 0shy

v)t ) Le) Cgt ~ ) o~lt) f 1- eL4

lV-)CLshy

t17L I ~ 1-

A-) 7 shy

~LO c ol~c~ nAL) LI- J

L AL

A- + Lt-CH

(lJ H

M~tJ

bull 0 0 S- S A 1 L

bull gt1~cK G ~

middotOAlA

c- n O-L lo~ r _ ___ 1 _ 1 -_-gt7- 7 ~~- ~ ~ 1W bull co -_- v jlt~ I)

NWCrugt) 0 gt ~

bull LoQ~ -C- ~JltOA)~A N

fv--O-gt O~ I A)ltt

ClC OCgt 1-f-O-I ~c

MOJ ofSET 5T~01 1 (51J~D

ANI) AL IOf

(71)) A Ltv---

I Nt tbL

-IbAC-L A L CSt)~ f- 01 (

LMP A ) bull

1r- ~ t

(p AL6H

jib CGL

cP AoL1 A

SA et-L

~( ~q

cgt 1312 LP AL 4l

S~ o-ll(l-

c~O 1 54 H

j A cCfL2

hJL f11

--p A-f

r- =- jJ GXT INC q L

~OJ A 14 [~lt j C ~ A I-l I ( I ~

3~ AJ~ t

lt-t9 P A~ +A JA N~

ANt) A I OI~

MO-l [st-JAl- NS)(~ bull I~lt bt

) ~~Lll ~ 0-1 N~ ctLJS I ltbL

fV-~J IJL l~stLgt h )

~Ov A 14 -1 L

IN r l

~ bullH) fvA -J

Page 6: Name: Date: 18 April 2014 3 4 T EENG410/INFE410 ...faraday.ee.emu.edu.tr/eeng410/S13-14-MT-SOL.pdfName: Date: 18 April 2014 Number: EENG410/INFE410 - MICROPROCESSORS I Midterm Exam

bull 0 0 S- S A 1 L

bull gt1~cK G ~

middotOAlA

c- n O-L lo~ r _ ___ 1 _ 1 -_-gt7- 7 ~~- ~ ~ 1W bull co -_- v jlt~ I)

NWCrugt) 0 gt ~

bull LoQ~ -C- ~JltOA)~A N

fv--O-gt O~ I A)ltt

ClC OCgt 1-f-O-I ~c

MOJ ofSET 5T~01 1 (51J~D

ANI) AL IOf

(71)) A Ltv---

I Nt tbL

-IbAC-L A L CSt)~ f- 01 (

LMP A ) bull

1r- ~ t

(p AL6H

jib CGL

cP AoL1 A

SA et-L

~( ~q

cgt 1312 LP AL 4l

S~ o-ll(l-

c~O 1 54 H

j A cCfL2

hJL f11

--p A-f

r- =- jJ GXT INC q L

~OJ A 14 [~lt j C ~ A I-l I ( I ~

3~ AJ~ t

lt-t9 P A~ +A JA N~

ANt) A I OI~

MO-l [st-JAl- NS)(~ bull I~lt bt

) ~~Lll ~ 0-1 N~ ctLJS I ltbL

fV-~J IJL l~stLgt h )

~Ov A 14 -1 L

IN r l

~ bullH) fvA -J