Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment: Parts A and B

For "written" questions, please type your answers, use your very best English, and carefully consider the material from the chapters. I am usually only looking for a few sentences for each question, not an essay that goes on for pages. So choose your words carefully and thoughtfully.

PART A

[1] Does a computer need data registers (like D0-D7 in an M68K)? Defend your answer!

[2] Textbook question 5.35. If your student number is even, do parts (a), (c), (e) and (g). Otherwise do parts (b), (d), (f) and (h). Note that (b) should read "[[[4]]]", (c) should read "[[[0]]]" and
(h) should start with "[0]".

[3] Explain why the following assembly language and RTL constructs are incorrect.
a. MOVE    D3,#4
b. MOVE    [D3],D2
c. MOVE    (D3),D2
d. [D3] ←  A0 + 3
e. [D3] ←  #3
f. 3      ←  [D3]

[4] Create a simple M68K program called ADDER. Your program should add together the numbers: 6, 4, 12, 16, 17, and 50. The program should leave the answer in register D0 when it terminates.

The program is to be assembled with the M68K cross-assembler and then run on the M68K simu- lator. You can either install the cross-assembler and simulator given with the textbook (windows) or you can use the Linux one available on the course web site. Doing a trace (to hand in) with the windows version is much more painful than the Linux version, so make your choice carefully (and you have to figure out the windows one without my help).

To use the Linux assembler ("68kasm") and simulator ("bsvc"), follow the instructions in my mail message of January 26, if you have not already done so.

IMPORTANT NOTE: if you are using the Linux simulator, the instructions for creating a program are slightly different than those in the book. You should have the following at the start of each program:

ORG      $0
DC.L     $8000     This is the stack pointer value after a "reset"
DC.L     START      This is the first instruction to execute

You can then follow that with something like

ORG     $1000    START MOVE ...

You should still have a STOP instruction and END assembler directive, as described in the book, but also use a BREAK instruction right before your STOP instruction.

Create your program (ADDER.s) in your (for example) comp2213/bsvc-master directory using your favourite text editor and assemble it with the command 68kasm -l ADDER.s. If you had no assembly errors you should now have a file called ADDER.h68 (which is your executable program) and ADDER.lis (your program listing). Then start up the simulator by typing bsvc. Select File/Open Setup, drill down to samples/m68000, select serial.setup and click Open; a new window should pop up on your screen. Now choose File/Load Program, come back up to your bsvc-master directory, and open your ADDER.h68 program. Now click the GUI's Reset button and then the Run button. (Alternatively, instead of Run click Single Step and watch the result of each instruction.)

After you get your program working, create something to hand in by single-stepping through your program until it finishes, and then use the Trace menu to insert the register values into the trace window, and then save that window (again from the Trace menu). Hand that file and your program listing in. If you are using the windows software, do whatever it takes to hand the same information in. The tutors have looked at the Linux software and should be able to help you with it, but you are really on your own with the windows software.

There are some sample programs in the samples/m68000 directory. To learn how to use bsvc, you might find it instructive to run the MatrixMultiply.h68 program using the serial setup.

PART B

[5] What is wrong with each of the following M68K assembly language operations?

a. MOVE         Temp,#4
b. ADD.B        #1,A3
c. CMP.L          D0,#9
d. MOVE.B      #500,D5

[6] Translate the following fragment of high-level language into M68K assembly language. Then create a complete M68K program containing your code, and use a M68K simulator to test your program.

IF T = 5
       THEN X = 4
       ELSE Y = 6
END_IF
Hand in the program listing and program trace as in Question 4.

[7] A sequence (string) of one-byte ASCII characters is stored at memory location $600 onward. A second sequence of equal length is stored at memory location $700 onward. Each sequence ends with the character $0 (i.e., the ASCII NUL character). Write a M68K assembly language program to determine whether or not these two strings are identical. If they are identical, place the value
$00 in data register D0. If they are not, place the value $FF in D0.

Use the M68K cross-assembler and simulator to test your program (make up a couple of your own strings, using the DC.B assembler directive). Hand in the program listing and program trace as in Question 4.

[8] Write a subroutine ADDABC that performs the operation C = A + B. Variables A, B, and C are all word (i.e., 16-bit) values. Test your program on the M68K simulator by writing a main program which sets up values in A and B and then calls your main program.

Your calling code and subroutine should have the following features:

