Please show all the steps to solve this problem of assembly

Please, show all the steps to solve this problem of assembly language

Use the following variable definition for questions

var1       db -4, -2, 3, 1

var2       dw 1000h, 2000h, 3000h, 4000h

a)For each of the following statements, state whether or not the instruction is valid:

MOV   al,   var1

MOV   ah,   var2

MOV   var2,   al

MOV   ds,   ax

b)What will be the hexadecimal value of destination operand after each of the following instructions execute in sequence?

MOV    al,    var1

MOV    ah,   [var1 + 3]

c)What will be the value of destination operand after each of the following instructions execute in sequence?

MOV    ax,   var2

MOV    ax,   [var2 + 2]

Solution

a)

The first instruction is given as follows:

MOV al, var1

The var1 in the above instruction is defined as follows:

var1 db -4, -2, 3, 1

The size of the operand al is not equal to the size of the operand var1. The operands should be of equal size for the MOV instruction.

Hence, the first instruction is not valid.

The second instruction is given as follows:

MOV ah, var2

The var2 in the above instruction is defined as follows:

var2 dw 1000h, 2000h, 3000h, 4000h

The size of the operand ah is equal to the size of the operand var2 because both the operands has word storage. The above instruction satisfies the condition of the MOV instruction that the operands should be of equal size.

Hence, the second instruction is valid.

The third instruction is given as follows:

MOV var2, al

The var2 is a variable and is used at the place of the target register in the above MOV instruction. The left operand of MOV instruction should be a register.

Hence, the third instruction is not valid.

The fourth instruction is given as follows:

MOV ds, ax

The operands ds and ax are the registers which contains memory address. The content of the memory can be transferred using registers in the MOV instruction.

Hence, the fourth instruction is valid.

b)

The instruction given in the problem is as follows:

MOV al, var1

The above instruction moves the value of the variable var1 into the register al. The statememnt to declare and define the variable var1 is shown as follows:

var1 db -4, -2, 3, 1

The above statement is creating 4 bytes in which the starting address is var1. The value of var1, var2, var3, and var4 is given as follows:

var1 = -4

var1 + 1 = -2

var1 + 2 = 3

var1 + 3 = 1

The register al will have the hexadecimal value of -4. The hexadecimal value of -4 can be calculated as follows:

Calculate the binary number corresponding to 4 in 8 bits because size of a number in var1 is 1 byte = 8 bits:

4 = 0000 0100

Flip all the bits in the above binary representation of 4.

1111 1011

Add 1 to the above binary representation of 4.

1111 1011

             +1

1111 1100

The resultant binary representation can be written in the hexadecimal form as follows:

1111 1100

   F       C

Hence, the value of the destination register al in the instruction MOV al, var1 is FCh.

The instruction given in the problem is as follows:

MOV ah, [var1 + 3]

The above instruction moves the value of the variable [var1 + 3] into the register ah. The statememnt to declare and define the variable var1 is shown as follows:

The var1 + 3 represents the fourth consecutive value of var1 i.e., var1 + 3 = 1.

The register ah will have the hexadecimal value of 1. The hexadecimal value of 1 can be calculated as follows:

Calculate the binary number corresponding to 1 in 8 bits because size of a number in var1 is 1 byte = 8 bits:

1 = 0000 0001

The resultant binary representation can be written in the hexadecimal form as follows:

0000 0001

   0       1

Hence, the value of the destination register ah in the instruction MOV ah, [var1 + 3] is 01h.

c)

The instruction MOV ax, var2 will copy the first value pointed by var2 to the register ax. The variable var2 is defiend as follows:

var2 dw 1000h, 2000h, 3000h, 4000h

The variable var2 is creating 4 words starting with 1000h. The content of var1 and consecutive values pointed by var2 can be shown as follows:

var2 = 1000h

var2 + 1 = 2000h

var2 + 2 = 3000h

var2 + 3 = 4000h

Hence, the register ax will have the value 1000h after the execution of the instruction MOV ax, var2.

The instruction MOV ax, [var2 + 2] will copy the third value pointed by var2 to the register ax. The variable var2 is defiend as follows:

var2 dw 1000h, 2000h, 3000h, 4000h

The variable var2 is creating 4 words starting with 1000h. The content of var1 and consecutive values pointed by var2 can be shown as follows:

var2 = 1000h

var2 + 1 = 2000h

var2 + 2 = 3000h

var2 + 3 = 4000h

Hence, the register ax will have the value 3000h after the execution of the instruction MOV ax, [var2 + 2].

Please, show all the steps to solve this problem of assembly language Use the following variable definition for questions var1 db -4, -2, 3, 1 var2 dw 1000h, 20
Please, show all the steps to solve this problem of assembly language Use the following variable definition for questions var1 db -4, -2, 3, 1 var2 dw 1000h, 20
Please, show all the steps to solve this problem of assembly language Use the following variable definition for questions var1 db -4, -2, 3, 1 var2 dw 1000h, 20

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site