All Answers (2)

Embed Size (px)

Citation preview

  • 8/9/2019 All Answers (2)

    1/63

    Chapter 1 Test Bank Note to instructors: To view the answers, select Tools | Options | View | Hidden Text in MS-Word.

    Fill in the Blanks and Short Answer

    1. Which popular programming language is well-known for executing its target programs on a virtualmachine?

    2. In any numbering system, the specifies the number of !ifferent symbols that can be assigne!to a single !igit.

    ". #ranslate the following !ecimal numbers to binary$

    a. ""

    b. 1%

    c. &

    !. &2

    '. #ranslate the following !ecimal numbers to hexa!ecimal$

    a. ""

    b. ()

    c. 2)&

    !. &'

    ). *!! the following binary integers$ 1+11+1 an! ++111+11

    %. orm the -bit two s complement of each binary integer$

    a. +++++++1

    b. ++++1+++

    c. 1111++++

    !. ++++1111

    &. #ranslate the following signe! !ecimal numbers to binary$

    a. ""

    b. &

    c. &

    !. 1

    . /onvert the following string to a se0uence of hexa!ecimal * /II co!es$ *312"

    Multiple-Choice4 ome of the following 0uestions have more than one correct answer. /ircle all correct answers.5

    (. * program that combines ob6ect files into an executable program is calle! a .

    a. compiler

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 1

  • 8/9/2019 All Answers (2)

    2/63

    b. loa!er

    c. linker

    !. assembler

    1+. If virtual machine

  • 8/9/2019 All Answers (2)

    3/63

    a. true

    b. false

    1(. If I *-level instructions coul! be execute! !irectly by computer har!ware, a microco!e interpreter woul! be unecessary.

    a. true

    b. false

    2+. * single hexa!ecimal !igit can be use! to represent ) binary bits.

    a. true

    b. false

    21. #he most significant bit in a binary byte is numbere! bit &.

    a. true

    b. false

    22. #he sum of all powers of 2 between 2 + an! 2 & is 2)).

    a. true

    b. false

    2". * 0ua!wor! is bytes.

    a. true

    b. false

    2'. * wor! 4on Intel systems5 is 1% bits.

    a. true

    b. false

    2). * !oublewor! is %' bits.

    a. true

    b. false

    2%. * signe! integer stores the sign in the least significant bit 49 :5.

    a. true

    b. false

    2&. If an integer s sign bit is 1, the integer is negative.

    a. true

    b. false

    2 . * signe! byte can be e0ual to @12 .

    a. true

    b. false

    2(. :oolean algebra was invente! by amuel B. :oole, an *merican inventor who live! in the 1(2+ s.

    a. true

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition "

  • 8/9/2019 All Answers (2)

    4/63

    b. false

    "+. #he expression 3 = is true only when 3 an! = are both true.

    a. true

    b. false

    "1. #he expression X Y is only true when 3 an! = are both true .

    a. true

    b. false

    "2. #he expression X Y is true when 3 is false an! = is true .

    a. true

    b. false

    "". #he expression 4X Y) is true when 3 an! = are both false.

    a. true

    b. false

    "'. #he three most basic operators in :oolean algebra are *CA, D8, an! CD#.

    a. true

    b. false

    "). #he integer range of stan!ar! * /II co!es is$

    a. -12 to @12&

    b. + to 12&

    c. + to 2&+

    !. + to %),)")

    "%. Eow many bits are use! by Fnico!e characters?

    a. &

    b.

    c. 1%

    !. 2'

    "&. Which type of program must usually run on multiple platforms?

    a. !evice !river

    b. business application

    c. embe!!e! system

    !. assembler

    " . Which of the following best !escribes the relationship between assembly language an! machinelanguage?

    a. one to many

    b. one to one

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition '

  • 8/9/2019 All Answers (2)

    5/63

    c. many to one

    !. many to many

    "(. * program is consi!ere! porta le if it . . .

    a. can be rewritten in a !ifferent programming language without losing its meaning.

    b. can be 0uickly copie! from conventional 8*B into high-spee! 8*B.c. can be execute! on multiple platforms.

    !. none of the above

    '+. * !evice !river woul! or!inarily be written in . . .

    a. machine language

    b. assembly language

    c. a platform-in!epen!ent language, such as Gava

    !. an application-oriente! language

    '1. Which of the following are embe!!e! systems applications?

    a. an accounting program

    b. a 6avascript program running on a Web page

    c. a Cinten!oH vi!eo game

    !. a phone book searching program in a cellular phone

    '2. uppose a program written in language 91 must be execute! on a machine running a programrunning in language 9+. What important operation must take place?

    a. translation of the entire 91 program into 9+ co!e

    b. translation of the 9+ program into 91 co!e

    c. creation of a language 9" that interprets 9+ instructions!. interpretation of each 91 statement using 9+ co!e as the 91 program is running

    '". /onventional machine language instructions are execute! by which virtual machine level?

    a. microarchitecture level

    b. I * level

    c. assembly language level

    !. operating system level

    ''. Which language 4or virtual machine5 uses short mnemonics such as *AA an! F: to i!entifyinstructions?

    a. conventional machine language

    b. I *-level language

    c. assembly language

    !. microco!e interpreter

    '). What is the largest unsigne! integer that may be store! in 1% bits?

    a. "2&%&

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition )

  • 8/9/2019 All Answers (2)

    6/63

    b. %))"%

    c. %))")

    !. "2&%

    '%. What is the largest signe! integer that may be store! in "2 bits?

    a. 2 "2 1 b. 2 "2

    c. 2 "1 1

    !. 2 "1

    '&. #he two s complement of an integer is forme! by !oing which of the following?

    a. reversing 4inverting5 the bits an! a!!ing 1

    b. a!!ing 1 an! reversing the bits

    c. calculating the integer s a!!itive inverse

    !. changing the highest bit to a 1

    ' . Which of the following unsigne! !ecimal values is e0uivalent to binary 1+11+1+1 ?

    a. 1&(

    b. 1 1

    c. 1 2

    !. 1&)

    '(. Which of the following unsigne! !ecimal values is e0uivalent to binary 1111++++ ?

    a. 21%

    b. 1)+

    c. 2'+

    !. 2"

    )+. Which list contains the correct hexa!ecimal translation 4in or!er5 of the following unsigne!!ecimal integers? 33, 95, 257

    a. 21, ) , 1+1

    b. 22, );, 11*

    c. %*, ) , 1+1

    !. )1, 1'(, )((

    )1. Which of the following signe! !ecimal values is e0uivalent to binar 1111++++ ?a.

    b. 1%

    c. 2'+

    !. @2'+

    )2. Which of the following signe! !ecimal values is e0uivalent to binar ++++1111 ?

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition %

  • 8/9/2019 All Answers (2)

    7/63

    a. +32

    b. +16

    c. 1)

    !. @1)

    )". Which of the following binary values is e0uivalent to hexa!ecimal '*2:?

    a. +1++ 1+1+ ++1+ 11+1

    b. +1++ 1+1+ ++1+ 1+11

    c. +1++ 1+1+ ++1+ 1+11

    !. +11+ 1+11 ++1+ 1++1

    )'. Which of the following binary values is e0uivalent to hexa!ecimal &/:;?

    a. +111 11+1 1+11 111+

    b. +111 1+11 1+11 11++

    c. +111 11++ 11++ 111+!. +111 11++ 1+11 111+

    )). Which of the following is the binary translation of signe! !ecimal "" ?

    a. 11+11111

    b. 1+1+1+11

    c. 11++11++

    !. 111+++11

    Chapter 2 Test Bank Note to instructors: To view the answers, select Tools | Options | View | Hidden Text in MS-Word.

    Fill in the Blanks and Short Answer

    1 #he techni0ue of executing instructions in parallel is calle! .

    )%. Which unit in the I*-"2 instruction cycle receives machine instructions from the :IF an! insertsthem into the instruction 0ueue?

    )&. Which unit in the I*-"2 instruction cycle performs page protection checks?

    ) . Which component of an operating system is responsible for switching control between tasks?

    )(. I!entify three types of segments that woul! be reference! by segment registers.

    %+. If you were to multiply 1.) by 2.%, which part of the / F woul! you use?

    %1. Came two 8I /-like features incorporate! by Intel into the I*-"2 family.

    %2. In the lat segmentation mo!el, which table hol!s the a!!resses of segments?

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition &

  • 8/9/2019 All Answers (2)

    8/63

    %". 9ist at least five types of ports foun! on a typical / motherboar!.

    %'. Which support processor synchroniJes the / F an! the rest of the computer?

    %). Which support processor transfers !ata to the printer?

    %%. Why are serial ports typically slower than parallel ports?

    Multiple-Choice

    %&. Which two "2-bit registers are known as exten!e! in!ex registers?

    a. I, AI

    b. ;*3, ;:3

    c. ; I, ;AI

    !. ;: , ;

    % . What is the name of the lowest bits of the ;A3 register?

    a. A9 b. AE

    c. A3

    !. none of the above

    %(. Eow much memory can be a!!resse! in 8eal-a!!ress mo!e?

    a. %'+ 7

    b. 1 B:

    c. 1% B:

    !. ' K:

    &+. Eow much memory can be a!!resse! in rotecte! mo!e?

    a. %'+ 7

    b. 1 B:

    c. 1% B:

    !. ' K:

    &1. What special feature makes

  • 8/9/2019 All Answers (2)

    9/63

    !. + 2h

    &". Which type of ILD !evice uses the 1%))+ F*8# chip?

    a. F : port

    b. printer port

    c. serial port!. parallel port

    &'. If you wante! to turn a !evice on an! off using computer software, which type of port interfacewoul! be best?

    a. F :

    b. keyboar!

    c. serial

    !. parallel

    &). What is the name of the bus architecture commonly use! with entium processors?

    a. I *

    b. /I

    c. ;I *

    !. 8*B-:F

    &%. egment-offset a!!ressing is use! in which processor mo!e4s5?

    a. rotecte!

    b.

  • 8/9/2019 All Answers (2)

    10/63

    c. :ID programs are only use! by the operating system in 8eal-a!!ress mo!e

    !. !evice !rivers have more !irect access to har!ware than :ID programs

    +. *n interpreter program insi!e the / F is written in a language calle! a4n5 .

    a. machine language interpreter

    b. !igital !river programc. microprogram

    !. system !eco!er

    1. If you wante! to fin! out whether an integer containe! an even number of 1 bits, which status flagwoul! be useful?

    a. carry

    b. overflow

    c. sign

    !. parity

    2. In regar! to multitasking, a task s state consists of which three elements?

    a. status flags, program counter, register contents

    b. register contents, task variables, program counter

    c. task variables, segment !escriptor, register contents

    !. segment !escriptor, status flags, task variables

    ". Within the / F, all calculations an! logic operations take place insi!e the .

    a. registers

    b. *9F

    c. /F!. B:F

    '. #he three types of buses connecte! to the / F are$

    a. !ata, a!!ress, control

    b. !ata, system, a!!ress

    c. a!!ress, control, memory

    !. fetch-!eco!e, control, execution

    ). If a clock oscillates 1+ billion times per secon!, what is the !uration of a single clock cycle?

    a. 1 nanosecon!

    b. 1.+ x 1+ -( secon!s

    c. 1.+ x 1+ 1+ secon!s

    !. 1.+ x 1+ -1+ secon!s

    %. Auring which phase of the instruction execution cycle is the program counter incremente!?

    a. !eco!e

    b. execute

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 1+

  • 8/9/2019 All Answers (2)

    11/63

    c. operan! fetch

    !. fetch

    &. #he control unit 4/F5 coor!inates the se0uencing of steps involve! in executing machineinstructions.

    a. #rue

    b. alse

    . #he *9F performs only a!!ition, subtraction, multiplication, an! !ivision operations.

    a. #rue

    b. alse

    (. Aata travels along a bus one bit at a time.

    a. #rue

    b. alse

    (+. #he most basic unit of time for machine instructions is calle! the !achine c"cle .

    a. #rue

    b. alse

    (1. #he upper half of the ;*3 register is calle! *3.

    a. #rue

    b. alse

    (2. #he lower half of the ;:3 register is calle! :3.

    a. #rue

    b. alse

    (". #he Dverflow flag is base! on signe! arithmetic.

    a. #rue

    b. alse

    ('. #he >ero flag is clear when the result of an arithmetic operation is Jero.

    a. #rue

    b. alse

    (). 8egisters in the floating-point unit are + bits long.

    a. #rue

    b. alse

    (%. Bicroprograms are interprete! an! execute! by machine instructions.

    a. #rue

    b. alse

    (&. In 8eal-a!!ress mo!e, only one program can run at a time.

    a. #rue

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 11

  • 8/9/2019 All Answers (2)

    12/63

    b. alse

    ( . In

  • 8/9/2019 All Answers (2)

    13/63

    !. paging unit

    1+%.What are the six stages, or units involve! in executing a single I*-"2 instruction?

    a. co!e prefetch, instruction !eco!e, execution, segment, paging, memory store

    b. bus interface, instruction !eco!e, parallel analysis, execution, segment, paging

    c. bus interface, co!e prefetch, instruction !eco!e, execution, segment, paging!. bus interface, co!e prefetch, instruction !eco!e, execution, a!!ress translation, paging

    1+&.Which flag is set when an unsigne! value is too large to fit into a !estination operan!?

    a. ign

    b. /arry

    c. Dverflow

    !. *uxiliary /arry

    1+ .In a '-stage non-pipeline! processor, how many clock cycles are re0uire! to execute "instructions? 4*ssume that each stage executes in a single clock cycle.5

    a. 12

    b.

    c. %

    !. cannot be !etermine!

    1+(.In a '-stage single-pipeline! processor, how many clock cycles are re0uire! to execute "instructions? 4*ssume that each stage executes in a single clock cycle.5

    a. 12

    b.

    c. %

    !. cannot be !etermine!

    11+.In a %-stage !ual-pipeline! processor, how many clock cycles are re0uire! to execute )instructions? 4*ssume that stage ' re0uires two clock cycles, an! that stage ' has two pipelines.5

    a. 1+

    b. 11

    c. 12

    !. 1)

    111. Which of the following correctly !escribes the se0uence of rea!ing from memory !uring a singleclock cycle?

    a. 8ea! line set lowM *!!ress place! on busM Dperan! place! on !ata bus by memorycontrollerM 8ea! line set high, in!icating that !ata bus contains the re0ueste! !ata.

    b. *!!ress place! on busM Dperan! place! on !ata bus by memory controllerM 8ea! line setlowM 8ea! line set high, in!icating that !ata bus contains the re0ueste! !ata.

    c. *!!ress place! on busM 8ea! line set lowM 8ea! line set high, in!icating that !ata buscontains the re0ueste! !ataM Dperan! place! on !ata bus by memory controller.

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 1"

  • 8/9/2019 All Answers (2)

    14/63

    !. *!!ress place! on busM 8ea! line set lowM Dperan! place! on !ata bus by memorycontrollerM 8ea! line set high, in!icating that !ata bus contains the re0ueste! !ata.

    112.Which register is known as a loop counter?

    a. ;*3

    b. ;:3c. ;/3

    !. ;A3

    11".Which mo!e is the native state of the Intel processor?

    a. rotecte! mo!e

    b.

  • 8/9/2019 All Answers (2)

    15/63

    b. complex high-level instructions

    c. re0uires microco!e interpreter

    !. instructions are execute! !irectly by har!ware

    11(.Which of the following is4are5 a!vantages of F : ports over parallel ports?

    a. bi!irectional !ata transfer b. 0uery !evices to get name an! type of !evice

    c. permits a hub to be connecte!

    !. can suspen! power to !evices

    12+.Which type of output is the most general an! portable to !ifferent computer systems?

    a. writing !irectly to vi!eo memory

    b. using /@@ stream output statements

    c. calling operating system functions

    !. calling :ID functions

    121.Which type of output will execute the most 0uickly?

    a. writing !irectly to vi!eo memory

    b. using /@@ stream output statements

    c. calling operating system functions

    !. calling :ID functions

    Chapter 3 Test Bank Note to instructors: To view the answers, select Tools | Options | View | Hidden Text in MS-Word.

    Fill in the Blanks and Short Answer

    1 how an example of a vali! hexa!ecimal integer constant.

    122. how an example of a vali! -bit binary integer constant.

    12". how an example of an integer expression that performs both multiplication an! mo!ulusarithmetic.

    12'.What is the or!er of operations in the expression % @ 2) N ' ?

    12).* comman! that is recogniJe! an! execute! by the assembler while the source co!e is beingassemble! is a4n5 .

    12%.* is a wor! that has special meaning to the assembler an! can only be use! in itscorrect context.

    12&.I!entify two types of labels in assembly language programs.

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 1)

  • 8/9/2019 All Answers (2)

    16/63

    12 . how an example of an instruction mnemonic.

    12(.Which !irective enables block-style comments?

    1"+.In the *!! ub program in ection ".2, which statement !isplays the contents of the registers?

    1"1.In the *!! ub program in ection ".2, which !irective marks the last line in the program?

    1"2.In the *!! ub program in ection ".2, which !irective copies necessary !efinitions an! setupinformation from a text file?

    1"".Which !irective is use! when !efining signe! 1%-bit integers?

    1"'.Which !irective is use! when !efining unsigne! 1%-bit integers?

    1").Which !irective is use! when !efining signe! "2-bit integers?

    1"%.Which !irective is use! when !efining unsigne! 1%-bit integers?

    1"&.Which !irective is use! when !efining +-bit integers?

    1" .Which !irective can by use! in place of the :=#; !irective for unsigne! integers?

    1"(.Write a !ata !efinition statement that creates a signe! 1%-bit integer name! myWord an! leavesits contents uninitialiJe!.

    1'+.Which !irective !efines a segment containing only uninitialiJe! !ata?

    1'1.Aeclare a symbolic constant name! /DFC# that e0uals 2). /DFC# 2) 4or /DFC# ;OF2)5

    1'2.Fse /DFC# from the previous 0uestion in a !ata !efinition statement that creates an uninitialiJe!array of "2-bit unsigne! integers name! myArray .

    1'".Kiven the following array !efinition, write a constant !eclaration name! ArraySize thatautomatically calculates the siJe in bytes, of the array$

    newArray DWORD 10,20,30,40,50

    Multiple-Choice

    1''.Which !irective i!entifies the part of a program containing instructions?

    a. .A*#*

    b. ./DA;

    c. . #*/7

    !. . 8DK

    1').Which !irective4s5 are use! when !efining both signe! an! unsigne! %'-bit integers?

    a. OWD8A an! OWD8A

    b. AWD8A

    c. OWD8A

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 1%

  • 8/9/2019 All Answers (2)

    17/63

    !. AWD8A an! AWD8A

    1'%.In the *!! ub program in ection ".2, the exit statement calls which pre!efine! B -Win!owsfunction to halt the program?

    a. Ealt rogram

    b. ;xit rocess

    c. D 8eturn

    !. ;xit rogram

    1'&.Which of the following are vali! !ata !efinition statements that create an array of unsigne! bytescontaining !ecimal 1+, 2+, an! "+, name! myArray .

    a.

    b.

    c.

    !.1' .In the following !ata !efinition, assume that List2 begins at offset 2+++h. What is the offset of the

    thir! value 4)5?

    List2 WORD 3,4,5, ,!

    a.

    b.

    c.

    !.

    1'(.Which letter choice shows the memory byte or!er, from low to high a!!ress, of the following !ata

    !efinition?"i#$a% DWORD 12345 !&'

    a.

    b.

    c.

    !.

    1)+.Kiven the following array !efinition, which letter choice contains a vali! constant !eclarationname! ArrayCount that automatically calculates the number of elements in the array?

    newArray DWORD 10,20,30,40,50

    a. b.

    c.

    !.

    1)1. elect a !ata !efinition statement that creates an array of )++ signe! !oublewor!s name! myList an! initialiJes each array element to the value 1.

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 1&

  • 8/9/2019 All Answers (2)

    18/63

    a.

    b.

    c.

    !.

    1)2.Which of the following !efines a text macro name! M SSA! that contains this string !ata? # - at t'is. ,0

    a.

    b.

    c.

    !.

    1)".Which !irective is use! when !efining %'-bit I;;; long reals?

    a. 8;*9'

    b. 8;*9

    c. 8;*9%'

    !. 8;*9

    1)'.* character constant must be enclose! in single 0uotes.

    a. #rue

    b. alse

    1)).*n i!entifier in assembly language may not be more than 2'& characters long.

    a. #rue

    b. alse

    1)%.*n i!entifier may begin with a !igit.

    a. #rue

    b. alse

    1)&.#he following is a vali! i!entifier$ *:P%2 Q

    a. #rue

    b. alse

    1) .#he following is a vali! i!entifier$ *:%2 Q #

    a. #rue

    b. alse

    1)(.* label use! for !ata must not en! with a colon 4$5.

    a. #rue

    b. alse

    1%+.* co!e label always en!s with a colon 4$5.

    a. #rue

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 1

  • 8/9/2019 All Answers (2)

    19/63

    b. alse

    1%1.#he 8D/ !irective marks both the beginning an! en!ing of a proce!ure.

    a. #rue

    b. alse

    1%2.#he ./DA; !irective must always occur before the .A*#* !irective.

    a. #rue

    b. alse

    1%".In the following statement, ;*3 is calle! the destination operan!$

    / AX,10000'

    a. #rue

    b. alse

    1%'.If the source co!e for an assembly language program is mo!ifie!, you must run both the assembler an! linker to up!ate the program s executable co!e.

    a. #rue

    b. alse

    1%).#he listing file !oes not contain a !isassembly of each instruction.

    a. #rue

    b. alse

    1%%.#he listing file contains a list of segments an! groups in a program.

    a. #rue

    b. alse

    1%&.#he listing file contains a list of program symbols.

    a. #rue

    b. alse

    1% .#he following is a vali! !ata !efinition statement$

    'e%% tr WORD 10000',20000'

    a. #rue

    b. alse

    1%(.#he following is a vali! !ata !efinition statement$

    'e%% tr DWORD 2

    a. #rue

    b. alse

    1&+.#he following is a vali! !ata !efinition statement$

    str1 "Y 'is strin# is ite % n#. ,0

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 1(

  • 8/9/2019 All Answers (2)

    20/63

    a. #rue

    b. alse

    1&1.#he following are both vali! !ata !efinition statements$

    List1 "Y 10,20 "Y 30,40

    a. #rue

    b. alse

    1&2.#he following se0uence of statements is invali!$

    67 -e/ ea8,e-8

    6-atay"yte "Y 10

    67 -e/ a%, y"yte

    a. #rue

    b. alse

    1&".#he ;OF !irective permits a constant to be re!efine! at any point in a program.

    a. #rue

    b. alse

    1&'.#he #;3#;OF !irective permits a constant to be re!efine! at any point in a program.

    a. #rue

    b. alse

    "Some o# t$e #o%%o&in' (uestions $a e more t$an one *orre*t ans&er. Cir*%e a%% *orre*t ans&ers.)

    1&).#he two types of real-number constants are$

    a. !ecimal, binary

    b. enco!e!, binary

    c. !ecimal, enco!e!

    !. :/A, * /II

    1&%.Which of the following are true about assembly language instructions an! !irectives?

    a. a !irective is execute! at runtime

    b. an instruction is execute! at runtime

    c. a !irective is execute! at assembly time

    !. an instruction is execute! at assembly time

    1&&.#he basic parts of an instruction, in or!er from left to right, are$

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 2+

  • 8/9/2019 All Answers (2)

    21/63

    a. label, mnemonic, operan!4s5, comment

    b. comment, label, mnemonic, operan!4s5

    c. label, mnemonic, comment

    !. mnemonic, operan!4s5, comment

    1& .Dperan!s may be any of the following$

    a. constant or constant expression

    b. reserve! wor!

    c. register name

    !. variable name 4memory5

    1&(.Which util ity program rea!s an assembly language source file an! pro!uces an ob6ect file?

    a. compiler

    b. linker

    c. assembler

    !. loa!er

    1 +.* ma+ file is pro!uce! by which of the following utility programs?

    a. assembler

    b. linker

    c. loa!er

    !. text e!itor

    1 1.Which file4s5 contain a human-rea!able listing of segment 4an! segment group5 names?

    a. listing

    b. source

    c. map

    !. executable

    1 2.Which of the following will generate assembly errors?

    a. var1 :=#; 11+1b, 22, ")

    b. var2 :=#; *:/A; ,1

    c. var" :=#; Q , ( && ,

    !. var' :=#; 2)%,1(,'+

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 21

  • 8/9/2019 All Answers (2)

    22/63

    1 ".#he byte-or!ering scheme use! by computers to store large integers in memory with the high-or!er byte at the lowest a!!ress is calle!$

    a. big en!ian

    b. byte-ma6or

    c. little en!ian

    !. byte-minor

    Chapter 4 Test Bank Note to instructors: To view the answers, select Tools | Options | View | Hidden Text in MS-Word.

    Fill in the Blanks and Short Answer Fse the following !ata !efinitions until notifie! otherwise$

    9yte1 "Y 0::',1,29yte2 "Y 14'w r-1 WORD 0::::',1,2w r-2 WORD 3w r-3 WORD !:::',&000'w r-4 WORD 000'-w r-1 DWORD 10',20',30',40'-Array DWORD 10 D< (>)

    1 '.Write one or more statements that move the contents of &ord to &ord2 .

    1 ). or each of the following instructions, in!icate whether it is legal 495 or illegal 4I5$

    a6 / 9yte2,0::'96 / w r-1,9yte276 / w r-2,10000'-6 / si,w r-1

    1 %. or each of the following instructions, in!icate whether it is legal 495 or illegal 4I5$

    a6 /?8 a8,9yte196 /?8 e-8,9%76 /?8 w r-2,a%-6 /s8 -%,a%

    1 &.In!icate the hexa!ecimal value of the !estination operan! next to each instruction. Fse the letter Ito in!icate that a particular instruction is illegal$

    / -8,w r-3 a6/s8 ea8,9yte1 96

    / -',a% 76/ 98,-8 -6

    1 .In!icate the hexa!ecimal value of the !estination operan! next to each instruction. Fse the letter Ito in!icate that a particular instruction is illegal$

    / a8,@w r-3+2 a6/ ea8,@-w r-1+4 96/ a%,@9yte1+1 76/ ea8,@w r-3+4 -6

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 22

  • 8/9/2019 All Answers (2)

    23/63

    1 (.Where marke! by a letter 4a, b, c, !5, in!icate the hexa!ecimal value of the !estination operan!$

    / a8,w r-1in7 a8 a6-e7 a8 96

    / a8,w r-3ne# a8 76a-- a8,0B2A5' -6

    1(+.Where marke! by a letter 4a, b, c, !5, in!icate the hexa!ecimal value of the !estination operan!$

    / a%,!:'a-- a%,2 aC :,B:, :,O:=s 9 a%,5 9C :,B:, :,O:=

    / a%,&0'a-- a%,&0' 7C :,B:, :,O:=ne# a% -C :,B:, :,O:=

    1(1.Which instruction loa!s the low byte of the ; 9*K register into *E?

    1(2.Write an instruction that moves the "2-bit a!!ress of &ord into the ; I register 4assume "2-bitrotecte! mo!e5.

    1(".Write an instruction that moves the lower 1% bits of d&ord into the :3 register 4 hint: use #85.

    1('.Write an instruction that moves the lower bits of &ord2 into the *9 register.

    1().Write an instruction that moves ;:3 to location &ord $

    1(%.What is the value of the expression 4#= ; wor!15?

    1(&.What is the value of the expression 4#= ; !wor!15?

    1( .What is the value of the expression 49;CK#ED wor!15?

    1((.What is the value of the expression 4 I>;D wor!15?

    Short Programming ProblemsFse the following !ata !efinitions until notifie! otherwise$

    9yte1 "Y 0::',1,29yte2 "Y 14'w r-1 WORD 0::::',1,2w r-2 WORD 3w r-3 WORD !:::',&000'w r-4 WORD 000'-w r-1 DWORD 10',20',30',40'-Array DWORD 10 D< (>)

    2++.Implement the following expression in assembly language, using "2-bit integers 4you may mo!ifyany registers you wish5$

    ea8 = -w r-1 + e98 E e78

    2+1.Implement the following expression in assembly language, using "2-bit integers 4you may mo!ifyany registers you wish5$

    ea8 = E-w r-1 + (e-8 E e78) + 1

    2+2.Implement the following expression in assembly language, using "2-bit integers. #he notation!wor!R1S correspon!s to an array reference in /@@ or Gava$

    -Array@0 = -Array@1 + -Array@2

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 2"

  • 8/9/2019 All Answers (2)

    24/63

    2+".Fse the following !ata !eclarations to write an assembly language loop that copies the string fromsour*e to tar'et . Fse in!exe! a!!resing with ;AI, an! use the 9DD instruction.

    s r7e "Y trin# t 9e 7 Fie- ,0tar#et "Y O: s r7e D< (0),0

    Multiple-Choice2+'.#he following statement will assemble without errors$

    / WORD R @ea8 , 1234'

    a. true

    b. false

    2+).#he following instruction will pro!uce /h in ;*3$

    /s8 ea8,E4

    a. true

    b. false

    2+%.#he *E instruction copies the ign, Dverflow, an! /arry flags to the *9 register.a. true

    b. false

    2+&.#he following instructions will set the Dverflow flag$

    / a%,0D!'a-- a%,!4'

    a. true

    b. false

    2+ .#he following instruction will assemble$

    in7 @esia. true

    b. false

    2+(.#he following instructions will set the Dverflow flag$/ a%,125

    s 9 a%,E4

    a. true

    b. false

    21+.#he syntax for the BD< instruction is$ BD< destination , source .

    a. true

    b. false

    211.#he BD< instruction re0uires both operan!s to be the same siJe.

    a. true

    b. false

    212.#he BD< instruction permits a move between two memory operan!s.

    a. true

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 2'

  • 8/9/2019 All Answers (2)

    25/63

    b. false

    21".#he ;I register cannot be the !estination operan! of a BD

  • 8/9/2019 All Answers (2)

    26/63

    b. false

    22'.*!!ing & h an! +)h in an -bit register sets the Dverflow flag.

    a. true

    b. false

    22).*!!ing + h an! +)h in an -bit register sets the Dverflow flag.a. true

    b. false

    22%.*!!ing ) to + :h in an -bit register sets the >ero flag.

    a. true

    b. false

    22&.#he following instructions will set the /arry flag$/ a%,0: '

    s 9 a%,2

    a. true

    b. false

    22 .#he following instructions will set the ign flag$/ a%,0: '

    s 9 a%,2

    a. true

    b. false

    22(. elect the answer choice that best implements the following expression. Ao not permit d&ord ,;/3, or ;A3 to be mo!ifie!$

    ea8 = E-w r-1 + (e-8 E e78) + 1

    a./ ea8,-w r-1

    ne# ea8s 9 e-8,e78a-- ea8,e-8in7 ea8

    b./ ea8,-w r-1

    ne# ea8/ e98,e-8

    s 9 e98,e78a-- ea8,e98in7 ea8

    c. ne# -w r-1/ e98,e-8

    s 9 e98,e78a-- ea8,e98in7 ea8

    !./ ea8,-w r-1/ e-8,e98

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 2%

  • 8/9/2019 All Answers (2)

    27/63

    s 9 e98,e78a-- ea8,e98in7 ea8

    Some o# t$e #o%%o&in' (uestions $a e more t$an one *orre*t ans&er. Cir*%e a%% *orre*t ans&ers-

    Fse the following !ata !efinitions until notifie! otherwise$9yte1 "Y 0::',1,29yte2 "Y 14'w r-1 WORD 0::::',1,2w r-2 WORD 3w r-3 WORD !:::',&000'w r-4 WORD 000'-w r-1 DWORD 10',20',30',40'-Array DWORD 10 D< (>)

    2"+.What is the hexa!ecimal value of *3 when this co!e executes?

    / esi,O:: w r-1a-- esi,4

    / a8,@esia. 1

    b. 2

    c. h

    !. "

    2"1.What is the final hexa!ecimal value of *3 when this co!e executes?

    / e98,O:: -w r-1s 9 e98,2

    / a8,@e98

    a. ++++h

    b. ++1+h

    c. (+++h

    !. ++2+h

    2"2.What is the final hexa!ecimal value of *9 when this co!e executes?

    / e98,O:: 9yte1/ a%,@e98+3

    a. 1

    b. 2

    c. 1'h

    !. "

    2"".What is the final hexa!ecimal value of ;*3 when this co!e executes?

    / e-8,&/ ea8,-w r-1@e-8

    a. ++++++1+h

    b. 2+++++++h

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 2&

  • 8/9/2019 All Answers (2)

    28/63

    c. ++"+++++h

    !. ++++++"+h

    2"'.In rotecte! mo!e, which of the following !efine4s5 a pointer variable containing the offset of&ord ?

    a. ptr1 AWD8A wor!1

    b. wor!1 AWD8A ptr1

    c. ptr2 AWD8A #8 wor!1

    !. ptr2 AWD8A D ;# wor!1

    2"). uppose the statement WD8A #= ;A; #8 AWD8A has alrea!y appeare! in a program.Which of the following !ata !eclarations woul! be correct?

    a. #8 AWD8A var1 ?

    b. var2 WD8A ?

    c. var" #8 AWD8A ?

    !. var' #8 WD8A ?

    Example 21C 6-ata2C /arX DWORD ,&,!, ,5,4,3,2,1,03C /arY DWORD (L GH IO: /arX) D< (0)4C 67 -e5C / esi,O:: /arY + ( O: /arX) E 4

    C / e-i,4!C / e78,L GH IO: /arX E 1&C L1C / ea8,/arX@e-i

    C / @esi ,ea810C a-- e-i,411C s 9 esi,412C % F L1

    2"%.8efer to ;xample 2. *fter the loop executes, what will be the values at locations var=, var=@',an! var=@ ?

    a. +, +, +

    b. +, 1, 2

    c. 1, 2, "

    !. +, +, 1

    2"&.8efer to ;xample 2. *fter the loop executes, what will be the values in the last three positions4array elements5 of var=?

    a. +, +, +

    b. , (, +

    c. %, &,

    !. &, , (

    2" .8efer to ;xample 2. If line ( were change! to the following, what woul! be the final values atlocations var=, var=@', an! var=@ ?

    C / @esiE4 ,ea8

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 2

  • 8/9/2019 All Answers (2)

    29/63

    a. +, +, +

    b. +, 1, 2

    c. 1, 2, "

    !. +, +, 1

    se t$e #o%%o&in' data #or t$e remainin' (uestions in t$is se*tion- word1 WORD 1000h,2000h,3000h,4000h,5000h

    dword1 DWORD 10000h,20000h,30000h,40000h

    2"(.What is the final value of *3 after this co!e has execute!?

    / esi,O:: w r-1/ e78,5/ ea8,100'

    L1C a-- a8,@esia-- a8,1a-- esi, Y w r-1

    L F L1a. 1)+h

    b. +1)+h

    c. +1%h

    !. ++1%h

    2'+.What is the final value of *3 after this co!e has execute!?

    / e-8,O:: w r-1+&/ e78,2/ a8,0

    L1C / a8,@e-8a-- a8,20's 9 e-8,4L F L1

    a. +'+h

    b. (+'+h

    c. '+2+h

    !. "+2+h

    2'1. uppose we want ;*3 to contain the sum of the d&ord array when the following 4incomplete5co!e finishes executing$

    1C / e-i,O:: -w r-12C / e78,L GH IO: -w r-13C >4C >5C >

    C % F L1

    Which of the following choices woul! best fill in lines ", ', an! )?

    a.3C / ea8,@e-i

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition 2(

  • 8/9/2019 All Answers (2)

    30/63

    4C L1C a-- ea8,-w r-15C a-- e-i,2

    b.3C / ea8,04C L1C a-- ea8,@e-i5C a-- e-i, Y -w r-1

    c.3C / ea8,04C L1C a-- ea8,@e-i5C a-- e-i,2

    !.3C / DWORD R @e-i ,04C L1C a-- ea8,@e-i5C a-- e-i, Y -w r-1

    Chapter 5 Test Bank

    Note to instructors: To view the answers, select Tools | Options | View | Hidden Text in MS-Word.

    True/False1 * link library contains proce!ures that have alrea!y been assemble! into ob6ect co!e.

    2'2.#he 8D#D !irective is re0uire! when calling a library proce!ure.

    2'".#he assembler knows the exact a!!ress of a library proce!ure.

    2''.#he linker combines ob6ect files into an executable file.

    2').#he Irvine"2.lib proce!ures cannot link !irectly to kernel"2.lib

    2'%.7ernel"2.!ll is calle! a d"na!ic lin# li rar" .

    2'&.8eal-mo!e programs shoul! link to Irvine1%.lib.

    2' .#he 8ea! tring proce!ure inserts a carriage return 4+Ah5 at the en! of the input string.

    2'(.#he 8ea!/har proce!ure echoes the input character on the screen.

    2)+.#he 8an!om"2 proce!ure limits the largest ran!om number to + h

    2)1.#he Write:in proce!ure !oes not !isplay lea!ing Jeros.

    2)2.#he WriteEex proce!ure !oes not !isplay lea!ing Jeros.

    2)".#he WriteAec proce!ure !oes not !isplay a minus sign.

    2)'.#he first value a!!e! to a stack is also the first one to be remove!.

    2)).#he runtime stack is manage! by the / F an! supporting har!ware.

    2)%.#he register points to the last value pushe! on the stack.

    2)&.When using the Irvine"2 library, you shoul! always push "2-bit values on the stack.

    2) .#he D instruction copies a value from the stack to an operan! before incrementing the stack pointer.

    2)(.In rotecte! mo!e, imme!iate values pushe! on the stack are always "2 bits long.

    2%+.#he F E* instruction pushes all the "2-bit general-purpose registers on the stack.

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition "+

  • 8/9/2019 All Answers (2)

    31/63

    Fill in the Blanks and Short Answer 2%1.Which file acts as a bri!ge between Irvine"2.lib an! kernel"2.!ll?

    2%2.Which ILD !evice is use! for stan!ar! input?

    2%".Which library proce!ure writes a single character to stan!ar! output?

    2%'.Which library proce!ure locates the cursor at a specific row an! column on the screen?2%).Which library proce!ure rea!s a "2-bit signe! !ecimal integer from stan!ar! input?

    2%%.Which library proce!ure !isplays the / F flags an! "2-bit registers?

    2%&.Which library proce!ure generates a "2-bit pseu!oran!om integer in a caller-specifie! range?

    2% .Which library proce!ure writes an unsigne! "2-bit integer to stan!ar! output in hexa!ecimalformat?

    2%(.Which library proce!ure rea!s a string from stan!ar! input?

    2&+.Which register contains the offset of a character array when calling Ket/omman!#ail?

    2&1.Which register contains an integer before calling WriteAec?

    2&2.Which register contains the starting a!!ress of !ata when calling AumpBem?

    2&".Write co!e that causes a )++ millisecon! !elay, using a library proce!ure.

    2&'.Write a statement that moves a vi!eo color constant to ;*3. #he constant shoul! represent blacktext on a white backgroun!, using the constants !escribe! in the Irvine"2.inc file.

    2&).What will be the value of ;*3 when the following se0uence of instructions has execute!?F s' 5F s' 10F s' 20F F ea8

    2&%.What will be the value of ;*3 when the following se0uence of instructions has execute!?

    F s' 5F s' 10F F e98F F ea8

    2&&.What will be the value of ;/3 when the following se0uence of instructions has execute!?F s' 5F s' 10F F e98F F ea8F F e78

    Short Programming Problems

    2& .Write a se0uence of statements that rea! a signe! integer from stan!ar! input an! write the sameinteger to stan!ar! output. Fse library proce!ures.

    2&(.Kiven the following string !efinition, write a se0uence of statements that write the string tostan!ar! output. Fse a library proce!ure.

    str1 "Y DisF%ay t'is strin# ,0

    2 +.Kiven the following !ata !efinition, write a se0uence of statements that !isplay a !ump of the !atain "2-bit hexa!ecimal, using the /um+Mem proce!ure from the link library.

    array DWORD 10',20',30',40'

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition "1

  • 8/9/2019 All Answers (2)

    32/63

    2 1.Write statements that use library proce!ures to generate a single unsigne! pseu!oran!om integer between + an! ((( an! write it to stan!ar! output$

    2 2.Write a proce!ure name! S$o&0inary that !isplays the following array as a se0uence of binary bits. Inclu!e the use of the 9;CK#ED , D ;#, an! #= ; operators, an! call the Write0in proce!ure.

    array DWORD 10',20',30',40'

    2 ".Write a proce!ure name! 1ead that rea!s exactly ten characters from stan!ar! input into anarray of :=#; name! myStrin' . Fse the 9DD instruction with in!irect a!!ressing, an! call the1eadC$ar proce!ure from the book s link library. 48ea!/har returns its value in *9.5

    2 './o!e a 8D/ !eclaration for a proce!ure name! MySu . Fse the F ; operator to preserve the;*3 an! ;:3 registers.

    2 ).Araw a flowchart that correspon!s to the following co!e$/ e78,L GH IO: array/ ea8,0/ esi,O:: array

    L1C a-- ea8,@esia-- esi, Y array

    % F L1/ s ,ea8

    Multiple-Choice4 ome of the following 0uestions have more than one correct answer. /ircle all correct answers.5

    2 %.Which of the following /*99 instructions writes the contents of ;*3 to stan!ar! output as asigne! !ecimal integer?

    a. call WriteInteger

    b. call WriteAec

    c. call WriteEex

    !. call WriteInt

    2 &.Which of the following co!e se0uences assigns the value 1+h to ;:3?

    a./ e-8,20'

    F s' e-8/ e78,10'

    F s' e78F F e98F F e-8

    b./ e78,10'

    / e-8,20'F s' e78F s' e-8F F e98F F e-8

    c.F s' 20'

    / e78,10'F s' e78

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition "2

  • 8/9/2019 All Answers (2)

    33/63

    F F ea8F F e98

    !.F s' 30'F s' 10'F s' 20'

    F F e-8F F e98F F ea8

    2 .#he process of !ivi!ing a problem into general tasks, an! then separating general tasks into morespecific tasks is calle! . . .

    a. process-oriente! !esign

    b. functional !ecomposition

    c. top-!own !esign

    !. ob6ect-oriente! !esign

    2 (.Which of the following are vali! !esign criteria for the Integer ummation rogram 4 ection ).%5?

    a. separate proce!ures make the program run faster

    b. separate proce!ures make the program s structure easier to un!erstan!

    c. 9DD instructions might be out of range if all co!e were place! in the main proce!ure

    !. the program is easier to maintain an! un!erstan! when all the co!e is in a single proce!ure

    2(+.Which of the following are true about the F E instruction?

    a. It !ecrements the stack pointer 4by 2 or '5 an! copies the operan! into the stack at the location pointe! to by the stack pointer.

    b. It copies the operan! into the stack at the location pointe! to by the stack pointer, an! then!ecrements the stack pointer 4by 2 or '5.

    c. It increments the stack pointer 4by 2 or '5 an! copies the operan! into the stack at the location pointe! to by the stack pointer.

    !. It increments the stack pointer by 1 an! copies the operan! into the stack at the location pointe!to by the stack pointer.

    Chapter 6 Test Bank Note to instructors: To view the answers, select Tools | Options | View | Hidden Text in MS-Word.

    True/False1 or any two integers n an! ! , 44n 3D8 ! 5 3D8 ! 5 pro!uces n.

    2(1.#he *CA instruction has only one operan!.

    2(2.#he #; # instruction !oes not alter the !estination operan!.

    2(".#he D8 instruction can be use! to set an operan! s value to Jero.

    2('.#he 3D8 instruction can be use! to toggle 4complement5 the bits in a number.

    2().#he D8 instruction mo!ifies the ign, >ero, an! arity flags accor!ing to the value of the!estination operan!.

    2(%.#he arity flag in!icates whether the lowest wor! of a !estination operan! has an even number of1 bits.

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition ""

  • 8/9/2019 All Answers (2)

    34/63

    2(&.#he CD# instruction reverses the sign of a number.

    2( .#he G: instruction 6umps if the 4unsigne!5 first operan! is less than the 4unsigne!5 secon!operan!.

    2((.#he GK instruction is use! when comparing unsigne! integers.

    "++.#he GD instruction is use! after an operation involving signe! integers.

    "+1.#he G/3> instruction 6umps to a target label when the ;/3 register is e0ual to Jero.

    "+2.#he :#8 instruction copies a selecte! bit into the /arry flag an! clears the selecte! bit.

    "+".#he :# instruction copies a selecte! bit into the >ero flag.

    "+'.#he 9DD > instruction 6umps to a target label when the >ero flag is set an! ;/3 is greater thanJero.

    "+).* WEI9; loop can be constructe! with a /B instruction at the bottom of the loop, followe! by acon!itional 6ump instruction.

    "+%.In a finite-state machine, transitions between states usually occur when a new value has been rea!from input.

    "+&.#he following finite-state machine coul! be use! to successfully vali!ate the string 2"'@ $

    Fill in the Blanks and Short Answer "+ .In the following instruction se0uence, show the change! values of *9 where in!icate!, in binary$

    / a%,110011119an- a%,001010119 ; a6

    / a%,4"'an- a%, B' ; 96

    / a%,001111009r a%,&2' ; 76

    / a%, 4'8 r a%,3!' ; -6

    "+(.In the following instruction se0uence, show the change! values of *9 where in!icate!, inhexa!ecimal$

    / a%, B'n t a% ; a6

    / a%,4"'an- a%,!4' ; 96

    / a%,& 'r a%,42' ; 76

    / a%,!2'8 r a%,0A5' ; -6

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition "'

    start

    digit

    +,-

    digit digit

    A B

    C

  • 8/9/2019 All Answers (2)

    35/63

    "1+.In the following instruction se0uence, show the values of the /arry, >ero, an! ign flags wherein!icate!$

    / a%,001100119test a%,2 ; a6 B:= := :=

    / a%,7 F a%,5 ; 96 B:= := :=

    / a%,57 F a%,! ; 76 B:= := :=

    "11./o!e a single instruction that clears bits +, ", an! ' in the *9 register.

    "12./o!e instructions that 6ump to the label 91 when either bit 2 or " is set in the A9 register 4!o notmo!ify A95.

    "1"./o!e instructions that 6ump to the label 92 when the signe! integer in :9 is greater than ).

    "1'./o!e a single instruction that complements all bits in *9, without using the 3D8 instruction.

    "1)./o!e instructions that 6ump to label 9" when the *3 register has even parity.

    "1%./o!e a single instruction that inverts bits ) an! % in :9 without changing any other bits.

    "1&./o!e instructions that 6ump to label 9' if bits 1, 2, an! " are all set in the A9 register."1 ./o!e a label name! 4ere that can be the target of a 6ump instruction originating in a !ifferent

    proce!ure.

    "1(./o!e instructions that 6ump to label 9) when the :9 register has o!! parity. Ao not alter the valuein :9.

    "2+./o!e instructions that set the Dverflow flag. #hen co!e a 6ump instruction that 6umps to label 9%when the Dverflow flag has been set.

    "21./o!e instructions that implement the following pseu!oco!e using con!itional 6ump instructions.Ao not use the .I !irective. *ssume that integers are unsigne!$

    iJ( ea8 K e98 )/ -%,5;

    e%se/ -%, ;

    Multiple-Choice"22.What will be the hexa!ecimal value of *9 after these instructions execute?

    / a%,0B:'an- a%,2"'

    a. +:h

    b. ;*h

    c. +%h

    !. none of the above

    "2".What will be the hexa!ecimal value of *9 after these instructions execute?

    / a%,3B'r a%,&2'

    a. ";h

    b. :/h

    c. :;h

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition ")

  • 8/9/2019 All Answers (2)

    36/63

    !. none of the above

    "2'.What will be the hexa!ecimal value of *9 after these instructions execute?

    / a%, 4'8 r a%,3!'

    a. :&h

    b. *"h

    c. " h

    !. none of the above

    "2).Which answer choice shows the correct values of the /arry, >ero, an! ign flags after thefollowing instructions execute?

    / a%,001100119test a%,2

    a. / 1, > +, 1

    b. / +, > 1, +

    c. / 1, > +, 1!. / +, > +, +

    "2%.Which answer choice shows the correct values of the /arry, >ero, an! ign flags after thefollowing instructions execute?

    / a%,7 F a%,5

    a. / +, > +, +

    b. / 1, > +, +

    c. / 1, > 1, +

    !. / 1, > +, 1

    "2&.Which of the following selections contain instructions that 6ump to label 9' if bits 1, 2, an! " areall set in the A9 register?

    a.an- -%,0 'test -%,0 '

    n? L4

    b.test -%,0 '

    n? L4

    c.an- -%,0!'

    7 F -%,0!'e L4

    !.an- -%,0 '7 F -%,0 '

    e L4

    "2 .Which choices contain correct implementations of the following pseu!oco!e? 4*ssume that allvalues are unsigne!5$

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition "%

  • 8/9/2019 All Answers (2)

    37/63

    iJ( ea8 K e98 )/ -%,5;

    e%se/ -%, ;

    a.7 F ea8,e98

    a L1/ -%,F L2

    L1C / -%,5L2C

    b.7 F ea8,e98

    a L1/ -%,5F L2

    L1C / -%,L2C

    c. 7 F ea8,e989e L2

    / -%,5F L2

    L1C / -%,L2C

    !.7 F ea8,e98

    na L1/ -%,5F L2

    L1C / -%,

    L2C

    Fse the following !ata for the next two 0uestions. *ll values are signe!$

    6-ata/a%1 DWORD >/a%2 DWORD >

    "2(.Which selection is the correct implementation of the following pseu!oco!e?

    iJ( /a%1 K /a%2 MM /a%2 K ea8 ) / e98,1;e%se / e98,2;

    a./ /a%1,e98

    7 F e98,/a%2n# L1

    7 F /a%2,ea8# L1

    / e98,2F L2

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition "&

  • 8/9/2019 All Answers (2)

    38/63

    L1C / e98,1L2C

    b./ /a%1,e98

    7 F e98,/a%2# L1

    7 F /a%2,ea8# L1

    / e98,2F L2

    L1C / e98,1L2C

    c./ /a%1,e98

    7 F /a%2,e98# L1

    7 F /a%2,ea8# L2

    / e98,2F L2

    L1C / e98,1L2C

    !./ /a%1,e98

    7 F e98,/a%2%e L1

    7 F /a%2,ea8%e L1

    / e98,1F L2

    L1C / e98,2L2C

    ""+.Which selection correctly implements the following pseu!oco!e?

    w'i%e( int2 K= int1 )N

    a-- e98,2iJ( e98 K int2)

    / e98,0e%se / e98,int1

    a.t FC

    / ea8,int27 F ea8,int1

    n#e L3a-- e98,27 F e98,int2

    # L2/ e98,int1F L3

    L1C / e98,0

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition "

  • 8/9/2019 All Answers (2)

    39/63

    L2C F t FL3C

    b.t FC

    / ea8,int17 F ea8,int2

    % L3a-- e98,27 F e98,int2

    # L1/ e98,int1F L2

    L1C / e98,0L2C F t FL3C

    c.t FC

    / ea8,int27 F ea8,int1

    % L3a-- e98,27 F e98,int2

    # L1/ e98,int1F L2

    L1C / e98,0L2C F t FL3C

    !.t FC

    / ea8,int27 F ea8,int1

    % L3a-- e98,27 F e98,int2

    # L1/ e98,0F L2

    L1C / e98,int1L2C F t FL3C

    ""1. uppose ;*3, ;:3, an! ;/3 containe! three unsigne! integers. Which of the following co!eexcerpts woul! !isplay the largest of the three integers?

    a.7 F ea8,e98

    9 L1/ ea8,e98

    L1C 7 F ea8,e789 L2

    / ea8,e78L2C 7a%% Write nt

    b.7 F ea8,e98

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition "(

  • 8/9/2019 All Answers (2)

    40/63

    ae L1/ ea8,e98

    L1C 7 F ea8,e78ae L2

    / ea8,e78L2C 7a%% Write nt

    c.7 F ea8,e98

    nae L1/ ea8,e98

    L1C 7 F e78,ea8nae L2

    / ea8,e78L2C 7a%% Write nt

    !.7 F ea8,e78

    ae L1/ ea8,e98

    L1C 7 F ea8,e98

    ae L2/ ea8,e78

    L2C 7a%% Write nt

    ""2.What will be the final value of ; I when the following co!e executes?

    6-ataarray WORD &,2,3,5,E4, ,0,467 -e

    / esi,0/ e78,L GH IO: array

    L1C / a8,array@esi7 F a8,0F s'J

    a-- esi, Y arrayF FJL Fne L1

    a. +++++++%h

    b. +++++++&h

    c. +++++++/h

    !. +++++++;h

    """.What will be the final values of /3 an! A3 when the following co!e executes?

    6-ataarray WORD &,2,3,5,E4, ,0,467 -e

    / 78,1/ esi,2/ a8,array@esi/ 98,array@esi+4

    7 F a8,3ae L2

    7 F 98,49 L1

    F L3

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition '+

  • 8/9/2019 All Answers (2)

    41/63

    L1C / 78,4L2C / -8,5

    F L4L3C / -8,L4C

    a. /3 ', A3 )

    b. /3 1, A3 %

    c. /3 1, A3 )

    !. /3 ', A3 %

    ""'.In rotecte! mo!e 4flat mo!el5, which of the following /*99 instructions executes an in!irect callto a proce!ure whose a!!ress is store! in a memory location pointe! to by ;:3?

    a. call RebxS

    b. call AWD8A #8 RebxS

    c. call *8 RebxS

    !. call C;*8 #8 RebxS

    Chapter 7 Test Bank Note to instructors: To view the answers, select Tools | Options | View | Hidden Text in MS-Word.

    True/False1 #he E8 instruction is suitable only for unsigne! integers.

    "").#he E9 instruction is suitable only for unsigne! integers.

    ""%.#he *8 an! E8 instructions perform the same operation.

    ""&.#he BF9 instruction sets the Dverflow flag if the upper half of the pro!uct is e0ual to Jero.

    "" .#he BF9 instruction sets the /arry flag if the upper half of the pro!uct is not e0ual to Jero.

    ""(.When the BF9 /9 instruction executes, the 1%-bit pro!uct en!s up in the *3 register.

    "'+.When the BF9 :3 instruction executes, the "2-bit pro!uct en!s up in the ;*3 register.

    "'1.#he IBF9 instruction performs signe! integer multiplication.

    "'2.#he AI< instruction sets the Dverflow flag when a program attempts to !ivi!e by Jero.

    "'".#he following co!e will cause a Aivi!e Dverflow exception$/ a8,E12000000

    7w-

    / 98,10i-i/ 98

    Fill in the Blanks and Short Answer "''.What is the binary value of *9 after the following instructions have execute!?

    / a%,011010119s'r a%,2

    "').What is the binary value of *9 after the following instructions have execute!?

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition '1

  • 8/9/2019 All Answers (2)

    42/63

    / a%, 011010119r % a%,2

    "'%.What is the binary value of *9 after the following instructions have execute!?

    / a%,110001019sar a%,1

    "'&.What is the binary value of *9 after the following instructions have execute!?/ a%,110001019

    sar a%,4

    "' .What is the binary value of *9 after the following instructions have execute!?

    / a%,1000010197%7r7r a%,1

    "'(.What is the binary value of *9 after the following instructions have execute!?

    / a%,011010119st7r7% a%,2

    ")+.What is the binary value of *3 after the following instructions have execute!?

    / a8,00000000100111019/ 98,10101010100000009

    s'%- a8,98,1

    ")1.What is the binary value of *3 after the following instructions have execute!?

    / a8,00000000100111019/ 98,10101010100010119

    s'r- a8,98,2

    ")2.What will be the hexa!ecimal values of A3 an! *3 after the following instructions haveexecute!?

    / -8,5000'/ a8,10'% -8

    ")".What will be the value of the Dverflow flag after the following instructions have execute!?

    / -8,&00'/ a8,10'

    i % -8

    ")'.What will be the hexa!ecimal values of A3 an! *3 after the following instructions haveexecute!?

    / -8,E1/ a8,2

    i % -8")).What will be the hexa!ecimal values of A3 an! *3 after the following instructions have

    execute!?

    / -8,000:'/ a8, 342'/ 98,100'

    -i/ 98

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition '2

  • 8/9/2019 All Answers (2)

    43/63

    Short Programming Problems")%.Write a series of instructions that will multiply ;*3 by 1 , using a combination of shift, BD

  • 8/9/2019 All Answers (2)

    44/63

    a. A3 +1' h, *3 /%(1h

    b. A3 +12*h, *3 /(*2h

    c. A3 +12*h, *3 A%(2h

    !. A3 +2':h, *3 A%(2h

    "%).Kiven the following two assignments to *3 an! A3, which block of instructions will cause A3 toe0ual '+2)h an! *3 to e0ual 1*A2h?

    / a8, "4 '/ -8,00 5'

    a.s'r a8,1r7r -8,1s'r a8,1r7r -8,1

    b.s'r a8,2r7r -8,1

    s'% a8,1c.

    s'% a8,2s'r -8,1r7% -8,1

    !.s'r a8,1r7% -8,2r7r a8,1s'% -8,1

    "%%.Which of the following blocks of instructions will multiply the contents of the ;A3 register by"%?

    a./ e98,e-8

    s'% e-8,5s'% e98,2a-- e98,e-8

    b./ e98,e-8

    s'% e-8,5s'% e98,2a-- e-8,e98

    c./ e98,4

    a-- e-8,e98s'% e-8,2s'% e98,5a-- e-8,e98

    !./ e98,e-8

    s'% e98,5s'% e-8,2a-- e-8,e98

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition ''

  • 8/9/2019 All Answers (2)

    45/63

    "%&.Kiven that ;*3 contains +/+h, which of the following woul! be true after executing the/WA instruction?

    a. *3 h, A3 +/+h

    b. ;A3 h, ;*3 +/+h

    c. A3 h, *3 +/+h

    !. cannot be !etermine!

    "% .What will be the hexa!ecimal values of A3 an! *3 after the following instructions haveexecute!?

    / a8,12345 '/ -8,0/ 98,10'

    -i/ 98

    a. A3 +++%h, *3 2"')h

    b. A3 12"'h, *3 ++)%h

    c. A3 ++)%h, *3 12"'h

    !. cannot be !etermine!"%(.What will be the hexa!ecimal values of A3 an! *3 after the following instructions have

    execute!?/ a8,12345 '/ -8,0/ 98,10'

    -i/ 98

    Chapter 8 Test Bank Note to instructors: To view the answers, select Tools | Options | View | Hidden Text in MS-Word.

    Short Programming Problems1 Write a proce!ure name! se $ree that has three unsigne! integer stack parameters$ a byte, a

    wor!, an! a !oublewor!.

    "&+.*!! a local variable name! ar of type AWD8A to the Fse#hree proce!ure from the previous0uestion.

    "&1. how the entry co!e generate! by the assembler for the Fse#hree proce!ure 4in the previous0uestion5.

    "&2. uppose we !efine the following proce!ure$

    8a F%e2 ROB,neCDWORD, tw CDWORD

    / ea8, ne/ e98,@e9F+127a%% D FRe#sret

    8a F%e2 GD

    If we calle! xam+%e2 using the following statement, what values woul! be !isplaye! in ;*3an! ;:3?

    G$OP 8a F%e2, 10', 20'

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition ')

  • 8/9/2019 All Answers (2)

    46/63

    Multiple-Choice4 ome of the following 0uestions have more than one correct answer. /ircle all correct answers.5

    "&".Which of the following are true regar!ing local variables?

    a. #hey make efficient use of memory because their storage space can be release!.

    b. #hey can be accesse! from anywhere insi!e the same source co!e mo!ule.

    c. #hey are usually create! in the !ata segment

    !. #he same variable name can appear in two !ifferent proce!ures

    "&'.Eow are static variables !istinguishe! from global variables?

    a. Klobal variables are visible from all proce!ures in the source co!e file.

    b. tatic variables have a shorter lifetime than global variables.

    c. #he lifetime of a static variable is the same as the lifetime of its program.

    !. tatic variables are create! on the stack, using the ; an! ;: registers.

    "&).#he following is a vali! 9D/*9 !eclaration$LOBAL FArrayCDWORD R

    a. true

    b. false

    "&%.#he following is a vali! 9D/*9 !eclaration$

    LOBAL waF:%a#sC"Y @5

    a. true

    b. false

    "&&.#he following is a vali! 9D/*9 !eclaration$

    LOBAL 7 ntCDWORDa. true

    b. false

    "& .#he following is a vali! 9D/*9 !eclaration$

    LOBAL DWORDC7 nt

    a. true

    b. false

    "&(.Which of the following shows the proce!ure entry co!e generate! by B* B when the 9D/*9!irective is use! to !eclare a !oublewor! variable?

    a. / e9F,esFF s' e9Fs 9 esF,4

    b.F s' e9F

    / esF,e9Fa-- esF,4

    c.

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition '%

  • 8/9/2019 All Answers (2)

    47/63

    F s' e9F/ e9F,esF

    s 9 esF,4

    !.F s' e9F

    / e9F,esF

    a-- esF,4" +.Which of the following !efines an array local variable consisting of )+ signe! wor!s?

    a. LOBAL wArray@50 C WORD

    b. LOBAL wArrayC WORD@50

    c. LOBAL WORD@50 CwArray

    !. LOBAL WORDCwArray@50

    " 1.What a!vantages !o stack parameters have over register parameters?

    a. tack parameters re!uce co!e clutter because registers !o not have to be save! an! restore!.

    b. rograms using stack parameters execute more 0uickly.

    c. tack parameters are compatible with high-level languages.

    !. 8egister parameters are optimiJe! for spee!.

    " 2.What a!vantages !oes IC

  • 8/9/2019 All Answers (2)

    48/63

    " &.*n in!irect operan! such as R;:3S can be an argument passe! to the IC

  • 8/9/2019 All Answers (2)

    49/63

    !. :oth F E an! its correspon!ing D occur within the same loop.

    "(1.#he assembler checks the pointer type use! with the *AA8 operator against the pointer type!eclare! in the 8D/ !irective. or example, this prevents a pointer to AWD8A from being

    passe! to a proce!ure expecting an pointer to :=#;.

    a. true

    b. false"(2.*n alternate term for stac# $ra!e is .

    a. parameter frame

    b. activation recor!

    c. proce!ure execution frame

    !. parameter save area

    "(".*ssuming that a proce!ure contains no local variables, a stack frame is create! by which se0uenceof actions at runtime?

    a. arguments pushe! on stackM proce!ure calle!M ;: pushe! on stackM ;: set to ;

    b. ;: pushe! on stackM arguments pushe! on stackM proce!ure calle!M ;: set to ;c. arguments pushe! on stackM ;: pushe! on stackM ;: set to ; M proce!ure calle!

    !. arguments pushe! on stackM proce!ure calle!M ;: set to ; M ;: pushe! on stack

    "('.Which action must take place insi!e a proce!ure to reserve space on the stack for two !oublewor!local variables?

    a. after F E ;: , subtract from the base pointer 4;: 5

    b. after F E ;: , a!! to the base pointer 4;: 5

    c. after BD< ;: ,; , a!! to the stack pointer 4; 5

    !. after BD< ;: ,; , subtract from the stack pointer 4; 5

    "().Which memory mo!el uses "2-bit offsets for co!e an! !ata?a. small

    b. large

    c. flat

    !. huge

    "(%.Which of the following are vali! language specifiers in the .BDA;9 !irective?

    a. * /*9, D8#8*C, /

    b. /, = /*99, #A/*99

    c. :* I/, G*

  • 8/9/2019 All Answers (2)

    50/63

    "( .Which of the following are true about the / language specifier in the .BDA;9 !irective?

    a. #he 8;# instruction removes parameters from the stack.

    b. #he calling program removes parameters from the stack.

    c. Insi!e the proce!ure, the D instruction removes parameters from the stack before 8;#executes.

    !. *fter the /*99 instruction, a constant value is a!!e! to ; to remove parameters from thestack.

    "((.Which of the following are true about stack parameters?

    a. *ll are expresse! as positive offsets from ;: .

    b. *ll are expresse! as negative offsets from ;: .

    c. #hey are locate! at higher a!!resses than local variables.

    !. none of the above

    '++.Eow !oes using the 9;* instruction !iffer from using the D ;# operator with BD

  • 8/9/2019 All Answers (2)

    51/63

    a. 2 times

    b. " times

    c. ' times

    !. ) times

    '+'.If we were to expose the co!e generate! by B* B for MySu in ;xample 1, which of thefollowing woul! match that co!e most closely?

    a.Qy 9 ROB

    F s' e9F7 F DWORD R @e9F+4 ,!

    e L1in7 ea8

    / ea8,@e9F+4F s' ea87a%% Qy 9

    L1CF F e9F

    retQy 9 GD

    b.Qy 9 ROB

    F s' e9F/ e9F,esF

    7 F DWORD R @e9F+& ,!e L1

    / ea8,@e9F+&in7 ea8F s' ea87a%% Qy 9

    L1C

    F F e9Fret 4Qy 9 GD

    c.Qy 9 ROB

    / e9F,esF7 F DWORD R @e9F+& ,!

    e L1/ ea8,@e9F+&

    F s' ea8in7 ea87a%% Qy 9

    L1C

    ret 4Qy 9 GD

    !.Qy 9 ROB

    7 F DWORD R @e9F+& ,!e L1

    / ea8,@e9F+&in7 ea8F s' ea8

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition )1

  • 8/9/2019 All Answers (2)

    52/63

  • 8/9/2019 All Answers (2)

    53/63

    !. cannot be !etermine!

    '+(.8efer to ;xample 2. uppose we change! the last statement in the A**um proce!ure to thefollowing$

    ret &

    What woul! happen when running the program?

    a. #he program woul! run in the same manner.

    b. #he program woul! halt with a runtime error.

    c. When Aump8egs was calle!, ;*3 woul! be smaller than before.

    !. #he F E ;:3 instruction woul! execute two times.

    Chapter 9 Test Bank Note to instructors: To view the answers, select Tools | Options | View | Hidden Text.

    Short Programming Problems

    1 Fsing the following !efinition of a two-!imensional array, write a se0uence of instructions thatuse a base-in!ex operan! to move the element at row 2, column " to *3. 48ow an! columnnumbers begin at +5$

    6-ataROW = 5G)

    '11.Write a se0uence of instructions using BD< : that appen! sour*e to the en! of tar'et . #he firstthree instructions have been written for you$

    6-atas r7e "Y I PLQGO SR ,0tar#et "Y A"BD :H ,50 D< (0)67 -e

    G$OP trT%en#t', ADDR tar#et/ e-i,O:: tar#et

    a-- e-i,ea8

    '12.Write a se0uence of instructions that use /* A to search array/ for the first value that is notthe same as the current contents of ;*3. When the search is complete!, move the value you havefoun! into ;*3$

    arrayD DWORD 50 D< (>)

    '1".Write a se0uence of instructions that use #D A to fill each position of array/ with the largest possible "2-bit positive integer$

    arrayD DWORD 20 D< (>)

    '1'.Write a se0uence of instructions using /B A that compare arrayA to array0 in reverse or!er.*fter the comparison, move the first pair of non-matching array values to ;*3 an! ;:3.

    BO

  • 8/9/2019 All Answers (2)

    54/63

    arrayA DWORD BO)array" DWORD BO)

    '1).Write a se0uence of instructions using 9DA : an! #D : that copy each character from array*to array:, converting it to lowercase in the process. Cote$ setting bit ) in an uppercase characterwill convert it to lowercase$

    arrayA "Y A"BD :HIarray" "Y L GH IO: arrayA D< (0)

    Multiple-Choice4;ach of the following 0uestions has 6ust one correct answer5

    '1%.* se0uential search of an array of C elements re0uires, on average, C L 2 comparisons.

    a. true

    b. false

    '1&.* binary search of an array of %' elements re0uires a maximum of comparisons.

    a. true

    b. false

    '1 .#he 9DA : instruction loa!s from the memory location a!!resse! by ; I.

    a. true

    b. false

    '1(.#he #D : instruction loa!s from the memory location a!!resse! by ; I.

    a. true

    b. false

    '2+.Dn the first pass through an array of C items, how many times !oes the inner loop of a bubble sortexecute?

    a. C 1

    b. C

    c. C @ 1

    !. C 2

    '21.If a bubble sort re0uires +.2 secon!s to sort an array of 1,+++ elements, how many secon!s will itre0uire to sort 1+,+++ elements? Hint: u le sort is an O%n & ' al(orith!.

    a. 2 secon!s

    b. 2+ secon!s

    c. 2++ secon!s!. ' secon!s

    '22.#he instruction that copies !oublewor!s from one memory location to another is

    a. /B W

    b. BD< :

    c. BD< A

    !. /* A

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition )'

  • 8/9/2019 All Answers (2)

    55/63

    '2".#he 8; ; prefix !oes which of the following?

    a. repeats an instruction while the >ero flag is clear

    b. repeats an instruction while the >ero flag is set

    c. repeats an instruction while the /arry flag is clear

    !. repeats an instruction while the /arry flag is set'2'.Which instruction causes the ; I an! ;AI registers to be incremente! by the BD< : instruction?

    a. /9/

    b. 8;

    c. #A

    !. /9A

    '2).#he BD< : instruction uses which register as the source operan!?

    a. ; I

    b. ;AI

    c. ;*3!. ;/3

    Example 16-ata/ar1 "Y 10/ar2 "Y 20/ar3 "Y 3067 -e

    / esi,O:: /ar2/ e-i,O:: /ar1

    7 Fs9

    a L19 L2e L3

    '2%.#o which label will the program 6ump in ;xample 1?

    a. 91

    b. 92

    c. 9"

    !. cannot be !etermine! from the information given

    '2&.In ;xample 1, where will ; I point after the /B : instruction executes?

    a. at var1

    b. at var2

    c. at var"

    !. cannot be !etermine! from the information given

    '2 .If ar an! ar2 were change! to type WD8A in ;xample 1, what change4s5 woul! have to bema!e to the instructions in the co!e segment?

    a. change /B : to /B W

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition ))

  • 8/9/2019 All Answers (2)

    56/63

    b. change /B : to /B A

    c. change G* to GK, an! change G: to G9

    !. none of the above

    Example 21C 6-ata2C str1 "Y 1324A2342424 ,03C 67 -e4C / e-i,O:: str15C / a%, A

    C 7%-!C reFne s7as9&C / 9%,@e-i

    '2(.In ;xample 2, assume that str is locate! at offset +++'++1+h. What will be the value of ;AI after line & executes?

    a. +++'++1+h

    b. +++'++1"h

    c. +++'++1'h

    !. +++'++1)h

    '"+.In ;xample 2, if we change line % to st! , what value will be move! to :9 after line executes?

    a. * /II co!e of '

    b. * /II co!e of *

    c. * /II co!e of 2

    !. cannot be !etermine!

    '"1.In ;xample 2, if we change line & to repe scasb , what value will be move! to :9 after line executes?

    a. * /II co!e of "

    b. * /II co!e of *

    c. * /II co!e of 2

    !. cannot be !etermine!

    '"2.Which letter choice contains instructions that will fill all elements of arrayW with h?

    arrayW WORD 50 D< (>)

    a./ a8,0::::'/ e-i,O:: arrayW/ e78, O: arrayW

    7%-reF st s9

    b./ a8,0::::'/ e-i,O:: arrayW/ e78,L GH IO: arrayW

    7%-reF st sw

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition )%

  • 8/9/2019 All Answers (2)

    57/63

    c./ a8,0::::'/ esi,O:: arrayW/ e78, O: arrayW

    st-reF st sw

    !./ a8,0::::'/ esi,O:: arrayW/ e78,L GH IO: arrayW

    7%-reF? st sw

    '"".*ssume that +Strin' is a !oublewor! that contains the offset of a string. Which of the followingletter choices contains co!e that will set ;*3 to the length of the string? 4#he length shoul! notcount the string s null byte.5

    a./ e-i,F trin#/ ea8,0

    L1C 7 F "Y R @e-i ,0e L2in7 e-iin7 ea8

    F L1L2C

    b./ e-i,F trin#/ ea8,0

    L1C 7 F "Y R @e-i ,0ne L2

    in7 e-iF L1

    L2Cc.

    / e-i,F trin#/ ea8,0

    L1C 7 F "Y R @e-i ,0ae L2

    in7 e-iin7 ea8

    ne L1L2C

    !./ e-i,F trin#

    L1C 7 F "Y R @e-i ,0a L2

    in7 e-iin7 ea8

    n? L1L2C

    '"'. uppose we want to convert the letters in myStrin' to uppercase 4by clearing bit ) of eachcharacter5. 9ines 1 through % are the first part of the implmentation$

    6-ata

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition )&

  • 8/9/2019 All Answers (2)

    58/63

    y trin# "Y a9BDeJ#123'i ,067 -e1C / esi,O:: y trin#2C L1C / a%,@esi3C 7 F a%,04C e L35C 7 F a%, a

    C 9 L2

    Which letter choice contains the best alternative for the remaining instructions?

    a.!C 7 F a%, ?&C 9e L3

    C an- "Y R @esi ,11011111910C L2C in7 esi11C F L112C L3C ret

    b.!C 7 F a%, ?

    &C na L2C an- "Y R @esi ,11011111910C L2C in7 esi11C F L112C L3C ret

    c.!C 7 F a%, ?&C a L2

    C an- "Y R @esi ,11011111910C L2C in7 esi11C F L112C L3C ret

    !.!C 7 F a%, ?&C a L2

    C an- "Y R @esi ,11011111910C L2C n? L311C in7 esi12C F L113C L3C ret

    '").Kiven the following !eclaration of a two-!imensional array, which letter choice containsstatements that correctly calculate the sum of column +?

    6-ataROW = 5G

  • 8/9/2019 All Answers (2)

    59/63

    b./ esi,0/ e-i,O:: twArray/ e78,G

  • 8/9/2019 All Answers (2)

    60/63

    b. * /II co!e of 3

    c. ++h

    !. cannot be !etermine!

    Chapter 10 Test Bank Note to instructors: To view the answers, select Tools | Options | View | Hidden Text in MS-Word.

    Fill in the Blanks and Short Answer 1 Aefine a structure name! $ree:nts containing three unsigne! !oublewor!s name! #ie%d , #ie%d2,

    an! #ie%d3. #he fiel!s shoul! be uninitialiJe!.

    '" .Fsing the $ree:nts structure from the previous 0uestion, !eclare a variable name! #irst of type$ree:nts $

    '"(.Fsing the $ree:nts structure from the previous 0uestion, write a statement that assigns the value1+h to #ie%d$

    ''+.Fsing the $ree:nts structure from the previous 0uestion, write a statement that creates a variablename! + $ree that contains the offset of $ree:nts .

    Short Programming Problems

    Example 1O G RY WORD >

    O G GD

    OLY ROLY GD

    ''1.Fsing ;xample 1, !eclare a variable name! a6oint of type DIC# that initialiJes 3 to 1+ an! = to2+$

    ''2.Fsing ;xample 1, !eclare a variable name! a6o%y of type D9= that uses !efault structure values.

    ''".Fsing ;xample 1, set the first element of the a6o%y.+oints array to 3 1, = 2.

    '''.Fsing ;xample 1, set the secon! element of the a6o%y.+oints array to 3 ", = '.

    '').Fsing ;xample 1, write a se0uence of statements that initialiJe all 3 values in the a6o%y.+oints array to ran!om integers between + an! ((. Fse an in!exe! operan! to access the +oints array.

    ''%.Write a se0uence of statements that first set ; I to the offset of a6o%y. Cext, use ; I as an in!irectoperan! to set the num6oints fiel! to 2.

    ''&.Aeclare an array of two D9= structures name! myArray . Fse !efault initialiJation for both.

    Example 2R B R F WORD > Ri#'t WORD >

    Irvine, 7ip 8. *ssembly 9anguage for Intel-:ase! /omputers, ' th ;!ition %+

  • 8/9/2019 All Answers (2)

    61/63

    " tt WORD >R B GD

    AnyData

  • 8/9/2019 All Answers (2)

    62/63

    '%2.Write a macro name! mS$o&

  • 8/9/2019 All Answers (2)

    63/63

    GDQ

    a. six strings, each e0ual to Vcolor