? Parameters A and B should be passed on the stack to the procedure by reference (i.e., by address). Parameter C should be passed back to the calling program on the stack by value.

? Before you call the subroutine, make room on the stack for the returned parameter (i.e., parameter C). After calling the subroutine, read the parameter off the stack into data register D0 (i.e., D0 should end up containing the value of A + B).

? The subroutine ADDABC must not corrupt any registers. Save all working registers on the stack on entry to the subroutine and restore them before returning from the subroutine.

? When you write your code, preset the stack pointer to a value like $1500 (by using either MOVEA.L #$1500,A7 or LEA $1500,A7). Doing this will make it easier to follow the movement of the stack while your program is running.

? Make certain that you are operating with the correct operand sizes! Use .W for data values and .L for addresses/pointers.

? Some of the important instructions you might need are provided below. Make sure you understand exactly what they do.

           MOVEM.L            RegList, -(A7)            Push a group of registers on stack
           MOVEM.L            (A7)+, RegList            Pop a group of registers off stack
           LEA                    X(Ai), Aj                    Load Aj with the contents of Ai + X
           MOVEA.L            (Ai),Aj                       Load Aj with  longword pointed at by Ai

Your program should be of the general form:

 

ORG

$0

 




START

DC.L
DC.L
ORG
LEA
...
BSR
...
...
STOP

$8000
START
$400
$1500,A7

ADDABC


#$2700

Initial value of stack pointer
First instruction here

Set up the stack pointer with an easy value
Pass the parameters
Call the subroutine
Get the result, C, in D0
Clean up the stack
Halt execution

*
ADDABC      ...
                   ...
                 RTS
*
                 ORG          $1200              Put the test data here
A               DC.W        $1234              This is the first parameter
B               DC.W        $ABAB             This is the second parameter
                 END          START

This is not an easy or trivial problem. You will need to draw a map of the stack at every stage and take very great care not to confuse pointers (addresses) and actual parameters.

Hand in a listing and trace of your program as descried in question 4.

NOTE: a lot of the other questions in Chapters 5 and 6 look like good midterm and/or final exam questions to me.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92192961
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Your solution will entail writing a function called

Your solution will entail writing a function called TimeDifference and a test main that demonstrates that you can compute the time difference in minutes between the two times. TimeDifference is a function that receives a ...

The equation of regression line for sons heighty in inches

The equation of regression line for son's height(y) in inches versus father's height in inches is y = 35 + 0.5x. For a 72 inch tall father, what would we predict for the son's height?

If sailsboro just paid a dividend of 2 per share amp

If Sailsboro just paid a dividend of $2 per share & dividends are expected to grow at 8%, 6%, and 5% for the next three years respectively. After that the dividends are expected to grow at a constant rate of 3% indefinit ...

Systems analysis project 5can you answer the 4questions

Systems Analysis project 5: Can you answer the 4questions please. Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an internat ...

Question an agile-focused mind-set in project

Question: "An Agile-focused Mind-set in Project Management" • Read the following two (2) articles: "The Scrum Guide," located here and "Core Scrum," located here. Contrast the role of a Scrum Master and the role of a pro ...

The formulas a rarr b and c and a rarr b and a rarr c are

The formulas A → (B ∧ C) and (A → B) ∧ (A → C) are logically equivalent. For this problem, you are going to prove that they are equivalent in two different ways. Prove that A → (B ∧ C) ≡ (A → B) ∧ (A → C) by writing two ...

Recall that for a block cipher a key schedule algorithm

Recall that for a block cipher, a key schedule algorithm determines the subkey for each round, based on the key K. Let K = (K0,K1,K2......K55) be a 56-bit DES key. a. List the 48 bits for each of the 16 DES subkeys K1, K ...

Research one job and company that interests you one that

Research one job and company that interests you, one that you think might be a good fit for you after graduation. i.Identify why that job and company is a good fit for you Prepare a cover letter for that job. i.Include y ...

Subnetting ip adress - 190 3500750 subnetwhat is the

Subnetting : IP adress - 190. 35.0.0 750 subnet What is the subnet mask? How many bit? What is 2 n-2 host? What is 2 n subnets? What are the first 5 subnets? What is the first and last IP of 2nd block? Answer all the que ...

Please respondwhat are some other ways to troubleshoot

PLEASE RESPOND What are some other ways to troubleshoot reduced speed or latency? Or to find out what is using all the bandwidth? Perhaps might incorporate parts of this into own three issues.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As