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

  Program to processes the test data

Write a program that processes the test data. The output should be the student's ID, followed by the answers, followed by the test score, and followed by the test grade.

  Write program encodes english language phrase into pig latin

Write a program that encodes English language phrases into pig Latin. Pig Latin is a form of coded language oftenused for amusement. Many variations exist in the methods used toform pig Latin phrases.

  Write junit test methods for the starter code given

Write JUnit test methods for the starter code given in the Filtering Data exercise of the Abstract Classes and Interfaces lesson.

  Find the sum and difference for numbers

Write a program that prompts the user for two numbers, finds the sum and difference for those numbers and displays a descriptive label for each computation by calling two different functions. Use Function Prototypes.

  How does the nist become so relevant

What is an insider threat, and how can this plague system security - how does the NIST become so relevant? Why?

  How is active directory implemented?

How is Active Directory implemented?

  Create a class called dateprofile

Assignment - Computer Dating, Create a class called DateProfile that has the following private instance members: gender - a char, the gender of the applicant ('M' or 'F')

  Computer sales and repair store system

It is required to design a relational database system for a "realistic" application

  Explain encapsulation of data and methods

Explain the following three key concepts of object-oriented technology. Illustrate each one using examples. a) Encapsulation of data and methods b) Support for polymorphism c) Inheritance within class hierarchies.

  Function to calculate recurrence using dynamic programming

Write down a function to calculate the following recurrence by using dynamic programming. PN = PN-1 + 2PN-2, with P1 = P0 = 1.

  Write a function to circulate a list

Write a function to circulate a list. The function takes two paramaters, the first defines how many elements of the list to circulate, and the second is the list. The output should be the circulated list.

  How to assess quality of computer program

These are generally done at macroscopic level, but how would you assess quality of computer program if you received the e-mail with source listing of a program?

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