Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- FPGAs and Programmable Solutions
- Intel® FPGA University Program
- Bitwise logical NOT does NOT work!!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

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

Altera_Forum

Valued Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-19-2016
05:36 AM

730 Views

Bitwise logical NOT does NOT work!!

1 Reply

Highlighted
##

Altera_Forum

Valued Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-13-2016
07:39 AM

7 Views

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.

However, it can be synthesized in a number of ways, the simplest using the NOR instruction with the source register duplicated.```
nor r5,r5,r5 ; ones complement of value in r5
nor r3,r4,r4 ; ones complement of value in r4 to r3
```

BTW here is your code. Put it in a CODE (#) block when you post it. ```
.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. */
```

For more complete information about compiler optimizations, see our Optimization Notice.