source: trunk/INCLUDE/ASM.INC@ 47

Last change on this file since 47 was 46, checked in by Ben Rietbroek, 12 years ago

Various Changes [2012-04-14]

WARNING!!

All commits upto and including the commit of [2012-05-13] contain
a severe bug!! Building from these sources and then disabling
the 'force LBA' feature while also using the drive-letter feature or
editing the label can DESTROY THE MBR on ALL ATTACHED DISKS!!
DO NOT DISABLE 'FORCE LBA USAGE' WHEN BUILT FROM THE THESE COMMITS!!

Changes

o Added BLDLEVEL support
o Enhanced Master Make
o Sanitized sources
o Support for Wasm and Masm6 (experimental)
o Renamed MBR_PROT.ASM to MBR-PROT.ASM
o Merged bitfield code Into Installer
o First steps for cross platform Installer
o More...

File size: 7.1 KB
Line 
1; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
2;
3; This file is part of AiR-BOOT
4;
5; AiR-BOOT is free software: you can redistribute it and/or modify it under
6; the terms of the GNU General Public License as published by the Free
7; Software Foundation, either version 3 of the License, or (at your option)
8; any later version.
9;
10; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
11; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
12; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13; details.
14;
15; You should have received a copy of the GNU General Public License along with
16; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
17;
18; Some Standard macros to make life easier with ALP and other assemblers :D
19
20MPush Macro reglist
21 irp reg,<reglist>
22 push reg
23 EndM
24EndM
25
26MPop Macro reglist
27 irp reg,<reglist>
28 pop reg
29 EndM
30EndM
31
32
33; Rousseau:
34; My editor (Geany) keeps auto-completing 'call' to 'callfar' because
35; of this definition. Since it's not used anywhere I disabled it.
36;~ callfar Macro destination
37 ;~ push cs
38 ;~ call &destination
39;~ EndM
40
41
42;
43; OLD OVERLAP CHECKER, DOES NOT WORK WELL WITH JWASM.
44;
45; NOTE: Overlapchecking in JWasm is not as reliable as in Tasm.
46; Because it's a single pass assembler, the current location can be
47; incorrect. Tasm with multiple passes works correct.
48; FIXME: Get JWasm and Tasm use some common ECHO/%OUT method.
49; (Tasm only pases first word of non-quoted string to a macro)
50check_overlap MACRO loc
51
52 ; Exit macro immediately if no overlap.
53 ; We don't want to assign values to z_last_... if there is no
54 ; overlap because they would then hold the values the last time this
55 ; macro was called and not those of the last overlap.
56 IF (loc - $) LE 0
57 ;~ IF ($ - loc) GE 0
58 EXITM
59 ENDIF
60
61 ; Calculate the overlap.
62 z_last_overlap_size = (loc - $)
63 z_last_overlap_location = loc - z_last_overlap_size
64
65 IFDEF JWASM
66 ; Output message.
67 ECHO
68 ECHO ** ERROR: LOCATION OVERLAP DETECTED [JWASM] ! **
69 ECHO . THIS IS MOST LIKELY CAUSED BY CODE / DATA
70 ECHO . EXPANSION TOWARDS AN 'ORG' DIRECTIVE.
71 ECHO . LOOK AT 'z_last_overlap_location' TO SEE WHERE.
72 ECHO . LOOK AT 'z_last_overlap_size' TO SEE SIZE.
73 ECHO . FORCING ERROR...
74 ECHO
75 ENDIF
76 IFDEF TASM
77 IF2
78 ; Output message (only on pass2).
79 %OUT
80 %OUT ** ERROR: LOCATION OVERLAP DETECTED [TASM] ! **
81 %OUT . THIS IS MOST LIKELY CAUSED BY CODE / DATA
82 %OUT . EXPANSION TOWARDS AN 'ORG' DIRECTIVE.
83 %OUT . LOOK AT 'z_last_overlap_location' TO WHERE.
84 %OUT . LOOK AT 'z_last_overlap_size' TO SEE SIZE.
85 %OUT . FORCING ERROR...
86 %OUT
87 ENDIF
88 ENDIF
89
90 ; Terminate assembly by forcing an error.
91 .ERR
92ENDM
93
94
95;
96; A normal ORG directive resets the location counter where code and data is
97; going to be emitted. If the location counter is reset back to a point
98; where code or data already has been emitted, this will be overwritten
99; without warning.
100; This macro does a check for this condition and aborts if it exists.
101; If there is space between the new location and the last emitted code or data
102; it will be filled with a filler-value defined in this macro..
103;
104; There are differences between assemblers on when and how labels and values
105; are evaluated. Since JWasm is a single-pass assembler, some expressions
106; do not work that do work in multi-pass Tasm.
107; That's why the actual check for overlap is done by db getting a negative
108; value if an overlap occured.
109; Don't change the (after - before) expression to a pre-calculated label
110; because that won't work and will break this macro.
111;
112ORIGIN MACRO loc
113 ;~ IFDEF JWASM
114 ;~ db (@F - $) dup('X')
115 ;~ ORG loc
116 ;~ @@:
117 ;~ ENDIF
118
119 ; Use this value to fill the gap between the new origin and the last
120 ; emitted code or data.
121 fillchar = '0'
122
123 ; Mark the location of the last emitted code or data.
124 z_&loc&_1before:
125
126 ; JWasm can do db 0 dup (0).
127 ; Using db dup() causes JWasm to recognize the after label so that
128 ; overlap calculations are correct.
129 IFDEF JWASM
130 db (z_&loc&_2after - z_&loc&_1before) dup(fillchar)
131 ENDIF
132
133 ; Tasm cannot do db 0 dup(0), so we exclude that condition.
134 ; Overlap checking could be done differently in Tasm but to keep things
135 ; easy the JWasm method above is used.
136 IFDEF TASM
137 IF (z_&loc&_2after - z_&loc&_1before) NE 0
138 db (z_&loc&_2after - z_&loc&_1before) dup(fillchar)
139 ENDIF
140 ENDIF
141
142 ; Masm can also do db 0 dup (0), and it does calculate correctly
143 ; but cannot find the after label.
144 ; Same issue as with JWasm but the db construct does not solve it for masm.
145 ; The label-values show-up to be correct in the listing though.
146 ; Currently overlap-checking is disabled when assembling with Masm !
147 ; FIXME: Find a solution for Masm.
148 IFDEF MASM
149 ;~ db (z_&loc&_2after - z_&loc&_1before) dup(fillchar)
150 ECHO ** Warning: Overlap Check on: loc not performed !
151 ENDIF
152
153 ; Wasm can also do db 0 dup (0), but it complains about brackets or so.
154 ; Seems to be some syntax issue.
155 ; It cannot generate a list-file so values cannot be checked.
156 ; It does not even support ECHO so no warning can be given.
157 ; So overlap-checking is disabled when assembling with Wasm !
158 ; FIXME: Find a solution for Wasm.
159 IFDEF WASM
160 ; NOT EVEN ECHO IS SUPPORTED !
161 ;~ db (z_&loc&_2after - z_&loc&_1before) dup(fillchar)
162 ENDIF
163
164 ; Set the new origin.
165 ORG loc
166
167 ; Mark the new location.
168 z_&loc&_2after:
169
170 ; Calculate the gap.
171 z_&loc&_3gap = z_&loc&_2after - z_&loc&_1before
172
173 ;
174 ; Note that the variables are prefixed with z_ so they appear
175 ; at the end of the list-file.
176 ;
177ENDM
178
179
180
181; Shortcuts for pointer-types
182bptr equ byte ptr
183wptr equ word ptr
184dptr equ dword ptr
185qptr equ qword ptr
186tptr equ tbyte ptr
187
188
189sector_size equ 512 ; Normal size of a sector.
190image_size_60secs equ 7800h ; Size of the pre v1.07 image.
191image_size_62secs equ 7c00h ; Size of the post v1.06 image.
192
193;image_size equ image_size_60secs
194image_size equ image_size_62secs
195
196; Image size in sectors
197sector_count equ image_size / sector_size
198
199IF image_size EQ image_size_60secs
200 ; Maximum number of partitions supported in pre v1.07.
201 partition_count equ 30
202ELSE
203 ; Maximum number of partitions supported in post v1.06.
204 partition_count equ 45
205ENDIF
Note: See TracBrowser for help on using the repository browser.