@Bobbym This is NOT a waste of time. If you ever do DSP stuff on MCUs it actually makes a lot of sense. When you start doing bit twidderly in C or C++ you'll need to understand what's happening. When you look at the disassembly view in Keil or IAR then this knowledge is FUNDAMENTAL.
Okay as per your assignment, look at the machine architecture, that will determine if the machine is using Little Endian or Big Endian storage type in the register.
The key of the program is to perform a bitwise shift operation depending on the register storage operation, and depending on the endianess, that will determine if you do a left or right bitwise shift.
Remember if you keep shifting what happens to the bits? if it's using two's complement format, what digit is used to maintain it being signed or unsigned. If you're wondering how you will get all 1's there is your clue.
Also regardless of which number you started with you can do your shifts to get all zeros.
As for if the register is all ones, what is all ones in decimal? if it's 8 bits in 2's complement representation format?. How can you check that in assembly?
If you did the course its actually pretty easy, it's been a few years for me, but this stuff is used in industry all the time.
Oh and remember the assembly mnemonics structuring will match the processor architecture of your design.
@holmes what crap are you saying? OMG.
If you shift the contents of a full register it WILL get to a 0 in the LSB if you do a shift. Remember left shift does "blank" and right shift does "blank" operations (hint * and /).
If the 8 bit register word size is 255 bits, and you try to insert a greater value than it can hold then a register OVERFLOW will occur when the register is given a value more than it can hold and it will start from 0 again.
Let's say you have an 8-bit MCU (PIC, AVR, STM8 etc) and you keep shifting bits what will happen?
Here is a 4 bit counter done on the Arduino as an example:
https://www.youtube.com/watch?v=08fTlrFOLFU
Its a 4 bit register, what happens when you keep shifting bits? It returns to 0. Remember 0 in an 8-bit register is 00000000.
Ever work with C or C++? When happens if you have an int and you try to store a larger value than the storage size? It wraps around.
See this is why this course is so important. If you get a job as an embedded software engineer this is FUNDAMENTAL knowledge. Play around with a microcontroller, program in C or C++ and see what happens.
THIS COURSE IS NOT A WASTE OF TIME IT IS IMPORTANT. Maybe you just don't work in a field where its important to YOU. But for understanding things like ECC, CRC etc and writing solid programs its invaluable.
Even if you decide to do web or mobile, unless you plan to do nothing but front end development or UI this stuff IS important. At some point you'll have to optimize something and you can't use "var" you must do an explicit type declaration like "int" and if you don't know this then you'll have a hell of a time when a player's points reaches to zero after they cross a certain value.
Its so prevalent and part of bugs it's part of the C standard library <stdlib.h>
Look at
int8_t
int16_t
int32_t
etc...
@Bobbym This stuff is what will set you apart from the dime a dozen code monkey's when you go into the field. This bit stuff is so important a BIBLE for anyone working with hardware and even hacker's is this book "Hacker's Delight" that handles a lot of bit twiddlery here:
https://www.amazon.com/Hackers-Delight-2...0321842685
Here's also a free page that people refer to all the time for bit twiddling:
https://graphics.stanford.edu/~seander/bithacks.html