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

  Is this an example of head or tail recursion

Referring to the code in Part 1, use the substitution model to illustrate what the result of calling (add1-iter '(1 2 3)) will be. Why is the list reversed ?

  Create a folder for each region name.

Use the attached page/code to create a template with the changes indicated below. Apply the template to a few pages to demonstrate how it's done. Provide any instructions for applying it that weren't given.

  Write program-compute average using floating-point numbers

Write a program that will accept as input between 2 and 25 numbers and then calculate the average of the numbers. Make sure you use floating-point numbers in case the average is not a whole number.

  Define object-oriented programs

We are working on Object-Oriented Programs and I am lost.

  Assignment - file access and flowcharts

Assignment - File Access and Flowcharts, The Output symbol is used to output data to a text file. When an Output symbol is reached during Raptor program execution, the system determines whether or not output has been redirected

  Write method multiple to determine for pair of integers

Write a method multiple which determines, for pair of integers, whether second integer is a multiple of first. The method must take two integer arguments

  How can the two arrays share the same memory

This results in the two arrays sharing the same portion of memory. Can you picture this? How can the two arrays share the same memory?

  Void function to display in nicely formated way

Write a void function display_exer() that display in a nicely formated way the eat members of an exerclass object. Pass the object to the function by reference.

  Explain proper use of html with all of the elements

The proper use of HTML, with all of the elements, codes, tags, headers, forms, Metadata, and categories will assure that you will structure your site to be accessible to the users of your site, your target audience

  Simulate the metro station

To simulate the metro system, your program will create and manipulate a set of dynamic data structures that will represent various components of the metro. Figure 1 illustrates the required dynamic data structures. Your program will maintain 3 typ..

  Write class to represent temperatures in degree-fahrenheit

Write Temperature class to represent temperatures in degrees in Celsius, Fahrenheit and Kelvin. Use floating-point number for temperature and a character (type char) for scale.

  Rewrite the sql statement to make it correct.

Tell why the following SQL statement is incorrect

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