Question

x86 MASM Write a program that will use bit-wise instructions to take an inputted binary value...

x86 MASM

Write a program that will use bit-wise instructions to take an inputted binary value and reverse it.

Example:

Input: 000000000011
Output after instruction: 110000000000

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Let us assume the 16 bit number is stored at memory location 2450 and 2451

Algorithm –

  1. Load contents of memory location 2450 in register AL
  2. Load contents of memory location 2451 in register AH
  3. Assign 0004 to CX Register Pair
  4. Rotate the contents of AL by executing ROL instruction using CX
  5. Rotate the contents of AH by executing ROL instruction using CX
  6. Store the content of AH in memory location 2450
  7. Store the content of AL in memory location 2451

Explanation for the logic–

  1. MOV AL, [2450]: loads contents of memory location 2450 in AL
  2. MOV AH, [2451]: loads contents of memory location 2451 in AH
  3. MOV CX, 0004: assign 0004 to CX register pair
  4. ROL AL, CX: rotate the content of AL register left by 4 bits i.e. value of CX register pair
  5. ROL AH, CX: rotate the content of AH register left by 4 bits i.e. value of CX register pair
  6. MOV [2450], AH: stores the content of AH in 2450 memory address
  7. MOV [2451], AL: stores the content of AL in 2451 memory address
  8. HLT: stops executing the program
Add a comment
Know the answer?
Add Answer to:
x86 MASM Write a program that will use bit-wise instructions to take an inputted binary value...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ssembly Language Programming with x86, IRVINe MASM 1. Write a program to add 7 12 times...

    ssembly Language Programming with x86, IRVINe MASM 1. Write a program to add 7 12 times and print out the result ------------------------------------------------------------------------------- Write a program to print and add 10 20 30 40 50   ; you can use a loop The output should be “The sum of 10 20 30 40 50 ”

  • Please provide x86 (MASM not NASM) .386 (32bit) assembly program for the following (needs to be...

    Please provide x86 (MASM not NASM) .386 (32bit) assembly program for the following (needs to be compatible with Visual Studio 2015.asm file): (10 points) Write an assembly program to find the largest element by searching an array int aryll-[11, 15,-3,-4, 0,60.11,-9,18) int index-l; int max- 0; int arraySize-sizeof array /sizeof max while (index < arraySize) if (ary[index] > max) max = ary[index]; - Use cmp instruction and the appropriate jump instruction (signed or unsigned) to translate the if and while...

  • Write a C Program that: - Creates an input file (input.txt) - Take user inputted integer...

    Write a C Program that: - Creates an input file (input.txt) - Take user inputted integer for number of lines in the input file - accepts inputted text from command line to the input file (input.txt) - saves and closes file. (input.txt) - reopens and displays the newly inputted contents of the file

  • Programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift...

    Programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5 bits = input("Enter bit string: ") bits = bits[1:] + bits[0] print ("Result:", bits) to code a new encryption algorithm. The algorithm should Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting...

  • MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the...

    MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest common divisor of two positive numbers. . • Your program should read the two positive integers using dialog boxes. If they are not positive, a message box should be displayed with an appropriate message. • Your program needs to have a procedure that takes two positive integers as parameters. • You need to follow cdecl protocol for parameter passing. • Display the valid...

  • MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest...

    MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest common divisor of two positive numbers. . • Your program should read the two positive integers using dialog boxes. If they are not positive, a message box should be displayed with an appropriate message. • Your program needs to have a procedure that takes two positive integers as parameters. • You need to follow cdecl protocol for parameter passing. • Display the valid...

  • Python Programing : Convert to binary - functions Write a program that takes in a positive...

    Python Programing : Convert to binary - functions Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x // 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a...

  • Write a machine language program to input two one-digit numbers ranging from 0 to 4 (using...

    Write a machine language program to input two one-digit numbers ranging from 0 to 4 (using the character input instruction), add them, and then output the single digit sum (using the character output instruction). Execute your program in the PEP/8 simulator. Example Input: 43 (this is the numbers 4 and 3. Remember, this is two ASCII characters when inputted into your program) Output: 7 (ASCII character 55dec)

  • Use Assembly (Masm and Irvine32 library) to write a complete program that: 1. Asks the user...

    Use Assembly (Masm and Irvine32 library) to write a complete program that: 1. Asks the user to enter 2 numbers. Assume that the user enters unsigned 32-bit integers only. 2. Displays the product of the two numbers. Assume that the result will never be larger than 32 bits. 3. This process will continue till the user enters 0 for both inputs. You can’t use mul instruction in your program: You need to use shifting and addition only. Your program must...

  • I need the following done in MASM (Assmebly or ASM) This program must use Irvine Library and the outline for the code is...

    I need the following done in MASM (Assmebly or ASM) This program must use Irvine Library and the outline for the code is below (Kip irvine) Write an assembly language program to input a string from the user. Your program should do these two things: 1. count and display the number of words in the user input string. 2. Flip the case of each character from upper to lower or lower to upper. For example if the user types in:   ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT