Arm/memenable

From ASMBits

You have a 4-KB (kilobyte) memory that is mapped to the address range 0xff3000 – 0xff3fff. The memory should be enabled only when an address within that range is accessed.

Write a function that returns whether a given address should cause your memory to be enabled (return 1 or 0). You should not use any add, sub, mul, or greater/less-than conditional instructions (equal or not-equal comparisons are allowed).

unsigned int memenable(unsigned int address);


In hardware, you would typically use and/or/not gates and avoid add/sub circuits due to cost. Equality comparisons with a constant can be implemented as an AND gate with some inverted inputs, but less/greater comparisons need to do subtraction, which is much more costly.


Expected solution length: Around 6 lines.

Sample Input

memenable(0xff3100)

Sample Output

r0=1

Write your solution here

Upload a source file...