source: trunk/include/asm.inc@ 109

Last change on this file since 109 was 70, checked in by Ben Rietbroek, 9 years ago

Centralized the version information [v1.1.1-testing]

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File size: 7.8 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 IFDEF AUX_DEBUG
122 fillchar = '#'
123 ELSE
124 fillchar = 0
125 ENDIF
126
127 ; Mark the location of the last emitted code or data.
128 z_&loc&_1before:
129
130 ; JWasm can do db 0 dup (0).
131 ; Using db dup() causes JWasm to recognize the after label so that
132 ; overlap calculations are correct.
133 IFDEF JWASM
134 db (z_&loc&_2after - z_&loc&_1before) dup(fillchar)
135 ENDIF
136
137 ; Tasm cannot do db 0 dup(0), so we exclude that condition.
138 ; Overlap checking could be done differently in Tasm but to keep things
139 ; easy the JWasm method above is used.
140 IFDEF TASM
141 IF (z_&loc&_2after - z_&loc&_1before) NE 0
142 db (z_&loc&_2after - z_&loc&_1before) dup(fillchar)
143 ENDIF
144 ENDIF
145
146 ; Masm can also do db 0 dup (0), and it does calculate correctly
147 ; but cannot find the after label.
148 ; Same issue as with JWasm but the db construct does not solve it for Masm.
149 ; The label-values show-up to be correct in the listing though.
150 ; Currently overlap-checking is disabled when assembling with Masm !
151 ; FIXME: Find a solution for Masm.
152 IFDEF MASM
153 ;~ db (z_&loc&_2after - z_&loc&_1before) dup(fillchar)
154 ECHO ** Warning: Overlap Check on: loc not performed !
155 ENDIF
156
157 ; Wasm can also do db 0 dup (0), but it complains about brackets or so.
158 ; Seems to be some syntax issue.
159 ; It cannot generate a list-file so values cannot be checked.
160 ; It does not even support ECHO so no warning can be given.
161 ; So overlap-checking is disabled when assembling with Wasm !
162 ; FIXME: Find a solution for Wasm.
163 IFDEF WASM
164 ; NOT EVEN ECHO IS SUPPORTED !
165 ;~ db (z_&loc&_2after - z_&loc&_1before) dup(fillchar)
166 ENDIF
167
168 ; Set the new origin.
169 ORG loc
170
171 ; Mark the new location.
172 z_&loc&_2after:
173
174 ; Calculate the gap.
175 z_&loc&_3gap = z_&loc&_2after - z_&loc&_1before
176
177 ;
178 ; Note that the variables are prefixed with z_ so they appear
179 ; at the end of the list-file.
180 ;
181ENDM
182
183
184;
185; This macro inserts the AiR-BOOT signature at the place where it is invoked.
186;
187InsertAirbootSignature MACRO lang
188 db 'AiRBOOT'
189 dw AB_SIG_DATE
190 dw AB_SIG_YEAR
191 dw AB_SIG_VERSION
192 ; Wasm can only process the reference to 'lang' in pass 2 because it comes
193 ; from an included file which it has not processed yet at pass 1.
194 IFDEF WASM
195 IF2
196 db lang
197 ENDIF
198 ; The other assemblers process 'lang' correctly in pass 1.
199 ELSE
200 db lang
201 ENDIF
202ENDM
203
204
205; Shortcuts for pointer-types
206bptr equ byte ptr
207wptr equ word ptr
208dptr equ dword ptr
209qptr equ qword ptr
210tptr equ tbyte ptr
211
212
213sector_size equ 512 ; Normal size of a sector.
214image_size_60secs equ 7800h ; Size of the pre v1.07 image.
215image_size_62secs equ 7c00h ; Size of the post v1.06 image.
216
217;image_size equ image_size_60secs
218image_size equ image_size_62secs
219
220; Image size in sectors
221sector_count equ image_size / sector_size
222
223IF image_size EQ image_size_60secs
224 ; Maximum number of partitions supported in pre v1.07.
225 max_partitions equ 30
226ELSE
227 ; Maximum number of partitions supported in post v1.06.
228 max_partitions equ 45
229ENDIF
Note: See TracBrowser for help on using the repository browser.