1 \ @(#) dump_struct.fth 97/12/10 1.1
2 \ Dump contents of structure showing values and member names.
5 \ Copyright 1987 Phil Burk
8 \ MOD: PLB 9/4/88 Print size too.
9 \ MOD: PLB 9/9/88 Print U/S , add ADST
10 \ MOD: PLB 12/6/90 Modified to work with H4th
11 \ 941109 PLB Converted to pforth. Added RP detection.
12 \ 090609 PLB Convert >rel to use->rel and ..! to s!
14 include? task-member.fth member.fth
15 include? task-c_struct c_struct.fth
19 : EMIT-TO-COLUMN ( char col -- )
20 out @ - 0 max 80 min 0
26 : STACK.NFAS ( fencenfa topnfa -- 0 nfa0 nfa1 ... )
27 \ Fill stack with nfas of words until fence hit.
29 0 r> ( set terminator )
30 BEGIN ( -- 0 n0 n1 ... top )
33 \ dup n>link @ \ JForth
39 : DST.DUMP.TYPE ( +-size -- , dump data type, 941109)
54 : DUMP.MEMBER ( addr member-pfa -- , dump member of structure)
55 ob.stats ( -- addr offset size )
56 >r + r> ( -- addr' size )
57 dup ABS 4 > ( -- addr' size flag )
58 IF cr 2dup swap . . ABS dump
59 ELSE tuck @bytes 10 .r ( -- size )
60 3 spaces dst.dump.type
65 : DUMP.STRUCT ( addr-data addr-structure -- )
66 >newline swap >r ( -- as , save addr-data for dumping )
67 \ dup cell+ @ over + \ JForth
68 dup code> >name swap cell+ @ over + \ HForth
69 stack.nfas ( fill stack with nfas of members )
72 WHILE ( continue until non-zero )
73 dup name> >body r@ swap dump.member
74 bl 18 emit-to-column id. cr
79 : DST ( addr <name> -- , dump contents of structure )
82 IF [compile] literal compile dump.struct
87 : ADST ( absolute_address -- , dump structure )
88 use->rel [compile] dst \ mod 090609
91 \ For Testing Purposes
109 $ 12345678 afoo s! along1
110 $ -665 afoo s! ashort1
113 -234 afoo .. agoo s! goo_height