Thread: Bitwise operators

  1. #1
    kerrywolfe
    Guest

    Bitwise operators

    Hey everybody,

    I have some quick and easy questions for you. Need to create some C++ statements to resemble assembler language (H6809).

    Need:

    1. ANDA# - computes the bitwise and of memory[pc] and A....

    2. BEQ - stores the byte held in Memory[PC] (signextended) in EAR.


    ANy help much appreciated!!

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    1. You can use the & operator -

    var &= A;

    with store the bitwise AND of var and A in var (whatever A represents).

    2. There's no way of working directly with registers in C++ (I'm assuming EAR is a register). However you can use the register keyword as a hint to the compiler to store a variable in a register (which it often ignores). Something like -

    register byte_t = var;

    where var symbolises the location in memory, and byte_t is a typedef of char.

  3. #3
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382
    You could do what he said or you could use:

    Code:
    asm
    {
       mov ax, a
       mov bx, b
       or ax, bx
       mov a, ax
    }
    This would leave the result in a. I think. My asm is a little rusty.
    Current Setup: Win 10 with Code::Blocks 17.12 (GNU GCC)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitwise operators
    By gnewfenix in forum C Programming
    Replies: 2
    Last Post: 05-16-2009, 08:43 PM
  2. Bitwise Operators
    By rrc55 in forum C Programming
    Replies: 6
    Last Post: 04-30-2009, 11:37 AM
  3. Palindromes and Bitwise operators
    By Dr Tornillo in forum C Programming
    Replies: 8
    Last Post: 08-02-2007, 02:31 PM
  4. bitwise and arithmetic Operators
    By Whiteghost in forum C Programming
    Replies: 4
    Last Post: 12-28-2006, 02:13 PM
  5. Bitwise Operators, Help!!
    By Mini__C in forum C Programming
    Replies: 6
    Last Post: 07-14-2004, 04:20 PM