~crc_/napia-rohi

f996e1321bf6f339320ca9fa8e9e83f08b2d8f21 — crc 7 months ago 1b08aa4
display name of unresolved labels now
1 files changed, 10 insertions(+), 5 deletions(-)

M rohi.c.unu
M rohi.c.unu => rohi.c.unu +10 -5
@@ 195,7 195,7 @@ void store_half(int value, int address) {
  int a, b;
  if (value > 65535) {
    printf("Error: Unable to store value `%d` ", value);
    printf("halfword address\n");
    printf("in a halfword address\n");
    exit(1);
  }
  a = value & 0xFF;


@@ 214,14 214,14 @@ void store_word(int value, int address) {

## Saving an Image

The image is saved to `output.napia`. The full memory image
The image is saved to `output.ni`. The full memory image
is saved to the file, so all files should be 65536 bytes in
length.

~~~
void save() {
  FILE *fp;
  if ((fp = fopen("output.napia", "wb")) == NULL) {
  if ((fp = fopen("output.ni", "wb")) == NULL) {
    printf("Unable to save the image!\n");
    exit(2);
  }


@@ 269,6 269,11 @@ int lookup(char *name) {
      slice = Labels[n].address;
    }
  }

  if (slice == 65536) {
    printf("Error: `%s` not found.\n", name);
  }

  return slice;
}
~~~


@@ 620,7 625,7 @@ void rohi(char *filename, int base) {
~~~
void save_map() {
  FILE *fp;
  if ((fp = fopen("output.map", "wb")) == NULL) {
  if ((fp = fopen("output.nm", "wb")) == NULL) {
    printf("Unable to save the label map!\n");
    exit(2);
  }


@@ 639,7 644,7 @@ int main(int argc, char **argv) {
  if (argc > 1) {
    rohi(argv[1], 0);
    save();
    printf("Wrote %d bytes to output.napia\n", here);
    printf("Wrote %d bytes to output.ni\n", here);
    printf("%d labels\n", np);
    save_map();
  }