Skip to main content
A better URL
Source Link
Leo B.
  • 22.3k
  • 6
  • 55
  • 168

Not to speak off the top of my head, going to https://www.pcjs.org/https://www.pcjs.org/machines/dec/pdp11/1170/4mb/ and compiling

int a, b;
extern c();
d() {
    if (a == (a & b))
        c();
}

yields the body of d() as follows:

_d:
jsr     r5,rsave
mov     _a,r0
mov     _b,r1
com     r1
bic     r1,r0
cmp     _a,r0
jne     L1
jsr     pc,_c
L1:jmp  rretrn

In other words, AND is done as complementing one of the operands and clearing the bits of the other using the result of the complement.

Not to speak off the top of my head, going to https://www.pcjs.org/ and compiling

int a, b;
extern c();
d() {
    if (a == (a & b))
        c();
}

yields the body of d() as follows:

_d:
jsr     r5,rsave
mov     _a,r0
mov     _b,r1
com     r1
bic     r1,r0
cmp     _a,r0
jne     L1
jsr     pc,_c
L1:jmp  rretrn

In other words, AND is done as complementing one of the operands and clearing the bits of the other using the result of the complement.

Not to speak off the top of my head, going to https://www.pcjs.org/machines/dec/pdp11/1170/4mb/ and compiling

int a, b;
extern c();
d() {
    if (a == (a & b))
        c();
}

yields the body of d() as follows:

_d:
jsr     r5,rsave
mov     _a,r0
mov     _b,r1
com     r1
bic     r1,r0
cmp     _a,r0
jne     L1
jsr     pc,_c
L1:jmp  rretrn

In other words, AND is done as complementing one of the operands and clearing the bits of the other using the result of the complement.

Source Link
Leo B.
  • 22.3k
  • 6
  • 55
  • 168

Not to speak off the top of my head, going to https://www.pcjs.org/ and compiling

int a, b;
extern c();
d() {
    if (a == (a & b))
        c();
}

yields the body of d() as follows:

_d:
jsr     r5,rsave
mov     _a,r0
mov     _b,r1
com     r1
bic     r1,r0
cmp     _a,r0
jne     L1
jsr     pc,_c
L1:jmp  rretrn

In other words, AND is done as complementing one of the operands and clearing the bits of the other using the result of the complement.