Computing Systems and Assembly Language: Midterm 2 | CMPE 12, Study notes of Engineering

Typology: Study notes

2019/2020

Uploaded on 06/15/2020

prindhorn
prindhorn 🇺🇸

4.6

(11)

276 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
NAME (LAST, First | please
print
):
Email:
@ucsc.edu
CMPE12 | Computing systems and assembly language, Fall 2006
Midterm 2
TuesdayNovember 28th, 2006
No books, notes or calculator.
Simple computations are expected to be carried out by hand.
Justify all your answers | no credit will be given for a correct answer if work is not shown
Use the back of pages as scratch paper, if necessary.
Exercise Score Out of
M2.1 15
M2.2 10
M2.3 14
M2.4 16
M2.5 45
TOT
100
pf3
pf4
pf5
pf8

Partial preview of the text

Download Computing Systems and Assembly Language: Midterm 2 | CMPE 12 and more Study notes Engineering in PDF only on Docsity!

NAME (LAST, First | please print):

Email: @ucsc.edu

CMPE12 | Computing systems and assembly language, Fall 2006 Midterm 2

Tuesday Novemb er 28th, 2006

No b o oks, notes or calculator. Simple computations are exp ected to b e carried out by hand. Justify all your answers | no credit will b e given for a correct answer if work is not shown Use the back of pages as scratch pap er, if necessary.

Exercise Score Out of M2.1 15 M2.2 10 M2.3 14 M2.4 16 M2.5 45 TOT 100

M2.1 Below is an LC3 program.

.orig x LD R1, x LD R2, y AND R3, R3, # JSR TWEETY TOM BRzp JERRY ADD R1, R1, # JSR TWEETY JERRY BRnz SYLVESTER ADD R1, R1, #- SYLVESTER ADD R3, R3, # JSR TWEETY BRnp TOM ST R3, z halt x .fill x y .fill x z .fill x .blkw 4 TWEETY NOT R0, R ADD R0, R0, # ADD R0, R1, R RET .end

 (5 p oints) What standard ow-control structure(s) do es this program implement?

 (10 p oints) Write a high-level language fragment (C is preferred) equivalent to this program, using the appropriate control structures and making the co de as coincise and clean as p ossible.

M2.3 (14 p oints) Fill out the symbol table for the program on page 2 with the entries de ned in this co de fragment. Also indicate what are the names of the two columns of the symb ol table.

(what is in this col?) (what is in this col?)

M2.4 (16 p oints) The picture b elow describ es the implementation of memory-mapp ed I/O in the LC architecture. Fill out all the shaded b oxes with the corresp onding blo ck's missing name.





































M2.5 (cont.) Knowing that the assembler is not using memory lo cations b elow 0x1000, answer the following questions:

 (5 p oints) What is the addressing mo de used by this instruction? ldaa var

 (5 p oints) What is the addressing mo de used by this instruction? inca

 (5 p oints) What is the addressing mo de used by this instruction? ldx #var

 (5 p oints) What is the addressing mo de used by this instruction? jsr CONSOLEINT

 (5 p oints) What is the addressing mo de used by this instruction? addd #

 (5 p oints) What is the addressing mo de used by this instruction? std 0, X

Knowing that the rst numb ers that is written to the console is 16384 ,

 (5 p oints) What is the second numb er written to the console?

 (5 p oints) What is the third numb er written to the console?

 (5 p oints) What is the fourth numb er written to the console?

LC3 instruction set | this page can b e detached but it must b e returned with the test

TRAP Service Routines Trap Vector Assembly Name Description x20 GETC Read a single character from the keyb oard into R0[7:0], no echo x21 OUT Write the character in R0[7:0] to the display x22 PUTS Write to display the 0-terminated string starting at address R x23 IN Write a prompt to display and then read a char from keyb, returned in R0[7:0], with echo x24 PUTSP Write to display the packed (2 characters/word) 0-terminated string starting at address R x25 HALT Halts execution and prints a message to the display

Device Register Assignments Address Register Name Description xFE00 KBSR Keyb oard status register: bit 15 set means new character waiting xFE02 KBDR Keyb oard data register: bits [7:0] contain the new character xFE04 DSR Display status register: bit 15 set means display ready for output xFE06 DDR Display data register: bits [7:0] are output on the screen xFFFE MCR Machine control register: bit 15 is the clo ck enable bit