diff options
author | Pixel <> | 2001-04-16 21:44:42 +0000 |
---|---|---|
committer | Pixel <> | 2001-04-16 21:44:42 +0000 |
commit | cb850755d0ca7c625fe418ef6b9770876c3308f2 (patch) | |
tree | 78cd8a9305943d5779a39e4a1a140469a27dec1a /lib/memoire.c | |
parent | 85155ff54ba94f8ac40e267f83435284e88b866c (diff) |
Pouet
Diffstat (limited to 'lib/memoire.c')
-rw-r--r-- | lib/memoire.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/memoire.c b/lib/memoire.c index 48daf0e..eb6dadc 100644 --- a/lib/memoire.c +++ b/lib/memoire.c @@ -1,3 +1,5 @@ +#include <stdio.h> +#include <stdlib.h> #include "memoire.h" #include "interne.h" #include "simulator.h" @@ -20,6 +22,15 @@ Uint32 * memoire_principale; /** **/ /*****************************************/ + +void InitMemoire(void) { + memoire_principale = (Uint32 *) Emalloc(TAILLE_MEMOIRE * sizeof(Uint32)); +} + +void FreeMemoire(void) { + free(memoire_principale); +} + /* Lit le mot qui se trouve à l'offset 'offset' en mémoire */ Uint32 LD(Uint32 offset) { @@ -27,24 +38,27 @@ Uint32 LD(Uint32 offset) switch (offset) { case 0xffffff00: - return (!feof(stdin)); + initterm(); + i = !feof(input); + clearterm(); + return (i); case 0xffffff01: - return (fgetc(stdin)); - case 0xffffff05: + initterm(); + i = fgetc(input); clearterm(); + break; + case 0xffffff05: fscanf(input, "%i", &i); - initterm(); - return i; + break; default: if (offset >= TAILLE_MEMOIRE) { exception(1, _("Invalid Memory Adress")); - return (i); } else { i = memoire_principale[offset]; - return (i); } break; } + return i; } static void copychaine(Uint32 * t, char * s) { |