Annotation of gforth/arch/misc/asm.fs, revision 1.8

1.1       pazsan      1: \ PIE MISC assembler
                      2: 
1.7       anton       3: \ Copyright (C) 1998,2000,2003,2004 Free Software Foundation, Inc.
1.6       pazsan      4: 
                      5: \ This file is part of Gforth.
                      6: 
                      7: \ Gforth is free software; you can redistribute it and/or
                      8: \ modify it under the terms of the GNU General Public License
1.8     ! anton       9: \ as published by the Free Software Foundation, either version 3
1.6       pazsan     10: \ of the License, or (at your option) any later version.
                     11: 
                     12: \ This program is distributed in the hope that it will be useful,
                     13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
                     14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     15: \ GNU General Public License for more details.
                     16: 
                     17: \ You should have received a copy of the GNU General Public License
1.8     ! anton      18: \ along with this program. If not, see http://www.gnu.org/licenses/.
1.6       pazsan     19: 
1.1       pazsan     20: Vocabulary assembler
                     21: also assembler also definitions forth
1.4       jwilke     22: \ [IFUNDEF] cross
                     23: \ : X ;
                     24: \ [THEN]
1.1       pazsan     25: 
                     26: \ sources
                     27: 
                     28: $0 Constant PC         $1 Constant PC+2
                     29: $2 Constant PC+4       $3 Constant PC+6
                     30: 
                     31: $8 Constant ACCU       $9 Constant SF
                     32: $A Constant ZF         $C Constant CF
                     33: 
                     34: \ destinations
                     35: 
                     36: $0 Constant JMP                $1 Constant JS
                     37: $2 Constant JZ         $4 Constant JC
                     38: 
1.3       pazsan     39: $7 Constant *ACCU
1.1       pazsan     40: ( $8 Constant ACCU )   $9 Constant SUB
1.2       pazsan     41: ( $A Constant SUBR )   $B Constant ADD
1.1       pazsan     42: $C Constant XOR                $D Constant OR
                     43: $E Constant AND                $F Constant SHR
                     44: 
1.4       jwilke     45: $FFFC Constant txd
                     46: $FFFF Constant rx?
                     47: $FFFE Constant rxd
1.1       pazsan     48: \ $FFF0 Constant tx
                     49: 
                     50: : end-label previous ;
                     51: 
                     52: Create marks $10 cells allot
                     53: 
1.4       jwilke     54: : ahere X here 2/ ;
1.1       pazsan     55: 
                     56: : m ( n -- ) cells marks + ahere 2* swap ! 0 ;
                     57: : r ( n -- ) cells marks + @ ahere swap s" !" evaluate 0 ;
                     58: 
                     59: \ intel hex dump
                     60: 
                     61: : 0.r ( n1 n2 -- ) 0 swap <# 0 ?DO # LOOP #> type ;
                     62: 
                     63: : tohex ( dest addr u -- )  base @ >r hex
                     64:   ." :" swap >r >r
                     65:   r@ dup 2 0.r  over 4 0.r  ." 00"
                     66:   over 8 rshift + +
                     67:   r> r> swap bounds ?DO  I ( 1 xor ) c@ dup 2 0.r +  LOOP
                     68:   negate $FF and 2 0.r  r> base ! ;
                     69: 
                     70: : 2hex ( dest addr u -- )
                     71:   BEGIN  dup WHILE
                     72:          >r 2dup r@ $10 min tohex cr
                     73:          r> $10 /string 0 max rot $10 + -rot
                     74:   REPEAT  drop 2drop ;
                     75: 
1.4       jwilke     76: \ : sym 
                     77: \    base @ >r hex
                     78: \    cr ." sym:s/PC=" ahere 4 0.r ." /" bl word count type ." /g" cr
                     79: \    r> base ! ;
                     80: : sym bl word drop ;
                     81: 
                     82: : label 
                     83:   >in @ bl word count X here symentry >in !
                     84:   ahere Constant ;
1.1       pazsan     85: 
1.5       jwilke     86: : code
                     87:   -1 ABORT" Need end-code or end-label before a new code definition" ;
                     88: 
1.1       pazsan     89: also forth definitions
                     90: 
                     91: : label also assembler label ;
                     92: 
                     93: : (code) also assembler ;
                     94: : (end-code) previous ;
                     95: 
                     96: previous previous previous
1.4       jwilke     97: 

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