Assembly lang prog

Ace your homework & exams now with Quizwiz!

This many red stripes are on the U.S. flag

7

Cinderella, Rapunzel and Hansel and Gretel are a few of the fairy tales written by 19th century German brothers, Jacob and Wilhelm, whose last name was what?

Brothers Grimm

These are the values of CF, ZF, and SZF after the following instructions are executed : ::: mov al,00110011b**** test al,2

CF = 0, ZF = 0, SF = 0

This instruction causes the ESI and EDI registers to be incremented by the MOVSB instruction

CLD

Which is greater - The pressure in an automobile tire, or the pressure in a bottle of champagne?

Champagne is about 3 times as much pressure as in a tire

This US auto maker produced a car called the Cirrus

Chrysler

This procedure locates the cursor at a specific row and column on the screen

Gotoxy

Is it illegal to catch mice?

In Ohio it is, if done without a hunting license!

This instruction copies the value of the Carry flag into bit 7 of AL, and shifts all existing bits in AL one position to the right.

RCR AL, 1

This instruction converts the value 6Fh in AL to the value F6h.

ROL AL, 4

This code converts the string mystring to lower case

What is : mov ecx, LENGTHOF mystring**** mov esi, OFFSET mystring**** L1: or BYTE PTR [esi], 20h ; set bit 5**** inc esi**** loop L1****

This is the correct implementation of the following pseudocode:::if( val1 > val2 || val2 > eax )**** mov ebx,1;**** else**** mov ebx,2;

What is : mov val1,ebx**** cmp ebx,val2**** jg L1**** cmp val2,eax**** jg L1**** mov ebx,2**** jmp L2**** L1: mov ebx,1**** L2:

This is the value of EAX when the following sequence of instructions has executed::::: push 5***** push 10***** push 20***** pop eax

What is : 20

This is the value of EAX when the following sequence of instructions has executed::::: push 5***** push 10***** pop ebx***** pop eax

What is : 5

This is the value of ECX when the following sequence of instructions has executed::::: push 5**** push 10**** pop ebx**** pop eax**** pop ecx

What is : Cannot be determined

This code causes a 500 millisecond delay, using a library procedure.

What is : MOV EAX, 500 ***** call Delay

This statement moves a video color constant to EAX. The constant should represent black text on a white background, (using the constants in the Irvine32.inc file)

What is : MOV EAX, black + ( white * 16)

This code will display the following string to standard output::::: str1 BYTE "Display this string",0

What is : MOV EDX, OFFSET str1****call WriteString

This will be the value of the Overflow flag after the following instructions have executed ::::: mov dx,800h **** mov ax,10h **** imul dx

What is : OF = 1 ( DX = 0000h, AX = 8000h, so DX is not a sign extension of AX)

This code writes a sequence of statements that read a signed integer from standard input and write the same integer to standard output. Use library procedures.

What is : call ReadInt*****call WriteInt

This is the equivalent Assembly Language code of the following C++ code. Assume that integers are unsigned. NO .IF directive allowed: if( eax > ebx ) mov dl,5; ******* else mov dl,6;

What is : cmp eax, ebx***jna L1****mov DL, 5****jmp L2****L1: mov dl,6

This codes a PROC declaration for a procedure named MySub. It uses the USES operator to preserve the EAX and EBX registers.

What is : mySub PROC USES EAX EBX

This loop uses the XOR instruction to transform every character in a string called buffer into a new value ( produce a cipher text)

What is ::: KEY = 239 ; Can be any byte value**** BUFMAX = 128**** .DATA**** buffer BYTE BUFMAX+1 DUP(0)**** bufSize DWORD BUFMAX**** .CODE **** mov ecx, bufSize ; loop counter**** mov esi, 0 ; index 0 in buffer**** L1:**** xor buffer[esi], KEY ; translate a byte**** inc esi ; point to next byte**** loop L1****

The following pseudo code in assembly language::: if(val1 >ecx) AND (ecx >edx ) then X = 1**** else X = 2;

What is ::: cmp val1, ecx****jna L1**** cmp ecx, edx****jna L1****mov x, 1**** jmp next****L1: mov X, 2****next

This is the correct implementation of the following pseudocode::::while( int2 >= int1 )**** {**** add ebx,2**** if( ebx > int2)**** mov ebx,0**** else**** mov ebx,int1**** }

