Annotation of gforth/arch/misc/asm.fs, revision 1.1
1.1 ! pazsan 1: \ PIE MISC assembler
! 2:
! 3: Vocabulary assembler
! 4: also assembler also definitions forth
! 5:
! 6: \ sources
! 7:
! 8: $0 Constant PC $1 Constant PC+2
! 9: $2 Constant PC+4 $3 Constant PC+6
! 10:
! 11: $8 Constant ACCU $9 Constant SF
! 12: $A Constant ZF $C Constant CF
! 13:
! 14: \ destinations
! 15:
! 16: $0 Constant JMP $1 Constant JS
! 17: $2 Constant JZ $4 Constant JC
! 18:
! 19: ( $8 Constant ACCU ) $9 Constant SUB
! 20: $A Constant SUBR $B Constant ADD
! 21: $C Constant XOR $D Constant OR
! 22: $E Constant AND $F Constant SHR
! 23:
! 24: $FFFC Constant tx
! 25: \ $FFF0 Constant tx
! 26:
! 27: : end-label previous ;
! 28:
! 29: Create marks $10 cells allot
! 30:
! 31: : ahere s" here" evaluate 2/ ;
! 32:
! 33: : m ( n -- ) cells marks + ahere 2* swap ! 0 ;
! 34: : r ( n -- ) cells marks + @ ahere swap s" !" evaluate 0 ;
! 35:
! 36: \ intel hex dump
! 37:
! 38: : 0.r ( n1 n2 -- ) 0 swap <# 0 ?DO # LOOP #> type ;
! 39:
! 40: : tohex ( dest addr u -- ) base @ >r hex
! 41: ." :" swap >r >r
! 42: r@ dup 2 0.r over 4 0.r ." 00"
! 43: over 8 rshift + +
! 44: r> r> swap bounds ?DO I ( 1 xor ) c@ dup 2 0.r + LOOP
! 45: negate $FF and 2 0.r r> base ! ;
! 46:
! 47: : 2hex ( dest addr u -- )
! 48: BEGIN dup WHILE
! 49: >r 2dup r@ $10 min tohex cr
! 50: r> $10 /string 0 max rot $10 + -rot
! 51: REPEAT drop 2drop ;
! 52:
! 53: : sym base @ >r hex
! 54: cr ." sym:s/PC=" ahere 4 0.r ." /" bl word count type ." /g" cr
! 55: r> base ! ;
! 56:
! 57: : label ahere Constant ;
! 58:
! 59: also forth definitions
! 60:
! 61: : label also assembler label ;
! 62:
! 63: : (code) also assembler ;
! 64: : (end-code) previous ;
! 65:
! 66: previous previous previous
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>