Created
June 19, 2012 21:07
-
-
Save josejuan/2956541 to your computer and use it in GitHub Desktop.
Microcódigo de reglas.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Extraer( | |
int *A, // I/O unidades actuales en almacén | |
int *C, // I/O valor actual en la tarifa | |
int *P, // I/O unidades pendientes a extraer | |
char *m // microprograma a ejecutar | |
) { | |
int r; // registro de memoria | |
#define INTENTA(S) { \ | |
int x = S - *P; \ | |
if(x >= 0) {S = x; *P = 0;} \ | |
else {S = 0; *P = -x;} \ | |
} | |
while(*m) | |
switch(*m++) { | |
case 'c': INTENTA(*C); break; | |
case 'a': INTENTA(*A); break; | |
case 'C': *C -= *P; *P = 0; break; | |
case 'A': *A -= *P; *P = 0; break; | |
case 's': r = *P; break; | |
case 'r': *P = r; break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment