-
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!!
-
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.
-
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.