I'm trying to figure out how to implement a bit counter in LC3 assembly language. ex: input "00001100001000001" output "000000000000100" I would be counting the number of ones in the string of bits and outputting that number in binary. I know how to do this given one bit at a time, but I don't know how I can analyze only one bit of a 16 bit string at a time. Thanks.
1
There are 1 best solutions below
Related Questions in BIT
- How to flip bits in one operation with c#?
- Values getting Overflowed while converting Bit into TB
- Problem with EF Core 8 handling MSSQL tinyint & nullable bit in Blazor
- How to add a additional property in the overview tab of the bit dev mdx documentation for the components?
- vscode debugger display binary full set of bits
- Has a value of 0 for bit 1, what does it mean?
- SDL2 1-bit surface, assign one of two colors in palette to a pixel
- Rotate 2D grid of bits
- How to flip the bits of a number according to the count
- Explain how left shift works in Java
- Create new mask
- Count all set bit sum upto the Nth number
- Standard way of getting a bit pattern of all ones
- Where do I add a zero as padding for 4B5B code?
- EasyModbus Framework Read Bit from device
Related Questions in LC3
- Installing the C compiler for LC3
- LC-3 Assembly OR operation
- I am unsure about LC-3 NOP
- LC-3 Assemby Counters
- Assembly - Prime/Not Prime - LC3
- How to return from HALT in LC3?
- How can I take multiple digit positive integers as input in LC3?
- How can I print a multiple-digit decimal number stored in a register in LC-3 assembly?
- LC-3 Program: Tracing the Execution
- Is there a reason this LC-3 subroutine keeps looping?
- LC-3 Assembly Calculator
- How do I modify my code to compare the user input against "QUIT" and have it exit the loop if they don't match?
- LC-3 program with 3 bugs (2 syntax and 1 logic)
- LC-3 Assembly Code isn't processing user's input correctly
- What is the equivalent of .WORD in LC3?
Related Questions in BITCOUNT
- Why newer clang is generating one more instruction than just popcntl to count the bits of an int on haswell architecture?
- How can I use the "builtin" function __builtin_ctzll in a VS C++ Project?
- message output not working due to BitCount and Length being zero
- 32 bit builtin population count for clang counts long long integer c++
- XOR operation and BitCount in Java on Long variables returns java.lang.NumberFormatException
- Matrix transpose and population count
- Counting 1 bits (population count) on large data using AVX-512 or AVX-2
- Counting number of '1' values in each bit position in Redshift column
- Java - Big O of bitCount()?
- How does Long.bitCount() finds the number of set bits?
- Calculate Hamming Distance in SQLite
- what's the difference between __builtin_popcountll and_mm_popcnt_u64?
- Trouble doing a bitwise xor + bit_count in mysql
- Can someone explain how this bitCount code works?
- MongoDB support search Bitwise XOR and Bit Count?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are several different ways you can count the number of bits in a value stored in the LC3.
Personally, I would use the bit mask method because it's quick and efficient, and I won't have to worry about bogging my code down.
A bit mask looks like the following:
Now all you have to do is create a loop that AND's each of these mask values with your stored value. If you get a positive number after ANDing them then you would just add 1 to your bit counter, and then repeat the process with each of the remaining mask values.