Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. In an 8-bit binary number, which is the most significant bit (MSB)? 2. In the

ID: 3869760 • Letter: 1

Question

1. In an 8-bit binary number, which is the most significant bit (MSB)?

2. In the following code, the value in AL is intended to be a signed byte. Explain how the

Overflow flag helps, or does not help you, to determine whether the final value in AL falls

within a valid signed range.

mov al,-1

add al,130

3. Trace the following program:

1: main PROC

2: mov eax,5

3: add eax,6

4: sub eax, 6

5: mov ebx, eax

what is the value in eax= and in ebx=   

4. At which level/s can an assembly language program manipulate input/output?

5. In 64-bit mode, you can use up to eight floating-point registers.

6. What is a calling convention, and how is it used in assembly language declarations?

7. How do you reserve space for the stack in a program?

8. How is a source file different from a listing file?

9. How are data labels and code labels different?

10. Why is it not a good idea to use numeric addresses when writing instructions that access variables?

11. Find out if you can declare a variable of type DWORD and assign it a negative value. What does this tell you about the assembler’s type checking?

12. Given the number 456789ABh, list out its byte values in little-endian order.

13. Declare an array of 120 uninitialized unsigned doubleword values.

14. Show the order of individual bytes in memory (lowest to highest) for the following doubleword

variable: val1 DWORD 87654321h

15. True or false: The following is a valid data definition statement:

var1 BYTE 0Ah, 255

16. Write an assembly program to compute the following expression:

AL = BL +val1

where Val1 is an 8-bit memory variable

Explanation / Answer

1.

In an 8-bit binary number, the leftmost bit is the most significant bit (MSB). The example is as follows:

01101110

Here, the leftmost bit is 0 which is the most significant bit. Here, the most significant bit represents whether the number is signed or unsigned that is positive or negative.

0 represents that the number is unsigned and 1 represents that the number is signed.

2.

The Overflow flag is set when the set of the result exceeds or becomes less than the size of the destination operand.

The overflow flag is represented as a single bit which indicates an arithmetic overflow.

mov al, -1 moves the value -1(FFFF) into AL

add al, 130 will add 130 to the value which is stored in al. If the negative result follows, it indicates an overflow. When the instruction add al, 130 is executed, the value of AL will be 129.

The range of the integer signed byte value is -128 to 127, the value 129 exceeds the size of the destination operand.

The value of overflow flag is 1 and the final value in AL does not fall within the range.

3.

main PROC

mov eax,5

add eax,6

sub eax, 6

mov ebx, eax

The value in eax = 5 and in ebx= 5

Solution:

The value of eax as well as ebx will be 5. According to the program, the main program PROC is called. The value 5 is moved into the register eax. This value 5 is added to 6 according to the instruction add eax, 6 making the value to be 11 in eax. Now, subtract the value 6 from eax such that the value becomes 11-6 = 5. Now, move the value of ebx into eax to get the value 5 into ebx.

Hence, eax = 5, ebx = 5

4.

The levels at which an assembly language can manipulate the input/output are as follows:

Application program

Operating System

BIOS

Hardware

5.

The statement “In 64-bit mode, you can use up to 8 floating point registers” is true.

Explanation: The floating-point unit has 8 floating point data register called ST (0), ST (1), ST (2), ST (3), ST (4), ST (5), ST (6), ST (7). The floating-point data register has 80 bits when 32 or 64-bit processor is used.

6.

The calling convention is the method that is used to describe the procedure calls through the registers to be reserved. Through this convention parameters are passed by value/reference and the stack pointer is restored.

7.

The space for the stack in a program is reserved through .STACK directive. This directive is used to identify the variables/procedures of the program code that is kept on the stack. This directive is followed by the integer that specifies the number of bytes reserved for the space.

8.

Source file: The code written by the programmer according to the requirement of the software is written in the source file.

Listing file: It is the copy of the source file that is printed to make the hard copy backup. This listing file has the line numbers in front of the program instructions, offset addresses, procedures, symbol table.

9.

Data label: The data label is used to define the name of the variable and gives the variable address as output.

Code label: The code label is used to transfer the control to the label during the execution of the program.

10.

It is not a good idea to use numeric addresses when writing the instructions that access variables because if a new value is inserted in the variable location before the location of the existing variable, the numeric addresses should be updated and this updation is error-prone and difficult.

11.

A variable of type DWORD can be declared but a negative value cannot be represented with DWORD. DWORD is used to represent 32-bit unsigned integer and the most significant bit cannot be used for sign representation.

12.

In little endian order, the bytes are ordered from low to high which means that the least significant byte is stored at the first address in the memory.

The number 456789ABh will be stored in little endian order as follows:

ABh

89h

67h

45h

13.

An array of 120 uninitialized unsigned doubleword values will be declared as follows:

darray DWORD 120 DUP(?)

Here, darray be the name of the array that has 120 elements

The question mark keeps the data uninitialized.

14.

The order of individual bytes in memory for the doubleword variable: val1 DWORD 87654321h is as follows:

    21h

    43h

    65h

    87h

15

The following statement var1 BYTE 0Ah, 255 is valid

16

The assembly program to compute the following expression: AL = BL + val1 is as follows:

mov (%addval1), %eax

add %eax, %BL

mov %BL, %AL