Imported Upstream version 2.9.0
[debian/cc1111] / as / mcs51 / readme.390
1 DS80C390 flat mode support
2
3 2/4/2000 Kevin Vigor (e-mail: kevin at vigor.nu)
4
5 I have hacked the 8051 assembler to support the 24 bit flat address mode of
6 the DS80C390 processor. This mode allows the chip to directly address up to
7 4 Meg of RAM. Details can be found at Dallas' web site: www.dalsemi.com.
8
9 1: Assembler changes.
10
11 24 bit mode is entered via a new assembler directive, .flat24. This directive
12 takes a mandatory argument, which is either the string "on" or the string
13 "off". ".flat24 on" enables 24-bit mode, and ".flat24 off" puts the assembler
14 into standard 8051 mode.
15
16 Note that any .included files within a ".flat24 on" segment of the code will
17 be compiled in 24-bit mode.
18
19 In 24-bit mode, 8 instructions have altered behavior. Of these, 5 modify
20 the instruction encoding, while 3 differ only in behavior. These
21 instructions are discussed in the DS80C390 User's Guide, but a summary is
22 included here:
23
24 ACALL and AJMP now take a 19 bit offset instead of the 8051's 11 bit offset. 
25 An extra address byte is added to the encoded instruction.
26
27 LCALL and LJMP now take a 24 bit target address instead of the 8051's 16 bit
28 address. An extra address byte is added to the encoded instruction.
29
30 MOV DPTR, #immed now takes a 24 bit immediate value instead of the 8051's 16
31 bit address. An extra data byte is added to the encoded instruction.
32
33 INC DPTR now increments the entire 24 bit DPTR. The encoding is not changed.
34
35 RET and RETI restore the full 24 bit PC from the stack. The encoding is not
36 changed.
37
38 2: Linker changes.
39
40 The linker supports (through a variety of evil hacks) 19 bit ACALL/AJMP
41 relocations and 24 bit LCALL/LJMP/DPTR relocations. These changes should be
42 invisible to the user.
43
44 The linker can now also generated extended linear address records in the
45 Intel hex output format. This is necessary for any areas located above the
46 64K mark. This is enabled by the "-r" linker flag, and is disabled by
47 default (but the linker will throw a warning if an extended address is
48 encountered without the -r flag being enabled).
49
50 Note that for various reasons, areas may still not be larger than 64K.
51 However, they may be located anywhere in the 4 Meg address space via the
52 assembler .org directive (for ABS areas) or the linker "-b" option.
53
54 3: Examples
55
56 Note that this example uses ABS areas to make the layout obvious. This code
57 won't do anything useful at all, but demonstrates the instruction encoding
58 in .flat24 mode vs 8051 mode.
59
60 ; test1.asm
61 .area CODE (ABS)
62 .org 0
63
64 ; SFRs not known to the assembler yet...
65 $TA = 0x00C7
66 $ACON = 0x009D
67
68 ; Set the chip to 24 bit flat mode via the DS "timed access" procedure.
69 mov $TA, #0xAA
70 mov $TA, #0x55
71 mov $ACON, #0x06                ; 10 bit stack & 24 bit flat addressing.
72
73 .flat24 on              ; Enable 24-bit mode. The AM1 bit had better be
74                         ; on...
75
76 mov dptr, #myData       ; Valid on the '390: myData is in the FARDATA
77                         ; area at 0x300001.
78                         ; Generates: 90 30 00 01
79 acall _junkNear         ; Within 11 bit range, but still must generate
80                         ; 19 bit address for '390 flat mode.
81                         ; Generates: 11 04 00                   
82 ajmp _junkFar           ; Within 16 bit range.
83                         ; Generates 01 08 00
84 acall _junkReallyFar    ; Within 19 bit range.
85                         ; Generates 91 00 00
86 lcall _junkReallyReallyFar      ; Within 24 bit range.
87                         ; Generates 12 08 00 00
88
89 ; Set the chip to 8051 mode via the DS "timed access" procedure.
90 mov $TA, #0x0AA
91 mov $TA, #0x055
92 mov $ACON, #0x00        ; 8 bit stack & 16 bit flat addressing.
93
94 .flat24 off             ; Now we're an 8051 again. The AM1 bit had better be
95                         ; off...
96
97 ;mov dptr, #myData      ; Can't do that: myData is too far away.
98 acall _junkNear         ; Within 11 bit range.
99                         ; Generates 91 00
100 ljmp _junkFar           ; Within 16 bit range; can't AJMP, but can LJMP
101                         ; Generates 02 08 00
102 ret
103
104 .area CODE2 (ABS)
105 .org 0x400
106 ; This is within the 11 bit ACALL/AJMP range of the 8051.
107 _junkNear:
108 ret
109
110 .area CODE3 (ABS)
111 .org 0x800
112 ; This is within the 390's 19 bit ACALL/AJMP range, and inside the stock
113 ; 8051's 16 bit LCALL range.
114 _junkFar:
115 ret
116
117 .area CODE4 (ABS)
118 ; This is within the 390's 19 bit ACALL/AJMP range and outside the
119 ; 8051's LCALL range.
120 ; Note that to link an image with an area beyond 64K (like this one),
121 ; the '-r' flag must be provided to the linker, and Intel Hex output format
122 ; must be used.
123 .org 0x40000
124 _junkReallyFar:
125 ret
126
127 .area CODE5 (ABS)
128 ; This is outside anybody's ACALL/AJMP range.
129 .org 0x80000
130 _junkReallyReallyFar:
131 ret
132
133 .area FARDATA (ABS)
134 .org 0x300000
135 ; This is way, way up there.
136 .byte 0x01
137 myData:
138 .byte 0x02
139
140 ; test1.asm ends.
141