topic Bitwise logical NOT does NOT work!! in IntelĀ® FPGA University Program
https://community.intel.com/t5/Intel-FPGA-University-Program/Bitwise-logical-NOT-does-NOT-work/m-p/186803#M2810
<P>Anyhow, I have this Assembly assignment in which I have to count the number of binary 0's in a given hex value. It shows us how to count the 1's. I figured I'd try the NOT operator. It mentions the NOT operator in the InstructionSetReference.PDF, but it doesn't show us how to use it anywhere. I've tried everything I can think of, but all it does is return errors upon compilation with the Altera Monitor Program. When I try it like NOT r2 It gives this error: Error: unrecognised instruction not Compilation stopped. So, what's the deal with this? I go online, and everywhere they talk about the NOT instruction, that's how you use it. Perhaps some of you are familiar with this assignment. Here's the primary code: You see, in part 3, we have to count the 0's instead of the 1's. .text .global _start _start: ldw r2, NUM(r0) /* Loading hex value from the .word directive. I will use that hex number''s binary equivalent. */ mov r5, r0 /* Register is the counter, and increments by one, leaving the last incremented value to be the max number of consequtive 1''s. */ LOOP: beq r2, r0, END /* This loops until r2 no longer contains 1''s in its binary value. */ srli r3, r2, 0x1 /* Shifts binary value of r2 to the right and stores that shifted value into r3 */ and r2, r2, r3 /* ANDing the binary of r2 with the shifted binary of r3 so that all 1''s now ANDed with 0''s turn to 0, and then overwriting r2 with the new binary result */ addi r5, r5, 1 /* Incrementing counter by 1. */ br LOOP /* Relooping this until there are no more 1''s in the binary value of r2. */ END: br END NUM: .word 0x3fabedef /* This is the value who''s binary value will be assessed for max number of consecutive 1''s. */ NOTE: Sorry about how the message all compacted together. I can't seem to figure out how to make it space out properly in this message. It's like this doesn't honor any new lines</P>Tue, 19 Apr 2016 12:36:50 GMTAltera_Forum2016-04-19T12:36:50ZBitwise logical NOT does NOT work!!
https://community.intel.com/t5/Intel-FPGA-University-Program/Bitwise-logical-NOT-does-NOT-work/m-p/186803#M2810
<P>Anyhow, I have this Assembly assignment in which I have to count the number of binary 0's in a given hex value. It shows us how to count the 1's. I figured I'd try the NOT operator. It mentions the NOT operator in the InstructionSetReference.PDF, but it doesn't show us how to use it anywhere. I've tried everything I can think of, but all it does is return errors upon compilation with the Altera Monitor Program. When I try it like NOT r2 It gives this error: Error: unrecognised instruction not Compilation stopped. So, what's the deal with this? I go online, and everywhere they talk about the NOT instruction, that's how you use it. Perhaps some of you are familiar with this assignment. Here's the primary code: You see, in part 3, we have to count the 0's instead of the 1's. .text .global _start _start: ldw r2, NUM(r0) /* Loading hex value from the .word directive. I will use that hex number''s binary equivalent. */ mov r5, r0 /* Register is the counter, and increments by one, leaving the last incremented value to be the max number of consequtive 1''s. */ LOOP: beq r2, r0, END /* This loops until r2 no longer contains 1''s in its binary value. */ srli r3, r2, 0x1 /* Shifts binary value of r2 to the right and stores that shifted value into r3 */ and r2, r2, r3 /* ANDing the binary of r2 with the shifted binary of r3 so that all 1''s now ANDed with 0''s turn to 0, and then overwriting r2 with the new binary result */ addi r5, r5, 1 /* Incrementing counter by 1. */ br LOOP /* Relooping this until there are no more 1''s in the binary value of r2. */ END: br END NUM: .word 0x3fabedef /* This is the value who''s binary value will be assessed for max number of consecutive 1''s. */ NOTE: Sorry about how the message all compacted together. I can't seem to figure out how to make it space out properly in this message. It's like this doesn't honor any new lines</P>Tue, 19 Apr 2016 12:36:50 GMThttps://community.intel.com/t5/Intel-FPGA-University-Program/Bitwise-logical-NOT-does-NOT-work/m-p/186803#M2810Altera_Forum2016-04-19T12:36:50ZRe: Bitwise logical NOT does NOT work!!
https://community.intel.com/t5/Intel-FPGA-University-Program/Bitwise-logical-NOT-does-NOT-work/m-p/186804#M2811
<P>Assuming you are programming the Altera NIOS II processor (you never say, but these are the opcodes you are using...), there is no NOT instruction. </P><P></P> <P></P>However, it can be synthesized in a number of ways, the simplest using the NOR instruction with the source register duplicated. <P></P> <P></P><CODE>
nor r5,r5,r5 ; ones complement of value in r5
nor r3,r4,r4 ; ones complement of value in r4 to r3
</CODE> <P></P> <P></P>BTW here is your code. Put it in a CODE (#) block when you post it. <P></P> <P></P><CODE>
.text
.global _start
_start: ldw r2, NUM(r0) /* Loading hex value from the .word directive. I will use that hex number''s binary equivalent. */
mov r5, r0 /* Register is the counter, and increments by one, leaving the last incremented value to be the max number of consequtive 1''s. */
LOOP: beq r2, r0, END /* This loops until r2 no longer contains 1''s in its binary value. */
srli r3, r2, 0x1 /* Shifts binary value of r2 to the right and stores that shifted value into r3 */
and r2, r2, r3 /* ANDing the binary of r2 with the shifted binary of r3 so that all 1''s now ANDed with 0''s turn to 0, and then overwriting r2 with the new binary result */
addi r5, r5, 1 /* Incrementing counter by 1. */
br LOOP /* Relooping this until there are no more 1''s in the binary value of r2. */
END: br END
NUM: .word 0x3fabedef /* This is the value who''s binary value will be assessed for max number of consecutive 1''s. */
</CODE>Fri, 13 May 2016 14:39:15 GMThttps://community.intel.com/t5/Intel-FPGA-University-Program/Bitwise-logical-NOT-does-NOT-work/m-p/186804#M2811Altera_Forum2016-05-13T14:39:15Z