Author Topic: Changing bits  (Read 3748 times)

0 Members and 1 Guest are viewing this topic.

Offline Camdenmil

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 121
  • Rating: +4/-0
    • View Profile
Changing bits
« on: January 15, 2011, 07:25:04 pm »
I'm probably missing something, but is there a way to get/set the value of a single bit in axe?
It is bad luck to be superstitious.

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Changing bits
« Reply #1 on: January 15, 2011, 07:27:47 pm »
Documentation has this for reading bits:
Code: [Select]
EXPeBIT# where e is euler's e. Returns BIT# of EXP, where the high bit is bit0 and the low bit is bit 7. Example, 255e0 would return 1.

Writing to bits, you basically have to "or" the bit over; so
Code: [Select]
e^(bit#) or EXP -> EXP As for resetting bits, I forget...

edit: here's a more optimizedish version by runer112; http://ourl.ca/7815/138430
« Last Edit: January 15, 2011, 07:28:48 pm by squidgetx »

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Changing bits
« Reply #2 on: January 15, 2011, 10:04:21 pm »
or will set a bit
and will reset a bit
xor will toggle a bit
Code: [Select]
e^(#) [or/and/xor] EXP->EXP
where # is the bit to set 0-7 starting from the right hand side.


Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Changing bits
« Reply #3 on: January 15, 2011, 10:15:24 pm »
Actually, for and you need to use not(e^(#)) and EXP->EXP
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: Changing bits
« Reply #4 on: January 15, 2011, 10:37:55 pm »
How 'bout an Axiom, anyone?
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Changing bits
« Reply #5 on: January 15, 2011, 10:38:48 pm »
Perhaps I'm behind in my Axe, but I wasn't aware that the Not( function was implemented in Axe.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Changing bits
« Reply #6 on: January 15, 2011, 10:44:21 pm »
Perhaps I'm behind in my Axe, but I wasn't aware that the Not( function was implemented in Axe.
It was added in Axe 0.4.7: "Bitwise complement command for 8 and 16 bit numbers"
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Changing bits
« Reply #7 on: January 15, 2011, 10:49:12 pm »
I've been wanting that function for quite some time. Thanks for pointing it out  :)
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