Docsity

EECS 388 Homework 2: Reversing Bit Order and Arithmetic Operations, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
EECS 388: Computer Systems and Assembly Language
Homework 2
Due Feb. 21, 2007
Justify your answers!
Figure 1 shows a part of the memory (both contents and locations).
Contents Locations
_____________________________________
$20 $4000
$50 $4001
$01 $4002
: :
: :
$B5 $5000
$CD $5001
Figure 1.
Problem 1 (10 Points):
Consider the memory shown in Figure 1. What is in accumulator A and the N, Z,
C, V bits in CCR after an LDD #$4001 instruction is executed?
Accumulator A ____________ N _____ Z ______ C ________ V _____
Problem 2 (15 Points):
Write a program segment to reverse the bit order of a 6-bit number. Assume this
number is stored in $6000. Store the reversed number to $6001 (i.e., if the
original number is 0 0 b5 b4 b3 b2 b1 b0, after this program, the number in $6001
will be 0 0 b0 b1 b2 b3 b4 b5).
Problem 3 (20 points):
Write a program segment to multiply a 16-bit number in the D register by 10
using arithmetic left shift instead of multiplication instructions.
Problem 4 (20 points):
Write a program to subtract two 24-bit numbers and store the result to memory
locations starting at $6000. The two 24-bit numbers are stored in memory
locations starting at $5000 and $5010, respectively.
pf2

Partial preview of the text

Download EECS 388 Homework 2: Reversing Bit Order and Arithmetic Operations and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EECS 388: Computer Systems and Assembly Language

Homework 2

Due Feb. 21, 2007

Justify your answers! Figure 1 shows a part of the memory (both contents and locations).

Contents Locations


$20 $ $50 $ $01 $

$B5 $

$CD $

Figure 1.

Problem 1 (10 Points):

Consider the memory shown in Figure 1. What is in accumulator A and the N, Z, C, V bits in CCR after an LDD #$4001 instruction is executed?

Accumulator A ____________ N _____ Z ______ C ________ V _____

Problem 2 (15 Points):

Write a program segment to reverse the bit order of a 6-bit number. Assume this number is stored in $6000. Store the reversed number to $6001 (i.e., if the original number is 0 0 b 5 b 4 b 3 b 2 b 1 b 0 , after this program, the number in $ will be 0 0 b 0 b 1 b 2 b 3 b 4 b 5 ).

Problem 3 (20 points):

Write a program segment to multiply a 16-bit number in the D register by 10 using arithmetic left shift instead of multiplication instructions.

Problem 4 (20 points):

Write a program to subtract two 24-bit numbers and store the result to memory locations starting at $6000. The two 24-bit numbers are stored in memory locations starting at $5000 and $5010, respectively.

Problem 5 (20 Points):

If A contains $56, what is the result of each of the following instructions? Assume that A is restored to its original value before each instruction.

a) ANDA #$

b) ORAA #$

c) EORA #$

d) BITA #$

Problem 6 (15 Points):

Consider the following program:

LDD #$F00D STD $ BSET $8100, $ BCLR $8101, $

What numbers are in $8100 and $8101 at the end?