Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1126 | savelij | 1 | ifndef __st6instrinc |
2 | __st6instrinc equ 1 |
||
3 | |||
4 | ;**************************************************************************** |
||
5 | ;* * |
||
6 | ;* AS 1.42 - File INSTR.INC * |
||
7 | ;* * |
||
8 | ;* contains macros for some commonly missing instructions on ST6 * |
||
9 | ;* * |
||
10 | ;**************************************************************************** |
||
11 | |||
12 | ; Add/Subtract with Carry: first operand must be A (accumulator) |
||
13 | |||
14 | adc macro dst,src |
||
15 | jrnc NoCarry |
||
16 | inc dst |
||
17 | NoCarry: add dst,src ; Rest normal addieren |
||
18 | endm |
||
19 | |||
20 | sbc macro dst,src |
||
21 | jrnc NoCarry |
||
22 | dec dst |
||
23 | NoCarry: sub dst,src |
||
24 | endm |
||
25 | |||
26 | ; OR operator: |
||
27 | ; uses De Morgan's rule: A OR B = /((/A) AND (/B)) |
||
28 | ; uses W register |
||
29 | ; dst must be A (accumulator) |
||
30 | |||
31 | or macro dst,src |
||
32 | com dst |
||
33 | ld w,dst |
||
34 | ld dst,src |
||
35 | com dst |
||
36 | and dst,w |
||
37 | com dst |
||
38 | endm |
||
39 | |||
40 | ; XOR Operator: |
||
41 | ; uses the principle of four NAND gates, i.e. does not have to use the OR macro |
||
42 | ; uses V and W register |
||
43 | ; dst must be A (accumulator) |
||
44 | |||
45 | xor macro dst,src |
||
46 | ld v,dst ; Op1 retten |
||
47 | and dst,src ; Hilfsergebnis A NAND B bilden |
||
48 | com dst |
||
49 | ld w,dst ; in W retten |
||
50 | ld dst,v ; Op1 nochmal holen |
||
51 | and dst,w ; 1. Teilergebnis A NAND W bilden |
||
52 | com dst |
||
53 | ld v,dst ; in V retten |
||
54 | ld dst,src ; 2. Teilergebnis B NAND W bilden |
||
55 | and dst,w |
||
56 | com dst |
||
57 | and dst,v |
||
58 | com dst |
||
59 | endif |
||
60 | endm |
||
61 | |||
62 | ; rotate right with carry |
||
63 | ; fairly brute force, I did not have any better idea... |
||
64 | ; dst must be A (accumulator) |
||
65 | |||
66 | rrc macro dst |
||
67 | rept 7 |
||
68 | rlc dst |
||
69 | endm |
||
70 | endm |
||
71 | |||
72 | ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
||
73 | ; For those missing the ROMWIN statement: |
||
74 | |||
75 | romwin macro adr |
||
76 | assume rombase:adr>>6 |
||
77 | endm |
||
78 | |||
79 | endif ; __st6instrinc |