What is ::: top:**** mov eax,int2**** cmp eax,int1**** jl L3**** add ebx,2**** cmp ebx,int2**** jg L1**** mov ebx,int1**** jmp L2**** L1: mov ebx,0**** L2: jmp top**** L3:

This code is functionally equivalent to example 6.5.3 but has fewer instructions

What is :::.DATA***sum DWORD 0***sample DWORD 50*** array DWORD 10, 60, 20, 33, 72, 89, 45, 65, 72,18****arraySize = ($ - array) / TYPE array****.CODE *** mov EAX, 0****mov EBX, sample***mov ESI, 0 **** MOV ECX, arraySize****L1: CMP ESI,ECX***JNL L5****cmp array[ESI*4], EDX****JNG L4**** add EAX, array[ESI*4]****L4 : inc ESI**** jmp L1****L5 : mov sum, EAX

A code for a procedure that receives a character in AL. Sets the Zero flag if the character is a decimal digit.

What is ::::IsDigit PROC**** cmp al,'0' ; ZF = 0**** jb ID1**** cmp al,'9' ; ZF = 0**** ja ID1**** test ax,0 ; ZF = 1**** ID1: ret**** IsDigit ENDP

The following code in assembly language ::: if(ebx > ecx ) OR (EBX >val1 ) then x=1 **** else X = 2

What is ::::cmp ebx, ecx**** ja L1****cmp ebx, val1****ja L1****mov X, 2****jmp next****L1: mov X, 1****next:

