Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Of course it does read the title. My question was about changing bits individually or merging registers which is a processor question and it is important for OS development
computertrick wrote:Of course it does read the title. My question was about changing bits individually or merging registers which is a processor question and it is important for OS development
That is the sort of thing any assembly language or C programmer should know, long before he/she even thinks of embarking upon OS development.
Look up the assembly language OR, AND, XOR and NOT instructions, or the C ~, |, &, ^ operators.
computertrick wrote:I am aware of all of those instructions my question was is their an instruction in 8086 to change a single bit that's what I was trying to get across
computertrick wrote:I am aware of all of those instructions my question was is their an instruction in 8086 to change a single bit that's what I was trying to get across
Those instructions do precisely that, and more besides. For example, xor ax, 4 would flip bit 2 of the ax register.
For that matter, you can do it even without those instructions. add ax, 0x80 would set bit 7, and sub ax, 0x80 would clear it. That is elementary, and, if you haven't got that far, it will be a long time before you are ready for osdev.
computertrick wrote:Of course it does read the title. My question was about changing bits individually or merging registers which is a processor question and it is important for OS development
Summon the triple /faceplam...
While OS development require excellent skills of all aspect, including flipping a bit, I suggest you read the Required_Knowledge.
For that matter, you can do it even without those instructions. add ax, 0x80 would set bit 7, and sub ax, 0x80 would clear it. That is elementary, and, if you haven't got that far, it will be a long time before you are ready for osdev.
That is incorrect. What if the bit is already set (or clear)? Adding (or subtracting) would not have the desired result.
That is incorrect. What if the bit is already set (or clear)? Adding (or subtracting) would not have the desired result.
What has that got to do with anything? or ax, 0x80 wouldn't change a bit which was already set, and "and ax, 0xff7f" wouldn't clear a bit which was already clear. That is in the nature of bitwise operations.
That is incorrect. What if the bit is already set (or clear)? Adding (or subtracting) would not have the desired result.
What has that got to do with anything? or ax, 0x80 wouldn't change a bit which was already set, and "and ax, 0xff7f" wouldn't clear a bit which was already clear. That is in the nature of bitwise operations.
Read the bit of your post that I quoted again. add is not and, sub is not or. add would clear a set bit (and affect other bits), sub would set a clear bit (and affect other bits). That is the nature of arithmetic operations.
iansjack wrote:
Read the bit of your post that I quoted again. add is not and, sub is not or. add would clear a set bit (and affect other bits), sub would set a clear bit (and affect other bits). That is the nature of arithmetic operations.
If I wanted to convert a digit into its corresponding integer value, I could either do and ax, 0xcf or sub ax, 48, and which I did would depend upon the mood I was in at the time. Similarly, and ax, 0xdf and sub ax, 32 will both convert a lower case letter into an upper case letter (or clear the archive bit in an MS-DOS fille attribute byte).
I don't remember saying that sub was the same as or (or and).