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
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.
|