Domanda

I posted earlier inquiring how to define hex constants for this program, which someone helped me out with, and now I'm trying to figure out if this program is running correctly.

The program is intended to compute the logic expression X'Y + X'Z + YZ and put the result into D0. I need to show the contents of D0 in binary when the program completes. Here's what I have (alignment got a bit jumbled here, but it's aligned in the assembler (EASy 68K)):

START:  MOVE    X,D0
    NOT D0
    MOVE    D0,D1
    MOVE    Y,D2
    AND D2,D0
    AND Z,D1
    AND Z,D2
    OR  D1,D0
    OR  D2,D0
EXIT:   BRA EXIT
X:  DC  $000F
Y:  DC  $0033
Z:  DC  $0055

This is what I end up with in the respective data registers:

D0: 00000071 D1: 00000050 D2: 00000011

Ignoring the fact that the result is supposed to be shown in binary...being that this is a logic expression, and I use only AND and OR, shouldn't the result in D0 be either 1 or 0? Because X, Y, and Z are all non-zero constants, the expression evaluates to 1 (YZ=1)...have I made an error in the program? Or is my understanding off?

Thanks

È stato utile?

Soluzione

Logical expressions are executed simultaneously for every bit in the registers.

In C language e.g. integers 1,2,7 and -12313 are all considered equal in the context of if (a) printf("True"); else printf("False");

And the same applies for if (a || b) printf("a was not zero OR maybe b was not zero OR even both were not zero");

But for bitwise logical operations

00000000001 (binary) == 1 in decimal  
00000000010 (binary) == 2 in decimal  
------------------------------------  
00000000011 = 1 OR 2 == 3 in decimal
00000000000 = 1 AND 2 == 0 in decimal
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top