In assembly language ::: if(ebx >ecx AND ebx >edx> OR (edx >eax) then X = 1 **** else X = 2

What is ::::cmp ebx, ecx**** jna L1**** cmp ebx, edx**** jna L1**** jmp L2**** L1: cmp edx, eax**** jna L3**** L2: mov X, 1**** jmp next **** L3: mov x, 2 **** next:

The following code in assembly Language:::if (var1 <= var2) **** {**** var3 = 10;**** }**** else**** {**** var3 = 6;**** var4 = 7;**** }

What is ::::mov eax,var1**** cmp eax,var2**** jle ifpart**** mov var3,6**** mov var4,7**** jmp next**** ifpart:**** mov var3,10**** next:

This code computes the Max of unsigned EAX and EBX

What is :::mov Max, eax ; assume Max = eax**** cmp Max, ebx**** jae done**** mov Max, ebx ; Max = ebx**** done:

This instruction cause a jump to label L4 if bits 1, 2, and 3 are all set in the DL register?

What is :and dl,0Eh**** cmp dl,0Eh**** je L4****

This is the content of AL after the following instructions execute ::::mov al,94h xor al,37h

10100011

Write a procedure named Read10 that reads exactly ten characters from standard input into an array of BYTE named myString. Use the LOOP instruction with indirect addressing, and call the ReadChar procedure from the book's link library. (ReadChar returns its value in AL.)

Read10 PROC**** MOV ECX, LENGHTOF myString**** MOV ESI, OFFSET myString**** L1: call ReadChar**** MOV [esi], AL**** INC ESI**** Loop L1**** RET Read10 ENDP

This river runs through both Lyon and Marseilles?

Rhone River

This file acts as a bridge between Irvine32.lib and kernel32.dll

kernel32.lib

This is the binary value of AX after the following instructions have executed :::::: mov ax,0000 0000 1001 1101 b **** mov bx,1010 1010 1000 0000 b **** shld ax,bx,1

0000 0001 0011 1011

How many daughters did Charles Ingalls have in Little House on the Prairie?

3

This is the content of AL after the following instructions execute :::: mov al,11001111b***** and al,00101011b

00001011

In this example, assume that str1 is located at offset 00040010h. What will be the value of EDI after line 7 executes?:::::1: .data**** 2: str1 BYTE "1324A2342424",0**** 3: .code**** 4: mov edi,OFFSET str1**** 5: mov al,'A'**** 6: cld**** 7: repne scasb**** 8: mov bl,[edi]****

00040015h

1: .data**** 2: str1 BYTE "AAAX",0**** 3: str2 BYTE 10 DUP(0FFh)**** 4: .code**** 5: mov edi,0**** 6: L1: mov al,[str1+edi]**** 7: cmp al,0**** 8: je L2 9: mov [str2+edi],al 10: inc edi**** 11: jmp L1**** 12: L2:****** If we changed lines 7, 8, and 9 to the following, what value would be stored at offset [str2+4] after the loop finished? 7: mov [str2+edi],al****** 8: cmp al,0***** 9: je L2

00h

This is the binary value of AL after the following instructions have executed ::::::: mov al,10000101b **** clc **** rcr al,1

0100 0010

1: .data**** 2: str1 BYTE "AAAX",0**** 3: str2 BYTE 10 DUP(0FFh)**** 4: .code**** 5: mov edi,0**** 6: L1: mov al,[str1+edi]**** 7: cmp al,0**** 8: je L2**** 9: mov [str2+edi],al**** 10: inc edi**** 11: jmp L1**** 12: L2: After the code executes, what value will be stored at offset [str2+4]?

0FFh

The contents of CF, SF, and ZF after these instructions are executed ::: mov al,5 cmp al,7

1 1 0

This is the binary value of AL after the following instructions have executed :::: mov al,01101011b **** stc **** rcl al,2

1010 1110

This is the content of AL after the following instructions execute :::: mov al,00111100b**** or al,82h

10111110

This is the binary value of AX after the following instructions have executed ::::: mov ax,0000 0000 1001 1101 b **** mov bx,1010 1010 1000 1011 b **** shrd ax,bx,2

1100 0000 0010 0111

How many liters are there in the U.S. gallon?

3.78 liters

Suppose we want to convert the letters in myString to uppercase (by clearing bit 5 of each character). Lines 1 through 6 are the first part of the implmentation::::: .data**** myString BYTE "abCDefg123hij",0**** .code**** 1: mov esi,OFFSET myString**** 2: L1: mov al,[esi]**** 3: cmp al,0 **** 4: je L3 **** 5: cmp al,'a'**** 6: jb L2**** WRITE THE REMINING INSTRUCTIONS:::::

7: cmp al,'z' ***** 8: ja L2***** 9: and BYTE PTR [esi],11011111b***** 10: L2: inc esi***** 11: jmp L1***** 12: L3: ret*****

This code clears bits 0 and 1 in AL. Then , if the destination operand is equal to 0, the code should jump to label L3, otherwise, it will jump to label L4

::: and al, 11111100 ****jz L3****jmp L

This block of code will fill all elements of arrayW with FFFFh:::: arrayW WORD 50 DUP(?)

::::mov ax,0FFFFh**** mov esi,OFFSET arrayW**** mov ecx,SIZEOF arrayW**** std**** rep stosw

A case table that can call these prosedures if the user selects : a,b,c,d,e,f :::afoo, bfoo, cfoo, dfoo, efoo, ffoo. It must calculate table entry size and how many entries are there in the table.

:::CaseTable BYTE 'a'**** DWORD afoo**** EntrySize = ($ - CaseTable)**** BYTE 'b'**** DWORD bfoo**** BYTE 'c'**** DWORD cfoo**** BYTE 'd' **** DWORD dfooo BYTE 'e'**** DWORD efoo**** BYTE 'f' **** DWORD ffooo NumberOfEntries = ($ - CaseTable) / EntrySize

Write a sequence of instructions that use SCASD to search arrayD for the first value that is not the same as the current contents of EAX. When the search is completed, move the value you have found into EAX:::: arrayD SDWORD 50 DUP(?)

; ( first 3 statements may be in any order)**** mov edi, OFFSET arrayD**** mov ecx, LENGHTOF arrayD**** cld*** repz scasd**** mov eax, [edi-4]

6. Write a sequence of instructions using CMPSD that compare arrayA to arrayB in reverse order. After the comparison, move the first pair of non-matching array values to EAX and EBX.::::: COUNT = 5**** arrayA DWORD COUNT DUP(?)**** arrayB DWORD COUNT DUP(?)****

; ( first 4 statements may be in any order )**** mov esi, arrayA + count - 4**** mov edi, arrayB + count - 4**** mov ecx, count**** std**** repe cmpsd**** ; (next 2 assignments may be in any order)**** mov eax, [esi+4] ; from arrayA ***** mov ebx, [edi +4] ; from arrayB

Write a sequence of instructions that use STOSD to fill each position of arrayD with the largest possible 32-bit positive integer: arrayD SDWORD 20 DUP(?)

; ( first 4 statements may be in any order)*** mov eax, 7FFFFFFFh**** mov edi, OFFSET arrayD**** mov ecx, LLENGHTOF arrayD**** cld**** rep stosd

7. Write a sequence of instructions using LODSB and STOSB that copy each character from arrayA to arrayB, converting it to lowercase in the process. Note: setting bit 5 in an uppercase character will convert it to lowercase:::: arrayA BYTE "ABCDEFGHI"**** arrayB BYTE LENGTHOF arrayA DUP(0)

; (first 4 statements may be in any order)**** mov ecx, LENGHTOF arrayA**** mov esi, OFFSET arrayA**** mov edi, OFFSET arrayB**** cld******** L1 : LODSB**** or al, 0010 0000**** stosb**** LOOP L1

This single instruction uses 16 bit operand that clear the high 8 bits of AX and does not change the low 8 bits

AND ax, 00FFh

In this Example, if we change line 7 to "repe scasb", what value will be moved to BL after line 8 executes?::::::::: 1: .data**** 2: str1 BYTE "1324A2342424",0**** 3: .code**** 4: mov edi,OFFSET str1**** 5: mov al,'A'**** 6: cld**** 7: repne scasb**** 8: mov bl,[edi]****

ASCII code of "3"

This will be the hexadecimal values of DX and AX after the following instructions have executed :::::: mov dx,000Fh **** mov ax,6342h **** mov bx,100h **** div bx

DX = 0042h, AX = 0F63h

This is the hexadecimal values of DX and AX after the following instructions have executed ::::: mov ax,6B49h **** mov dx,0095h **** shl ax,1 **** rcl dx,1 ****

DX = 012Ah, AX = D692h

This will be the hexadecimal values of DX and AX after the following instructions have executed::::: mov dx, -16 **** mov ax,2 **** imul dx

DX = FFFFh, AX = FFE0h

Given that EAX contains FFFF80C0h, the contents of DX and AX after executing the CWD instruction

DX=FFFFh, AX=80C0h

This airline company is named after a Greek letter

Delta

The MOVSB instruction uses this register as the source operand

ESI

This person of non royal origins was known as "The King"?

Elvis Presley

T/F A WHILE loop can be constructed with a CMP instruction at the bottom of the loop, followed by a conditional jump instruction.

FALSE

T/F The PUSH instruction increments the stack pointer (by 2 or 4) and copies the operand into the stack at the location pointed to by the stack pointer.

FALSE

T/F The assembler knows the exact address of a library procedure

FALSE

In this example the program will jump to this label ::::.data*** var1 BYTE 10**** var2 BYTE 20**** var3 BYTE 30**** .code********** mov esi,OFFSET var2**** mov edi,OFFSET var1**** cmpsb**** ja L1**** jb L2**** je L3

L1

This code displays the following array in hexadecimal, using the DumpMem procedure from the link library:::::array DWORD 10h,20h,30h,40h

MOV ESI, OFFSET array**** MOV ECX, LENGHTOF array**** MOV EBX, TYPE array**** call dumpMem

Which one of these is not on the coast: Venice, San Diego, Reykjavik, Marrakesh, Helsinki, Lisbon

Marrakesh ( Morocco )

This waterfalls are between Lake Erie and Lake Ontario

Niagara Falls

This instruction pops the stack into the FLAGS register

POPFD

This instruction pushes the 32 bit FLAGS registers on the stack

PUSHFD

Write a procedure named ShowBinary that displays the following array as a sequence of binary bits, starting with the low-order value (00000010h). Include the use of the LENGTHOF, OFFSET, and TYPE operators, and call the WriteBin procedure::::: array DWORD 10h,20h,30h,40h

ShowBinary PROC**** MOV ECX, LENGHTOF array**** MOV ESI, OFFSET array**** L1: MOV EAX, [esi]**** call WriteBin**** ADD ESI, TYPE array**** Loop L1**** RET**** ShowBinary ENDP

T/F This code sequences assigns the value 10h to EBX:::: mov edx,20h**** push edx**** mov ecx,10h**** push ecx**** pop ebx**** pop edx

TRUE

The two registers containing: 1. an integer before calling WriteDec and 2. the starting address of data when calling DumpMem

What is : 1. EAX, 2. ESI

This country produces the greatest volume of beer per year

United States

What is "entrance" and "driveway" in Swedish?

What is : "Infart" and "Utfart."

This sentence contains every letter of the English Alphabet.

What is : "The quick brown fox jumps over a lazy dog."

This code uses library procedures to generate a single unsigned pseudorandom integer between 0 and 999 and write it to standard output:

What is : ****MOV EAX, 1000*****call RandomRange ***** calWriteDec

This library procedure writes an unsigned 32-bit integer to standard output in hexadecimal format

WriteHex

Which is the financial centre and main city of Switzerland?

Zurich

In this example ESI point at this variable after the CMPSB instruction executes::::.data*** var1 BYTE 10**** var2 BYTE 20**** var3 BYTE 30**** .code********** mov esi,OFFSET var2**** mov edi,OFFSET var1**** cmpsb**** ja L1**** jb L2**** je L3

at var2

This instruction ( a function call ) writes the contents of EAX to standard output as a signed decimal integer?

call writeInt

In this xample , if we change line 6 to "std", what value will be moved to BL after line 8 executes?::::1: .data**** 2: str1 BYTE "1324A2342424",0**** 3: .code**** 4: mov edi,OFFSET str1**** 5: mov al,'A'**** 6: cld**** 7: repne scasb**** 8: mov bl,[edi]****

cannot be determined

The hexadecimal values of DX and AX after the following instructions have executed :::: mov ax,3456h **** mov dx,12h **** mov bx,10h **** div bx

cannot be determined

If var1 and var2 were changed to type SWORD in the following code, then this change(s) would have to be made to the instructions in the code segment: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: .data*** var1 BYTE 10**** var2 BYTE 20**** var3 BYTE 30**** .code********** mov esi,OFFSET var2**** mov edi,OFFSET var1**** cmpsb**** ja L1**** jb L2**** je L3

change CMPSB to CMPSW and change JA to JG, and change JB to JL

This sequence of two instructions copies bits 0-5 from AL to bits 0-5 in BL. Bits 6-7 in BL are cleared, and AL is unchanged.

mov BL, AL ***** and BL, 0011 1111b

This series of instructions multiplies EAX by 18, using a combination of shift, MOV, and ADD instructions.

mov EBX, EAX ; make copy **** shl EAX, 4 ; EAX * 16 ****shl EBX, 1 ; EBX * 2 ****add EAX, EBX ; answer

This sequence of instructions divides -16 by 5, using the IDIV instruction. It uses the EBX register as a divisor.

mov eax, -16 ****cdq*****mov ebx, 5****idiv ebx

This blocks of instructions multiplies the contents of the EDX register by 36

mov ebx,edx ***** shl edx,5 ****** shl ebx,2 ***** add edx,ebx*****ALSO ::::::::mov ebx,edx*** shl ebx,5*** shl edx,2*** add edx,ebx

Assume that pString is a doubleword that contains the offset of a string. This code will will set EAX to the length of the string? (The length should not count the string's null byte.)

mov edi,pString*** mov eax,0**** L1: cmp BYTE PTR [edi],0**** je L2**** inc edi**** inc eax**** jmp L1**** L2:

21. Given the following declaration of a two-dimensional array,write a code to calculate the sum of theelements in column 0:::::: .data ROWSIZE = 5 NUMROWS = 4 twArray WORD NUMROWS DUP( ROWSIZE DUP(?) )

mov esi,0**** mov edi,0**** mov ecx,NUMROWS**** mov ax,0**** L1: add ax,twArray[esi+edi]**** add esi,(ROWSIZE * TYPE twArray)**** loop L1

The REPE prefix does the following:

repeats an instruction while the Zero flag is set

This instruction will multiply the integer in EBX by 32 (using shifts only)

shl ebx,5

This sequence of two instructions copies the integer in bits 4-7 from the AL register into bits 0-3 of the BL register. The upper 4 bits of AL are cleared, as will the upper 4 bits of BL.

shr AL, 4 **** mov BL, AL

Given the following two assignments to AX and DX, which block of instructions will cause DX to equal 4025h and AX to equal 1AD2h ::::: mov ax,6B49h ***** mov dx,0095h

shr ax,1 **** rcr dx,1 **** shr ax,1 **** rcr dx,1

This instruction will divide the unsigned integer in EBX by 8 (using shifts only)

shr ebx,3


Related study sets

PEDS: Chapter 26: School-Aged Child: 6-10 years

View Set

4.4 Protein Denaturation and Folding

View Set