Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:26 01 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : bitcopy

Author Message
drkl

Senior Member

Joined: 18/10/2015
Location: Hungary
Posts: 102
Posted: 12:30am 17 Mar 2016
Copy link to clipboard 
Print this post

Hello,

How can realize the bitcopy instruction in MMBasic?
REG2.BIT2=REG1.BIT1
REG1,REG2 are a 8 or 16 bit integers
BIT1,BIT2 are the bit positions within the integers.

Regards
drkl
 
jwaldha
Newbie

Joined: 14/01/2016
Location: Hungary
Posts: 10
Posted: 01:39am 17 Mar 2016
Copy link to clipboard 
Print this post

Quick and dirty:
Sub bc(reg1 As integer, bit1 As integer, reg2 As integer, bit2 As integer)
Print "before: "; Bin$(reg1), bit1, Bin$(reg2), bit2
If (reg1 And (2 ^ bit1)) Then
reg2 = reg2 Or (2 ^ bit2)
Else
reg2 = reg2 And ((2 ^ bit2) Xor &hffffffffffffffff)
EndIf
Print "after : "; Bin$(reg1), bit1, Bin$(reg2), bit2
End Sub

---
JWaldha
 
drkl

Senior Member

Joined: 18/10/2015
Location: Hungary
Posts: 102
Posted: 06:55am 17 Mar 2016
Copy link to clipboard 
Print this post

Hello,
The world is small, isn't it? All is hungarian...
Thank you for your code snipet, it is very good, I tested.
I try to use masking, but it was too difficult...
If you think,look: http://drkonya.eu

Regards
drkl
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025