2005 Spring Exam 1 W-solution

9
EEL4767 Computer System Design 1, Spring 2005 Exam 1 Part I: ClosedBook INotes (75 pts) NAME I. What register is used to keep track of the address of the next instruction to be executed is: a. b. .c) d. Index Registers Stack Pointer Program counter Condition code register. 2. Which type of ROM can be erased by electrical signals and reprogrammed a. MROM b. EPROM c. PROM d. EEPROM 3. Which instruction is best performed by an ALU: a. Store b. Dec c. Jmp d. Load 4. In 68HCII, what are the size of the following registers in the order: B, D, SP, CCR: a. 8 bits, 16 bits, 8 bits, 16 bits b. 8 bits, 16 bits, 16 bits, 16 bits c. All are 16 bits. d. 8 bits, 16 bits, 16 bits, 8 bits. 5. In a typical micro-processor, which of the following statements is true: a. Data bus is bi-directional and the Address bus is unidirectional. b. Data bus and Address bus are both unidirectional. c. Data bus is unidirectional and the address bus bi-directional. d. Data bus and Address bus are both bi-directional .

description

Solution to Embedded Systems Exam

Transcript of 2005 Spring Exam 1 W-solution

  • EEL4767ComputerSystemDesign1,Spring2005

    Exam1PartI: ClosedBookINotes(75pts) NAME

    I. Whatregisterisusedtokeeptrackoftheaddressofthenextinstructiontobeexecutedis:

    a.b..c)d.

    IndexRegistersStackPointerProgramcounterConditioncoderegister.

    2. WhichtypeofROM canbeerasedbyelectricalsignalsandreprogrammed

    a. MROMb. EPROMc. PROMd. EEPROM

    3. WhichinstructionisbestperformedbyanALU:

    a. Storeb. Decc. Jmpd. Load

    4. In 68HCII, whatarethesizeofthefollowingregistersintheorder:B, D, SP,CCR:

    a. 8bits,16bits,8bits,16bitsb. 8bits,16bits,16bits,16bitsc. All are16bits.d. 8bits,16bits,16bits,8bits.

    5. In atypicalmicro-processor,whichof thefollowingstatementsistrue:

    a. Databusisbi-directionalandtheAddressbusisunidirectional.b. DatabusandAddressbusarebothunidirectional.c. Databusisunidirectionalandtheaddressbusbi-directional.d. DatabusandAddressbusarebothbi-directional.

  • 6. In assemblylanguageprogramming,differentprefixesareusedtodifferentiatebetweendifferentkindsofdata.Whichstatementgivestherightprefix?

    cd

    Decimal##$

    Nothin

    Hexadecimal$

    7. Whatkindofaddressingis SUBA$2000?

    a. Immediateb. Registerc. Extendedd. Inherent

    8. Whatkindofaddressingis ADDA #$32?

    a. Immediateb. Registerc. Extendedd. Inherent

    9. WhatkindofaddressingisINX?

    a. Immediateb. Registerc. Extendedd. Inherent

    10.RelativeModeisusedonlywith??????instructions?

    a. Arithmeticb. Branchingc. Loadingd. Incrementing

    11.Howmanydifferentmemorylocationscanthe68HCli address(hint:thinkofthesizeofaddressbus):

    a. 256b. 262,144c. 65536d. 16384

  • 12.Whenusingbranchinstructions,thebranchoffset(BRAoffset)hasarangeof:

    ,'i a. -64to63bytes.b. Dependsonthesizeoftheassemblyprogram.c. Dependsonthetypeofbranchinstructionused.d. -128to 127bytes.

    I 13.WhatarethecontentsoftheD registerandthememorylocationsafterexecutingLDD $00001Beforetheinstruction:[D]=$1010;[$0000]=$20;[$0001]=$30.

    14.ThestatementM[lOOO]f- Rl +[R2]

    a. Addwhatis inRl andR2 andstoretheresultin memorylocation1000.b. UseRl asanaddresstoobtainthedatafomandaddwhatis inR2 and

    storetheresultinmemorylocation1000.c. UseR1 asanaddresstoobtainthedatafomanduseR2 anaddressasan

    addresstogetthedatafomandthenaddthemtogetherandstoretheresultinmemorylocation1000

    d. Addwhatis inRl tothedatastoredinmemorygivenbytheaddressinR2andstorestheresultinmemorylocation1000

    15.WhatdoesABX do:

    a. AddaccumulatorB andtheindexregisterX andstoretheresultinX.b. AddaccumulatorB andtheindexregisterX andstoretheresultinB.c. AddaccumulatorB andthecontentsofthememoryaddresspointedbythe

    indexregisterX andstoretheresultinX.d. AddaccumulatorB andthecontentsofthememoryaddresspointedbythe

    indexregisterX andstorestheresultinB.

    16.WhatisthedifferencebetweenLDX #$1000andLDX $10001

    a. Theyarebasicallythesame.b. Thefirstinstructionplacesthecontentsofmemorylocations$1000and

    $1001intoX andthesecondplacesthehexvalue$1000intoX register.c. Thefirstinstructionplacesthehexvalue$1000intoX registerandthe

    secondplacesthecontentsofmemorylocations$1000and$1001intoX.d. Oneoftheinstructionsisnotvalid.

    [D] r$OOO11 [$0000]a 1010 10 10b) 0000 30 20c 2030 30 20d) 3020 30 20

  • 17.Whichcond~tionalbranchinstructioninthefollowinglistwill notbranchif theconditionflagsareN=C=1andZ=V=O:

    a. BCS targetb. B~ targetc. :a,CCtargetd. Bve target

    18.Findthevaluesof theconditionflagsN, Z, V ande afterexecutingSUBA #$50.Given:[A] =#$70,N=O,Z=I,v=oandC=1.(IDNT: N is setifMSB oftheresultis set;Z is setif resultis zero;V is setif tWoscomplementoverflowresults;e issetif acarryisgenerated.):

    19.ComputethenewvaluesofaccumulatorA andthee flagafterexecutingtheinstructionASLA. TheoriginalvalueinA is $74(01110100)andtheC flagis 1.(Hint:0movesintoLSB andMSB movesintoC) :

    a. 11101000andC flagisO.b. 10111010andC flagisO.c. 11101000andC flagis 1.d. 10111010andC flagis 1.

    "~"I ~~~.; \.~ . " Q 0 J:-_. (;, .--l -~ 1

    20.If thememorylocationat$00contains$F6andthee flagis 1,whatarethenewvaluesofthismemorylocationandthee flagaftertheexecutionofLSR $OO?(Hint:0 intoMSB andLSB intoC):

    a. 11110110andC flagis 1.b. 11101101andC flagisO.c. 01111011andC flagisO.d. 01111011andC flagis 1.

    1f b -::. \ \ " 0 I \0

    0' / I.') ,~Q--"3--y LO

    ~~IC]---)? ,~!j21.ComputethenewvaluesofaccumulatorB andthee flagafterexecutingthe

    instructionROLB. TheoriginalvalueinB is $BEandtheC flagis 1.

    (Hint:einto LSB andMSB intoC): f PA~ -;:: " )~ ~ \0' \ \., 0

    a. 01111101andC flagisO.b. 11011111andC flagisO.c. 01111101andC flagis 1.d. 11011111andC flagis 1.

    'N Z V Ca 1 1 0 1b) 0 0 1 1c 1 0 0 0d) 0 0 0 0

  • 22.A programrequiresadelayof 1msec.ThefrequencyofE clockcycleis2MHz.CalculatethenumberofE clockcyclesrequiredforthisdelay:

    f ~ +~ 7. 1'1~l.-::---

    ,' ~ 2Mtil,..~1 -qJC) ~- ", - ~

    - '11':r:l

  • I 28.WhathappensafterexecutingSTAA #$1001A ~ ~DI()9 ZZ2

    a. Theaccumulatorremainsunchanged.b. Theccmtentsoftheaccumulatorarestoredattheaddress$0100.c. TheZ flagis setif theaccumulatorhas$00.d. InvalidInstruction

    29. Whatarethecontentsoftheaccumulatorafterexecutingtheseinstructions:

    LDX#VECLDAA I~XVEC FCB I, 2,3,4,5

    y..-: )A -;. 1.

    IIII

    a. Thecodereturnsan"error.b. [A]=1c. [A]=2d. [A]=3

    30.If thereg.SP =$F7C3,thentheinstructionPULA retrievesreg.A fromthestackandsetstheSP to:

    a. Remainsunchanged.b. $F7C2c. $F7C4d. Dependsonthedatainthestack.

  • EEL4767ComputerSystemDesignI, Spring2005

    Exam1PartI: ClosedBookINotes NAME

    Ques. A B C D1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X

  • \q----'J-S

    EEL4767ComputerSystemDesignI, Spring2005

    E~l ~Part2:ClosedBook/2PagesofNotes(25pts) NAME LlA.tc{ trJt,

    UsingtheINCHAR andOUTA subroutineswriteaprogramthatinputstwoASCnnumbersbetween0 and9. Yourprogramshouldcheckandmakesurethatthekeyboardinputisavalidnumberbetween(0-9).Onceyourprogramhasdeterminedthatthekeyenteredisavalidnumber,it shouldechoit tothescreen.Next,yourprogramshouldcompute A(.L:f1 0-4 :::.~J-?:'"

    Result=INumber1- Numher2I whereI I is equaltotheabsolutevalue.

    Finally,yourprogramshouldoutputtheresulttothescreenasanASCII number.

    O(~LV1-

    Lf1- JS~

    (MfA~t~

    c.",fAtEa["'fAu&c"'tA&8-

    CfI\ 'f\.

    \)fG.

    (f' p~6tu

    [MPA

    1'JtX

    (/1 fJA

    ~o.c" fA1)~

    c'" pAf;t El

    JRA

    ~100iQOo1..

    1 i'lLBA(J.

    ~1-;O..."''''

    li>~1ML\""" 1->1-

    N"~~i 33

    N"'~

    ~19"

    "wfI\.

    -Ii.1)~1W.f'1

    ~13bJ'lL4T"\

    ~j77tJuf'1~."~rJUM

    ~i~~

    /,HpV\Lf1-

  • ORG $0100LDS" #$OOFFJSR INCHARCMPA #$30BLO LPICMPA #$39BHI LPIJSR OUTATABJSR INCHARCMPA #$30BLO LP2CMPA #$39BHI LP2JSR OUTACBABHS SUBTRPSHAPSHBPULAPULB

    SUBTR SBAADDA #$30JSR OUTA

    EQ JMP STINCHAR PSHBRCHRI LDAB $102E

    ANDB #$20BEQ RCHRILDAA $102FPULBRTS

    OUTA PSHBWCHRl LDAB $102E

    ANDB #$80BEQ WCHRlSTAA $102FPULBRTS

    CRLF LDAA #$ODJSR OUTALDAA #$OAJSR OUTARTSEND

    STLPI

    LP2

    GO GET THE INPUT CHARGO SEE IF IT'S A #INVALID INPUTGO SEE IF IT'S A #INVALID INPUTGO ECHO THE CHARACTERPUT 1ST NUMBER IN AGO GET THE INPUT CHARGO SEE IF IT'S A #INVALID INPUTGO SEE IF IT'S A #INVAL ID INPUTGO ECHO THE CHARACTER

    SEE WHICH IS POSITIVE

    SWAP ATHE #'S INTHE A AND B ACC

    TAKE THE DIFFERENCECONVERT BACK TO ASCII

    THIS ROUTINE INPUTS ONE CHAR IN AIS THE RECEIVE BUFFER IS EMPTY

    SOURCE INPUT CHARACTER IN THE A

    THIS ROUTINE OUTPUTS ONE CHAR IN AIS THE TRANSMIT BUFFER IS EMPTY

    GO WRITE THE CHAR

    GO WRITE THE LF AND CR