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

using shift instruction to program an assembly code to zero number $46 that is a

ID: 3596368 • Letter: U

Question

using shift instruction to program an assembly code to zero number $46 that is already stored in $1000. store the result into $1100. in other word after you shift the bits of $46 for some times the number $46 becomes a $00 using shift instruction to program an assembly code to zero number $46 that is already stored in $1000. store the result into $1100. in other word after you shift the bits of $46 for some times the number $46 becomes a $00 using shift instruction to program an assembly code to zero number $46 that is already stored in $1000. store the result into $1100. in other word after you shift the bits of $46 for some times the number $46 becomes a $00

Explanation / Answer

Initially the number $46 is stored in the memory address $1000

STR $46, $1000

Now we need to change the number $46 to $00 using shift instructions and store the result in $1100

There are two types of shift instructions:

1)Shift Left (shifting the MSB(most significant bit) to the c-flag and adding '0' at the right end)

2)Shift Right( shifting the LSB(Least significant bit to the c-flag and adding '0' at the left end)

First let us see

Shift Left:

The binary value for $46 is

mov ax, 01000110

0100 0110 $46

shl ax,1 // (shift left the contents of ax by 1 bit i.e., shifts the MSB(most significant bit ) to c-flag and adds '0' at the right end.)

1000 1100 (The decimal equivalent is $140)

shl ax,1 0001 1000 $24

shl ax,1 0011 0000 $48

shl ax,1 0110 0000 $96

shl ax,1 1100 0000 $192

shl ax,1 1000 0000 $128

shl ax,1 0000 0000 $00

STR ax, $1100 //stores the new value of ax($00) in the memory location $1100.

After shifting 7 times the left bit, $46 has changed to $00.

Shift Right:

0100 0110 $46

shr ax,1 0010 0011 $35 //(shr-shift right the contents of ax by 1)

shr ax,1 0001 0001 $17

shr ax,1 0000 1000 $08

shr ax,1 0000 0100 $04

shr ax,1 0000 0010 $02

shr ax,1 0000 0001 $01

shr ax,1 0000 0000 $00

$46 has changed to $00 by right shifting the contents of ax 7 times.

Store the result of ax($00) in $1100

STR ax, $1100