Diff for /gforth/asm/numref.fs between versions 1.4 and 1.5

version 1.4, 2000/09/23 15:47:05 version 1.5, 2001/07/10 20:38:01
Line 1 Line 1
 \ refs.fs  \ numref.fs
   
 \ Copyright (C) 1998 Free Software Foundation, Inc.  \ Copyright (C) 1998 Free Software Foundation, Inc.
   
Line 23 Line 23
 This is a generic solution for doing labels (forward and backward  This is a generic solution for doing labels (forward and backward
 references) in an assembler program.  references) in an assembler program.
   
 - Who to use local labels:  How to use local labels
   =======================
   
 Example:  Example:
   
Line 37  End-Label Line 38  End-Label
 "n $:" defines an address reference. "n $" returns the address of the  "n $:" defines an address reference. "n $" returns the address of the
 reference defined with "n $:".  reference defined with "n $:".
   
 - How to embed local labels in your assembler:  
   
 At the moment all references are forward references, meaning,  How to embed local labels in your assembler
 all references are resolved at the end of the definition.  ===========================================
   
   At the moment all references are forward references, meaning all
   references are resolved at the end of the definition.
   
 The Simple Resolver  The Simple Resolver
   -------------------
   
 The only special thing is how a label is resolved. Numref executes  The only special thing is how a label is resolved. Numref does this by
 therefor a resolver-word, example for a two byte opcode with the second  executing a resolver-word. For example, consider a two byte opcode
 byte as branch-offset:  with the second byte as branch-offset. The resolver-word would look
   like this:
   
 : doresovle ( iaddr -- )  : doresolve ( iaddr -- )
   dup ref-addr @ - swap 1+ X c! ;    dup ref-addr @ - swap 1+ X c! ;
   
 iaddr is the address of the instruction with the reference that must  iaddr is the address of the instruction with the reference that must
 be resolved. The destination address of the reference is stored at ref-addr.  be resolved. The destination address of the reference is stored at ref-addr.
   
 The resolver must be registered bye "' doresolve TO std-resolve". This is   The resolver-word must be registered like this:
 not a defered word!  
    "' doresolve TO std-resolver"
   
   This is not a deferred word!
   
 Complex Resolving  Complex Resolving
   -----------------
   
 To support different cpu-instruction with different operand formats it is  To support different cpu-instruction with different operand formats it
 possible to find out the type of opcode bye accessing the targets' memory  is possible to find out the type of opcode by accessing the target's
 in doresolve. This works for very simple processors, e.g. for 6502 it is  memory in doresolve. This works for very simple processors, e.g. for
 very easy to find out whether we have a 2-byte absolute address or a 1-byte  6502 it is very easy to find out whether we have a 2-byte absolute
 relative address.  address or a 1-byte relative address.
   
 If this method is to difficult, it is possible to store additional  If this method is too difficult, it is possible to store additional
 information in the resolve structure.  information in the resolve structure.
   
 When assembling an opcode you should find out whether the address is a  When assembling an opcode you should find out whether the address is a
 reference and then  store the xt of a special  reference and then store the xt of a special resolver word in the
 resolver word in the resolve structure by "ref-resolver !", or store some  resolve structure by "ref-resolver !", or store some additional data
 additional data in the resolve structure by "ref-data !", if one data field  in the resolve structure by "ref-data !", if one data field is not
 is not enough allocate memory and use ref-data as pointer to it.  enough, allocate memory and use ref-data as pointer to it.
   
 - Internal strucutre:  Internal structure
   ==================
   
 There is a heap buffer to store the references.  There is a heap buffer to store the references.  The structure of one
 The structure of one entry is:  entry is:
   
  1 cell         ref-link   1 cell         ref-link
  1 cell         ref-flag        \ mixture of tag-number   1 cell         ref-flag        \ mixture of tag-number
Line 88  The structure of one entry is: Line 98  The structure of one entry is:
                                 \ (start of the instruction)                                  \ (start of the instruction)
  1 cell         ref-data        \ additional information for resolver   1 cell         ref-data        \ additional information for resolver
   
   
 [THEN]  [THEN]
   
 require ./basic.fs  require ./basic.fs

Removed from v.1.4  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>