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