Write one instruction to reverse the lsb

Assignment Help Programming Languages
Reference no: EM13972685

Assignment: Use bit wise instructions

lab requirement: use bitwise instructions when possible to make the code shorter

INCLUDE Irvine32.inc

VAL = 129

.data
bvar BYTE 0fh
wvar WORD -17
dvar DWORD 13
outstr1 BYTE "Number of 1's: ", 0  use for output of question 1
power2 BYTE "Power of 2", 0ah, 0dh, 0  use for output of question 2
notPower2 BYTE "Not power of 2", 0ah, 0dh, 0  use for output of question 2
arr WORD 1, -2, -3, 4

.code
main PROC
  Question 1:
  Add code below to print how many 1's there are in a data value, without changing the data itself. Use outstr1 for your text output.

  Your code should work with dvar, but if I change the variable name to wvar or bvar, the code should still run without any other modification.

  Question 2a
  Write code to determine if a data value is a power of 2, using the formula:
  bool powerOf2 = val&& !(val& (val - 1))
  where& is a bitwise AND, && is a logical AND, ! is a logical NOT (there is a difference between bitwise AND vs logical AND, don't mix them up same with bitwise NOT and logical NOT)
  You *cannot* use the CMP instruction in your code (try a bitwise instruction)

  Use power2 and notPower2 for your text output.

moveax, VAL  Your code should work with all VAL values

  Question 2b: explain in your own words how the formula above works

  Question 3: Given an array arr as defined in .data, and ebx is initialized below.

  Using ebx (not the array name), write ONE instruction to reverse the LSB of the 2nd and 3rd elements of arr. Reverse means 0 to 1 or 1 to 0. Your code should work with all values in arr (not just the sample values above).

movebx, OFFSET arr

exit

main ENDP

END main

Reference no: EM13972685

Questions Cloud

Description of group challenges and specific communications : Upon selecting a group of interest, prepare a six- to eight-slide presentation (excluding title and reference slides) that includes the following: A description of the group's challenges and specific communication needs
Tax consequences of the reduction : Helena has assets of $130,000 and liabilities of $160,000. One of her debts is for $120,000. Discuss the tax consequences of the reduction of this debt in each of the following circumstances:
The anxiety is caused by a new excavator : The new equipment has a 10-year life and expected salvage value of $105,000. What should the officer do? The tax rate is 35%, the CCA rate, 25% for both excavators and the required rate of return for the company is 13%.
What the primary difference between dram and sram : Develop the state diagram for a MOD-4 counter with an even number count sequence: 000, 010, 100, 110, 000, etc. All undefined states must return to 000.
Write one instruction to reverse the lsb : write ONE instruction to reverse the LSB of the 2nd and 3rd elements of arr - Write code to determine if a data value is a power of 2,
Compute depreciation expense on the building machinery and : On June 29, 2014, machinery included in the March 31, 2013, purchase that cost $100,000 was sold for $80,000.Herzog uses the straight line depreciation method for buildings and machinery and the sum of the years' digits method for equipment. Partial ..
Discharge of indebtedness situation : Determine the amount of income that must be recognized in each discharge of indebtedness situation that follows.
Determining the forgiveness of debt : Assume the same facts as in part a, except that Vito's liabilities are $800,000 before the forgiveness of debt.  Assume the same facts as in part a, except that Vito's total liabilities are $625,000 before the forgiveness of debt.
Compare the major developmental theories : Your two-year old daughter refuses to wear the clothes you pick for her every morning making getting dressed a twenty-minute pitched battle.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd