| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 
 |  
#include <stdio.h>
#include <stdlib.h>
#include <conio2.h>
 
static void display (unsigned long *a, size_t n)
{
   size_t i;
 
   for (i = 0; i < n; i++)
   {
      printf ("%2lu ", a[i]);
   }
   printf ("\n");
}
 
int main (void)
{
/* circuit dw 2,4,1,2,3,1,3,4,2,3,5,4,5,6 */
   unsigned long circuit[] = { 2, 4, 1, 2, 3, 1, 3, 4, 2, 3, 5, 4, 5, 6 };
 
/* entrees dw 0,0,0,0,0,0,0,0,0,0,0,0 */
   unsigned long entrees[12] = { 0 };
 
/* mov si, 0 */
   int si = 0;
 
/* mov cx, 4 */
   int cx;
 
/* mov di, 4 */
   int di = 1;
 
/* boucle: */
   for (cx = 0; cx < 4; cx++)
   {
 
/* mov si, circuit[di] */
      unsigned long si = circuit[di];
 
/* mov ax, entrees[si-1] */
      unsigned long ax = entrees[si - 1];
 
/* mov bx, entrees[si] */
      unsigned long bx = entrees[si];
 
/* ;code porte nand */
/* and ax,bx */
      ax &= bx;
 
/* not ax */
      ax = ~ax;
 
/* and ax,1 */
      ax &= 1;
 
/* mov entrees[si+1], ax */
      entrees[di + 1] = ax;
 
/* add di, 6 */
      di++;
 
      display (entrees, sizeof entrees / sizeof *entrees);
 
/* loop boucle */
   }
 
   return 0;
} | 
Partager