1 static char _[] = " @(#)dump.c 5.20 93/07/30 16:38:27, Srini, AMD ";
2 /******************************************************************************
3 * Copyright 1991 Advanced Micro Devices, Inc.
5 * This software is the property of Advanced Micro Devices, Inc (AMD) which
6 * specifically grants the user the right to modify, use and distribute this
7 * software provided this notice is not removed or altered. All other rights
10 * AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
11 * SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
12 * DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
13 * USE OF THIS SOFTWARE.
15 * So that all may benefit from your experience, please report any problems
16 * or suggestions about this software to the 29K Technical Support Center at
17 * 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
18 * 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
20 * Advanced Micro Devices, Inc.
21 * 29K Support Products
23 * 5900 E. Ben White Blvd.
26 *****************************************************************************
27 * Engineer: Srini Subramanian.
28 *****************************************************************************
30 ** This code provides dump routines to output data in
31 ** hex / ASCII formats.
33 *****************************************************************************
54 int get_addr_29k PARAMS((char *, struct addr_29k_t *));
55 int addr_29k_ok PARAMS((struct addr_29k_t *));
56 int print_addr_29k PARAMS((INT32, ADDR32));
58 int dump_mem_word PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
59 int dump_reg_word PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
60 int dump_mem_half PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
61 int dump_reg_half PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
62 int dump_mem_byte PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
63 int dump_reg_byte PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
64 int dump_mem_float PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
65 int dump_reg_float PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
66 int dump_mem_double PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
67 int dump_reg_double PARAMS((INT32 mspace, ADDR32 addr, INT32 bytes, BYTE *buf));
69 int get_data PARAMS((BYTE *, BYTE *, int));
70 int dump_ASCII PARAMS((char *, int, BYTE *, int));
74 ** The function below is used in dumping data. This function is
75 ** called in the main command loop parser of the monitor. The
76 ** parameters passed to this function are:
78 ** token - This is an array of pointers to strings. Each string
79 ** referenced by this array is a "token" of the user's
80 ** input, translated to lower case.
82 ** token_count - This is the number of tokens in "token".
84 ** This function reduces the tokens to three parameters:
85 ** memory_space, address and byte_count. The address parameter is
86 ** aligned as follows:
88 ** - All register accesses are byte aligned. The address,
89 ** however, accesses 32 bit words. The valued in these
90 ** registers are displayed in formats determined by the
93 ** - Memory addresses are aligned and displayed according
94 ** to the dump format as specified in the first token.
101 dump_cmd(token, token_count)
105 static INT32 memory_space=D_MEM;
106 static ADDR32 address=0;
109 struct addr_29k_t addr_29k_start;
110 struct addr_29k_t addr_29k_end;
117 INT32 bytes_returned;
121 ** What is the dump format?
124 if ((strcmp(token[0], "d") == 0) ||
125 (strcmp(token[0], "dw") == 0)) {
126 dump_format = WORD_FORMAT;
127 object_size = sizeof(INT32);
128 align_mask = 0xfffffffc;
131 if (strcmp(token[0], "dh") == 0) {
132 dump_format = HALF_FORMAT;
133 object_size = sizeof(INT16);
134 align_mask = 0xfffffffe;
137 if (strcmp(token[0], "db") == 0) {
138 dump_format = BYTE_FORMAT;
139 object_size = sizeof(BYTE);
140 align_mask = 0xffffffff;
143 if (strcmp(token[0], "df") == 0) {
144 dump_format = FLOAT_FORMAT;
145 object_size = sizeof(float);
146 align_mask = 0xfffffffc;
149 if (strcmp(token[0], "dd") == 0) {
150 dump_format = DOUBLE_FORMAT;
151 object_size = sizeof(double);
152 align_mask = 0xfffffff8;
158 ** Get start address and byte count
161 if (token_count == 1) {
162 if (ISREG(memory_space))
163 address = address + (byte_count/4);
165 if (ISMEM(memory_space))
166 address = address + byte_count;
169 /* Check the start address */
170 addr_29k_start.address = address;
171 addr_29k_start.memory_space = memory_space;
172 result = addr_29k_ok(&addr_29k_start);
177 if (token_count == 2) {
178 result = get_addr_29k(token[1], &addr_29k_start);
181 /* Check the start address */
182 result = addr_29k_ok(&addr_29k_start);
186 memory_space = addr_29k_start.memory_space;
187 /* Make sure we have an even multiple of object_size */
188 if (ISREG(memory_space)) {
189 address = addr_29k_start.address;
190 byte_count = (byte_count + (object_size - 1)) & 0xfffffffc;
193 if (ISMEM(memory_space)) {
194 address = addr_29k_start.address & align_mask;
195 byte_count = (byte_count + (object_size - 1)) & align_mask;
201 if (token_count == 3) {
202 result = get_addr_29k(token[1], &addr_29k_start);
205 /* Only check the start address */
206 result = addr_29k_ok(&addr_29k_start);
209 result = get_addr_29k(token[2], &addr_29k_end);
213 if (addr_29k_start.memory_space != addr_29k_end.memory_space)
215 if (addr_29k_start.address > addr_29k_end.address)
218 memory_space = addr_29k_start.memory_space;
219 if (ISREG(memory_space)) {
220 address = addr_29k_start.address;
221 byte_count = (addr_29k_end.address -
222 addr_29k_start.address + 1) * 4;
225 if (ISMEM(memory_space)) {
226 address = addr_29k_start.address & align_mask;
227 byte_count = ((addr_29k_end.address & align_mask) -
228 (addr_29k_start.address & align_mask) +
244 /* Will the data overflow the message buffer? Done by TIP ??*/
245 if ((read_buffer = (BYTE *) malloc((unsigned int) byte_count)) == NULL) {
251 if ((retval = Mini_read_req(memory_space,
253 byte_count / object_size,
257 hostendian)) != SUCCESS) {
261 bytes_returned = bytes_returned * object_size;
263 /* Continue if SUCCESSful */
266 ** Call data format routines
269 if ISMEM(memory_space) {
270 if (dump_format == WORD_FORMAT)
271 result = dump_mem_word(memory_space,
276 if (dump_format == HALF_FORMAT)
277 result = dump_mem_half(memory_space,
282 if (dump_format == BYTE_FORMAT)
283 result = dump_mem_byte(memory_space,
288 if (dump_format == FLOAT_FORMAT)
289 result = dump_mem_float(memory_space,
294 if (dump_format == DOUBLE_FORMAT)
295 result = dump_mem_double(memory_space,
301 if ISREG(memory_space) {
302 if (dump_format == WORD_FORMAT)
303 result = dump_reg_word(memory_space,
308 if (dump_format == HALF_FORMAT)
309 result = dump_reg_half(memory_space,
314 if (dump_format == BYTE_FORMAT)
315 result = dump_reg_byte(memory_space,
320 if (dump_format == FLOAT_FORMAT)
321 result = dump_reg_float(memory_space,
326 if (dump_format == DOUBLE_FORMAT)
327 result = dump_reg_double(memory_space,
335 (void) free ((char *) read_buffer);
338 } /* end dump_cmd() */
343 ** Functions used by dump_cmd()
348 ** This function is used to dump 32 bit words of data.
349 ** the address is printed, followed by the data, grouped
350 ** into 8 character long strings, each representing one
351 ** 32 bit word. Space for four 32-bit words is reserved
352 ** on each line. Following the hex data, an ASCII
353 ** representation of the data is printed.
357 dump_mem_word(memory_space, read_address, bytes_returned, read_buffer)
360 INT32 bytes_returned;
365 ADDR32 start_address;
367 ADDR32 last_print_address;
371 struct addr_29k_t addr_29k;
373 char ASCII_buffer[20];
377 ASCII_buffer[0] = '\0';
379 address_mask = 0xfffffff0;
380 start_address = read_address;
381 end_address = read_address + bytes_returned;
382 last_print_address = (end_address + 0xf) & address_mask;
383 address = start_address & address_mask;
386 ** Loop while data available
389 while (address <= last_print_address) {
391 /* Exit if address not valid */
392 addr_29k.memory_space = memory_space;
393 addr_29k.address = address;
394 result = addr_29k_ok(&addr_29k);
396 if (io_config.echo_mode == (INT32) TRUE)
397 fprintf(io_config.echo_file, "\n\n");
398 fprintf(stderr, "\n\n");
402 /* Print out ASCII data */
403 if ((address & address_mask) == address) {
404 fprintf(stderr, " %s\n", ASCII_buffer);
405 if (io_config.echo_mode == (INT32) TRUE)
406 fprintf(io_config.echo_file, " %s\n", ASCII_buffer);
410 /* Print address in margin */
411 if (((address & address_mask) == address) &&
412 (address != last_print_address)) {
413 result = print_addr_29k(memory_space, address);
418 /* Do leading and trailing spaces (if necessary) */
419 if ((address < start_address) ||
420 (address >= end_address)) {
421 fprintf(stderr, " ");
422 if (io_config.echo_mode == (INT32) TRUE)
423 fprintf(io_config.echo_file, " ");
424 result = dump_ASCII(ASCII_buffer, ASCII_index,
425 (BYTE *) NULL, sizeof(INT32));
426 ASCII_index = ASCII_index + sizeof(INT32);
427 address = address + sizeof(INT32);
430 /* Print out hex data */
431 if ((address >= start_address) &&
432 (address < end_address)) {
434 result = get_data((BYTE *)&data_word,
435 &read_buffer[byte_count],
440 fprintf(stderr, "%08lx ", data_word);
441 if (io_config.echo_mode == (INT32) TRUE)
442 fprintf(io_config.echo_file, "%08lx ", data_word);
444 /* Build ASCII srting */
445 result = dump_ASCII(ASCII_buffer,
447 &read_buffer[byte_count],
449 ASCII_index = ASCII_index + sizeof(INT32);
451 address = address + sizeof(INT32);
453 byte_count = byte_count + sizeof(INT32);
459 fprintf(stderr, "\n");
460 if (io_config.echo_mode == (INT32) TRUE)
461 fprintf(io_config.echo_file, "\n");
465 } /* end dump_mem_word() */
469 dump_reg_word(memory_space, read_address, bytes_returned, read_buffer)
472 INT32 bytes_returned;
477 ADDR32 start_address;
479 ADDR32 last_print_address;
483 struct addr_29k_t addr_29k;
485 char ASCII_buffer[20];
489 ASCII_buffer[0] = '\0';
491 address_mask = 0xfffffffc;
492 start_address = read_address;
493 end_address = read_address + (bytes_returned / 4);
494 last_print_address = (end_address + 0x3) & address_mask;
495 address = start_address & address_mask;
498 ** Loop while data available
501 while (address <= last_print_address) {
503 /* Exit if address not valid */
504 addr_29k.memory_space = memory_space;
505 addr_29k.address = address;
506 result = addr_29k_ok(&addr_29k);
508 fprintf(stderr, "\n\n");
509 if (io_config.echo_mode == (INT32) TRUE)
510 fprintf(io_config.echo_file, "\n\n");
514 /* Print out ASCII data */
515 if ((address & address_mask) == address) {
516 fprintf(stderr, " %s\n", ASCII_buffer);
517 if (io_config.echo_mode == (INT32) TRUE)
518 fprintf(io_config.echo_file, " %s\n", ASCII_buffer);
522 /* Print address in margin */
523 if (((address & address_mask) == address) &&
524 (address != last_print_address)) {
525 result = print_addr_29k(memory_space, address);
530 /* Do leading and trailing spaces (if necessary) */
531 if ((address < start_address) ||
532 (address >= end_address)) {
533 fprintf(stderr, " ");
534 if (io_config.echo_mode == (INT32) TRUE)
535 fprintf(io_config.echo_file, " ");
536 result = dump_ASCII(ASCII_buffer, ASCII_index,
537 (BYTE *) NULL, sizeof(INT32));
538 ASCII_index = ASCII_index + sizeof(INT32);
539 address = address + 1;
542 /* Print out hex data */
543 if ((address >= start_address) &&
544 (address < end_address)) {
546 result = get_data((BYTE *)&data_word,
547 &read_buffer[byte_count],
552 fprintf(stderr, "%08lx ", data_word);
553 if (io_config.echo_mode == (INT32) TRUE)
554 fprintf(io_config.echo_file, "%08lx ", data_word);
556 /* Build ASCII srting */
557 result = dump_ASCII(ASCII_buffer,
559 &read_buffer[byte_count],
561 ASCII_index = ASCII_index + sizeof(INT32);
563 address = address + 1;
565 byte_count = byte_count + sizeof(INT32);
571 fprintf(stderr, "\n");
572 if (io_config.echo_mode == (INT32) TRUE)
573 fprintf(io_config.echo_file, "\n");
577 } /* end dump_reg_word() */
582 ** This function is used to dump memory as half words.
586 dump_mem_half(memory_space, read_address, bytes_returned, read_buffer)
589 INT32 bytes_returned;
594 ADDR32 start_address;
596 ADDR32 last_print_address;
601 struct addr_29k_t addr_29k;
603 char ASCII_buffer[20];
607 ASCII_buffer[0] = '\0';
609 address_mask = 0xfffffff0;
610 start_address = read_address;
611 end_address = read_address + bytes_returned;
612 last_print_address = (end_address + 0xf) & address_mask;
613 address = start_address & address_mask;
616 ** Loop while data available
619 while (address <= last_print_address) {
621 /* Exit if address not valid */
622 addr_29k.memory_space = memory_space;
623 addr_29k.address = address;
624 result = addr_29k_ok(&addr_29k);
626 fprintf(stderr, "\n\n");
627 if (io_config.echo_mode == (INT32) TRUE)
628 fprintf(io_config.echo_file, "\n\n");
632 /* Print out ASCII data */
633 if ((address & address_mask) == address) {
634 fprintf(stderr, " %s\n", ASCII_buffer);
635 if (io_config.echo_mode == (INT32) TRUE)
636 fprintf(io_config.echo_file, " %s\n", ASCII_buffer);
640 /* Print address in margin */
641 if (((address & address_mask) == address) &&
642 (address != last_print_address)) {
643 result = print_addr_29k(memory_space, address);
648 /* Do leading and trailing spaces (if necessary) */
649 if ((address < start_address) ||
650 (address >= end_address)) {
651 fprintf(stderr, " ");
652 if (io_config.echo_mode == (INT32) TRUE)
653 fprintf(io_config.echo_file, " ");
654 result = dump_ASCII(ASCII_buffer, ASCII_index,
655 (BYTE *) NULL, sizeof(INT16));
656 ASCII_index = ASCII_index + sizeof(INT16);
657 address = address + sizeof(INT16);
660 /* Print out hex data */
661 if ((address >= start_address) &&
662 (address < end_address)) {
664 result = get_data((BYTE *)&data_half,
665 &read_buffer[byte_count],
670 /* We have to cast to INT32 to print out a hex halfword */
671 /* (the Sun libraries sign extend to 32 bits) */
672 data_word = (INT32) data_half;
673 data_word = (data_word & 0x0000ffff);
674 fprintf(stderr, "%04x ", data_word);
675 if (io_config.echo_mode == (INT32) TRUE)
676 fprintf(io_config.echo_file, "%04x ", data_word);
678 /* Build ASCII srting */
679 result = dump_ASCII(ASCII_buffer,
681 &read_buffer[byte_count],
683 ASCII_index = ASCII_index + sizeof(INT16);
685 address = address + sizeof(INT16);
687 byte_count = byte_count + sizeof(INT16);
693 fprintf(stderr, "\n");
694 if (io_config.echo_mode == (INT32) TRUE)
695 fprintf(io_config.echo_file, "\n");
698 } /* end dump_mem_half() */
703 ** This function is used to dump registers as half words.
707 dump_reg_half(memory_space, read_address, bytes_returned, read_buffer)
710 INT32 bytes_returned;
715 ADDR32 start_address;
717 ADDR32 last_print_address;
721 struct addr_29k_t addr_29k;
723 char ASCII_buffer[20];
727 ASCII_buffer[0] = '\0';
729 address_mask = 0xfffffffc;
730 start_address = read_address;
731 end_address = read_address + (bytes_returned / 4);
732 last_print_address = (end_address + 0x3) & address_mask;
733 address = start_address & address_mask;
736 ** Loop while data available
739 while (address <= last_print_address) {
741 /* Exit if address not valid */
742 addr_29k.memory_space = memory_space;
743 addr_29k.address = address;
744 result = addr_29k_ok(&addr_29k);
746 fprintf(stderr, "\n\n");
747 if (io_config.echo_mode == (INT32) TRUE)
748 fprintf(io_config.echo_file, "\n\n");
752 /* Print out ASCII data */
753 if ((address & address_mask) == address) {
754 fprintf(stderr, " %s\n", ASCII_buffer);
755 if (io_config.echo_mode == (INT32) TRUE)
756 fprintf(io_config.echo_file, " %s\n", ASCII_buffer);
760 /* Print address in margin */
761 if (((address & address_mask) == address) &&
762 (address != last_print_address)) {
763 result = print_addr_29k(memory_space, address);
768 /* Do leading and trailing spaces (if necessary) */
769 if ((address < start_address) ||
770 (address >= end_address)) {
771 fprintf(stderr, " ");
772 if (io_config.echo_mode == (INT32) TRUE)
773 fprintf(io_config.echo_file, " ");
774 result = dump_ASCII(ASCII_buffer, ASCII_index,
775 (BYTE *) NULL, sizeof(INT16));
776 ASCII_index = ASCII_index + sizeof(INT16);
778 address = address + 1;
781 /* Print out hex data */
782 if ((address >= start_address) &&
783 (address < end_address)) {
785 result = get_data((BYTE *)&data_word,
786 &read_buffer[byte_count],
791 fprintf(stderr, "%04lx %04lx ",
792 ((data_word >> 16) & 0xffff),
793 (data_word & 0xffff));
794 if (io_config.echo_mode == (INT32) TRUE)
795 fprintf(io_config.echo_file, "%04lx %04lx ",
796 ((data_word >> 16) & 0xffff),
797 (data_word & 0xffff));
799 /* Build ASCII srting */
800 result = dump_ASCII(ASCII_buffer,
802 &read_buffer[byte_count],
804 ASCII_index = ASCII_index + sizeof(INT32);
806 address = address + 1;
808 byte_count = byte_count + sizeof(INT32);
814 fprintf(stderr, "\n");
815 if (io_config.echo_mode == (INT32) TRUE)
816 fprintf(io_config.echo_file, "\n");
819 } /* end dump_reg_half() */
824 ** This function is used to dump memory as bytes.
828 dump_mem_byte(memory_space, read_address, bytes_returned, read_buffer)
831 INT32 bytes_returned;
836 ADDR32 start_address;
838 ADDR32 last_print_address;
842 struct addr_29k_t addr_29k;
844 char ASCII_buffer[20];
848 ASCII_buffer[0] = '\0';
850 address_mask = 0xfffffff0;
851 start_address = read_address;
852 end_address = read_address + bytes_returned;
853 last_print_address = (end_address + 0xf) & address_mask;
854 address = start_address & address_mask;
857 ** Loop while data available
860 while (address <= last_print_address) {
862 /* Exit if address not valid */
863 addr_29k.memory_space = memory_space;
864 addr_29k.address = address;
865 result = addr_29k_ok(&addr_29k);
867 fprintf(stderr, "\n\n");
868 if (io_config.echo_mode == (INT32) TRUE)
869 fprintf(io_config.echo_file, "\n\n");
873 /* Print out ASCII data */
874 if ((address & address_mask) == address) {
875 fprintf(stderr, " %s\n", ASCII_buffer);
876 if (io_config.echo_mode == (INT32) TRUE)
877 fprintf(io_config.echo_file, " %s\n", ASCII_buffer);
881 /* Print address in margin */
882 if (((address & address_mask) == address) &&
883 (address != last_print_address)) {
884 result = print_addr_29k(memory_space, address);
889 /* Do leading and trailing spaces (if necessary) */
890 if ((address < start_address) ||
891 (address >= end_address)) {
892 fprintf(stderr, " ");
893 if (io_config.echo_mode == (INT32) TRUE)
894 fprintf(io_config.echo_file, " ");
895 result = dump_ASCII(ASCII_buffer, ASCII_index,
896 (BYTE *) NULL, sizeof(BYTE));
897 ASCII_index = ASCII_index + sizeof(BYTE);
898 address = address + sizeof(BYTE);
901 /* Print out hex data */
902 if ((address >= start_address) &&
903 (address < end_address)) {
905 result = get_data((BYTE *)&data_byte,
906 &read_buffer[byte_count],
911 fprintf(stderr, "%02x ", data_byte);
912 if (io_config.echo_mode == (INT32) TRUE)
913 fprintf(io_config.echo_file, "%02x ", data_byte);
915 /* Build ASCII srting */
916 result = dump_ASCII(ASCII_buffer,
918 &read_buffer[byte_count],
920 ASCII_index = ASCII_index + sizeof(BYTE);
922 address = address + sizeof(BYTE);
924 byte_count = byte_count + sizeof(BYTE);
930 fprintf(stderr, "\n");
931 if (io_config.echo_mode == (INT32) TRUE)
932 fprintf(io_config.echo_file, "\n");
935 } /* end dump_mem_byte() */
940 ** This function is used to dump registers as bytes.
944 dump_reg_byte(memory_space, read_address, bytes_returned, read_buffer)
947 INT32 bytes_returned;
952 ADDR32 start_address;
954 ADDR32 last_print_address;
958 struct addr_29k_t addr_29k;
960 char ASCII_buffer[20];
964 ASCII_buffer[0] = '\0';
966 address_mask = 0xfffffffc;
967 start_address = read_address;
968 end_address = read_address + (bytes_returned / 4);
969 last_print_address = (end_address + 0x3) & address_mask;
970 address = start_address & address_mask;
973 ** Loop while data available
976 while (address <= last_print_address) {
978 /* Exit if address not valid */
979 addr_29k.memory_space = memory_space;
980 addr_29k.address = address;
981 result = addr_29k_ok(&addr_29k);
983 fprintf(stderr, "\n\n");
984 if (io_config.echo_mode == (INT32) TRUE)
985 fprintf(io_config.echo_file, "\n\n");
989 /* Print out ASCII data */
990 if ((address & address_mask) == address) {
991 fprintf(stderr, " %s\n", ASCII_buffer);
992 if (io_config.echo_mode == (INT32) TRUE)
993 fprintf(io_config.echo_file, " %s\n", ASCII_buffer);
997 /* Print address in margin */
998 if (((address & address_mask) == address) &&
999 (address != last_print_address)) {
1000 result = print_addr_29k(memory_space, address);
1005 /* Do leading and trailing spaces (if necessary) */
1006 if ((address < start_address) ||
1007 (address >= end_address)) {
1008 fprintf(stderr, " ");
1009 if (io_config.echo_mode == (INT32) TRUE)
1010 fprintf(io_config.echo_file, " ");
1011 result = dump_ASCII(ASCII_buffer, ASCII_index,
1012 (BYTE *) NULL, sizeof(INT32));
1013 ASCII_index = ASCII_index + sizeof(INT32);
1015 address = address + 1;
1018 /* Print out hex data */
1019 if ((address >= start_address) &&
1020 (address < end_address)) {
1022 result = get_data((BYTE *)&data_word,
1023 &read_buffer[byte_count],
1028 if (io_config.echo_mode == (INT32) TRUE)
1029 fprintf(io_config.echo_file, "%02lx %02lx %02lx %02lx ",
1030 ((data_word >> 24) & 0xff),
1031 ((data_word >> 16) & 0xff),
1032 ((data_word >> 8) & 0xff),
1033 (data_word & 0xff));
1034 fprintf(stderr, "%02lx %02lx %02lx %02lx ",
1035 ((data_word >> 24) & 0xff),
1036 ((data_word >> 16) & 0xff),
1037 ((data_word >> 8) & 0xff),
1038 (data_word & 0xff));
1040 /* Build ASCII srting */
1041 result = dump_ASCII(ASCII_buffer,
1043 &read_buffer[byte_count],
1045 ASCII_index = ASCII_index + sizeof(INT32);
1047 address = address + 1;
1049 byte_count = byte_count + sizeof(INT32);
1055 fprintf(stderr, "\n");
1056 if (io_config.echo_mode == (INT32) TRUE)
1057 fprintf(io_config.echo_file, "\n");
1060 } /* end dump_reg_byte() */
1065 ** This function is used to dump memory as floats.
1069 dump_mem_float(memory_space, read_address, bytes_returned, read_buffer)
1071 ADDR32 read_address;
1072 INT32 bytes_returned;
1077 ADDR32 start_address;
1079 ADDR32 last_print_address;
1080 ADDR32 address_mask;
1083 struct addr_29k_t addr_29k;
1087 address_mask = 0xfffffff0;
1088 start_address = read_address;
1089 end_address = read_address + bytes_returned;
1090 last_print_address = (end_address + 0xf) & address_mask;
1091 address = start_address & address_mask;
1094 ** Loop while data available
1097 while (address <= last_print_address) {
1099 /* Exit if address not valid */
1100 addr_29k.memory_space = memory_space;
1101 addr_29k.address = address;
1102 result = addr_29k_ok(&addr_29k);
1104 fprintf(stderr, "\n\n");
1105 if (io_config.echo_mode == (INT32) TRUE)
1106 fprintf(io_config.echo_file, "\n\n");
1110 /* Print address in margin */
1111 if (((address & address_mask) == address) &&
1112 (address != last_print_address)) {
1113 fprintf(stderr, "\n");
1114 if (io_config.echo_mode == (INT32) TRUE)
1115 fprintf(io_config.echo_file, "\n");
1116 result = print_addr_29k(memory_space, address);
1121 /* Do leading and trailing spaces (if necessary) */
1122 if ((address < start_address) ||
1123 (address >= end_address)) {
1124 fprintf(stderr, " ");
1125 if (io_config.echo_mode == (INT32) TRUE)
1126 fprintf(io_config.echo_file, " ");
1127 address = address + sizeof(float);
1130 /* Print out hex data */
1131 if ((address >= start_address) &&
1132 (address < end_address)) {
1134 result = get_data((BYTE *)&data_float,
1135 &read_buffer[byte_count],
1140 fprintf(stderr, "%+1.6e ", (double) data_float);
1141 if (io_config.echo_mode == (INT32) TRUE)
1142 fprintf(io_config.echo_file, "%+1.6e ", (double) data_float);
1144 address = address + sizeof(float);
1146 byte_count = byte_count + sizeof(float);
1152 fprintf(stderr, "\n");
1153 if (io_config.echo_mode == (INT32) TRUE)
1154 fprintf(io_config.echo_file, "\n");
1157 } /* end dump_mem_float() */
1163 ** This function is used to dump registers as floats.
1167 dump_reg_float(memory_space, read_address, bytes_returned, read_buffer)
1169 ADDR32 read_address;
1170 INT32 bytes_returned;
1175 ADDR32 start_address;
1177 ADDR32 last_print_address;
1178 ADDR32 address_mask;
1181 struct addr_29k_t addr_29k;
1185 address_mask = 0xfffffffc;
1186 start_address = read_address;
1187 end_address = read_address + (bytes_returned / 4);
1188 last_print_address = (end_address + 0x3) & address_mask;
1189 address = start_address & address_mask;
1192 ** Loop while data available
1195 while (address <= last_print_address) {
1197 /* Exit if address not valid */
1198 addr_29k.memory_space = memory_space;
1199 addr_29k.address = address;
1200 result = addr_29k_ok(&addr_29k);
1202 fprintf(stderr, "\n\n");
1203 if (io_config.echo_mode == (INT32) TRUE)
1204 fprintf(io_config.echo_file, "\n\n");
1208 /* Print address in margin */
1209 if (((address & address_mask) == address) &&
1210 (address != last_print_address)) {
1211 fprintf(stderr, "\n");
1212 if (io_config.echo_mode == (INT32) TRUE)
1213 fprintf(io_config.echo_file, "\n");
1214 result = print_addr_29k(memory_space, address);
1219 /* Do leading and trailing spaces (if necessary) */
1220 if ((address < start_address) ||
1221 (address >= end_address)) {
1222 fprintf(stderr, " ");
1223 if (io_config.echo_mode == (INT32) TRUE)
1224 fprintf(io_config.echo_file, " ");
1225 address = address + 1;
1228 /* Print out hex data */
1229 if ((address >= start_address) &&
1230 (address < end_address)) {
1232 result = get_data((BYTE *)&data_float,
1233 &read_buffer[byte_count],
1238 fprintf(stderr, "%+1.6e ", (double) data_float);
1239 if (io_config.echo_mode == (INT32) TRUE)
1240 fprintf(io_config.echo_file, "%+1.6e ", (double) data_float);
1242 address = address + 1;
1244 byte_count = byte_count + sizeof(float);
1250 fprintf(stderr, "\n");
1251 if (io_config.echo_mode == (INT32) TRUE)
1252 fprintf(io_config.echo_file, "\n");
1255 } /* end dump_reg_float() */
1261 ** This function is used to dump memory as doubles.
1265 dump_mem_double(memory_space, read_address, bytes_returned, read_buffer)
1267 ADDR32 read_address;
1268 INT32 bytes_returned;
1273 ADDR32 start_address;
1275 ADDR32 last_print_address;
1276 ADDR32 address_mask;
1279 struct addr_29k_t addr_29k;
1283 address_mask = 0xfffffff0;
1284 start_address = read_address;
1285 end_address = read_address + bytes_returned;
1286 last_print_address = (end_address + 0xf) & address_mask;
1287 address = start_address & address_mask;
1290 ** Loop while data available
1293 while (address <= last_print_address) {
1295 /* Exit if address not valid */
1296 addr_29k.memory_space = memory_space;
1297 addr_29k.address = address;
1298 result = addr_29k_ok(&addr_29k);
1300 fprintf(stderr, "\n\n");
1301 if (io_config.echo_mode == (INT32) TRUE)
1302 fprintf(io_config.echo_file, "\n\n");
1306 /* Print address in margin */
1307 if (((address & address_mask) == address) &&
1308 (address != last_print_address)) {
1309 fprintf(stderr, "\n");
1310 if (io_config.echo_mode == (INT32) TRUE)
1311 fprintf(io_config.echo_file, "\n");
1312 result = print_addr_29k(memory_space, address);
1317 /* Do leading and trailing spaces (if necessary) */
1318 if ((address < start_address) ||
1319 (address >= end_address)) {
1320 fprintf(stderr, " ");
1321 if (io_config.echo_mode == (INT32) TRUE)
1322 fprintf(io_config.echo_file, " ");
1323 address = address + sizeof(double);
1326 /* Print out hex data */
1327 if ((address >= start_address) &&
1328 (address < end_address)) {
1330 result = get_data((BYTE *)&data_double,
1331 &read_buffer[byte_count],
1336 fprintf(stderr, "%+1.15e ", data_double);
1337 if (io_config.echo_mode == (INT32) TRUE)
1338 fprintf(io_config.echo_file, "%+1.15e ", data_double);
1340 address = address + sizeof(double);
1342 byte_count = byte_count + sizeof(double);
1348 fprintf(stderr, "\n");
1349 if (io_config.echo_mode == (INT32) TRUE)
1350 fprintf(io_config.echo_file, "\n");
1353 } /* end dump_mem_double() */
1359 ** This function is used to dump registers as doubles.
1363 dump_reg_double(memory_space, read_address, bytes_returned, read_buffer)
1365 ADDR32 read_address;
1366 INT32 bytes_returned;
1371 ADDR32 start_address;
1373 ADDR32 last_print_address;
1374 ADDR32 address_mask;
1377 struct addr_29k_t addr_29k;
1381 address_mask = 0xfffffffc;
1382 start_address = read_address;
1383 end_address = read_address + (bytes_returned / 4);
1384 last_print_address = (end_address + 0x3) & address_mask;
1385 address = start_address & address_mask;
1388 ** Loop while data available
1391 while (address <= last_print_address) {
1393 /* Exit if address not valid */
1394 addr_29k.memory_space = memory_space;
1395 addr_29k.address = address;
1396 result = addr_29k_ok(&addr_29k);
1398 fprintf(stderr, "\n\n");
1399 if (io_config.echo_mode == (INT32) TRUE)
1400 fprintf(io_config.echo_file, "\n\n");
1404 /* Print address in margin */
1405 if (((address & address_mask) == address) &&
1406 (address != last_print_address)) {
1407 fprintf(stderr, "\n");
1408 if (io_config.echo_mode == (INT32) TRUE)
1409 fprintf(io_config.echo_file, "\n");
1410 result = print_addr_29k(memory_space, address);
1415 /* Do leading and trailing spaces (if necessary) */
1416 if ((address < start_address) ||
1417 (address >= end_address)) {
1418 fprintf(stderr, " ");
1419 if (io_config.echo_mode == (INT32) TRUE)
1420 fprintf(io_config.echo_file, " ");
1421 address = address + 2;
1424 /* Print out hex data */
1425 if ((address >= start_address) &&
1426 (address < end_address)) {
1428 result = get_data((BYTE *)&data_double,
1429 &read_buffer[byte_count],
1434 fprintf(stderr, "%+1.15e ", data_double);
1435 if (io_config.echo_mode == (INT32) TRUE)
1436 fprintf(io_config.echo_file, "%+1.15e ", data_double);
1438 address = address + (sizeof(double) / sizeof(INT32));
1440 byte_count = byte_count + sizeof(double);
1446 fprintf(stderr, "\n");
1447 if (io_config.echo_mode == (INT32) TRUE)
1448 fprintf(io_config.echo_file, "\n");
1451 } /* end dump_reg_double() */
1454 ** This function fills in a buffer with a character
1455 ** representation of the dumped data.
1459 dump_ASCII(buffer, index, data, size)
1468 for (i=0; i<size; i=i+1)
1470 buffer[index+i] = ' ';
1472 if (isprint(data[i]))
1473 buffer[index+i] = data[i];
1475 buffer[index+i] = '.';
1477 buffer[index+i] = '\0'; /* Null terminate */
1481 } /* end dump_ASCII() */