| 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 |
|
|---|
| 20 | MPush Macro reglist
|
|---|
| 21 | irp reg,<reglist>
|
|---|
| 22 | push reg
|
|---|
| 23 | EndM
|
|---|
| 24 | EndM
|
|---|
| 25 |
|
|---|
| 26 | MPop Macro reglist
|
|---|
| 27 | irp reg,<reglist>
|
|---|
| 28 | pop reg
|
|---|
| 29 | EndM
|
|---|
| 30 | EndM
|
|---|
| 31 |
|
|---|
| 32 | callfar Macro destination
|
|---|
| 33 | push cs
|
|---|
| 34 | call &destination
|
|---|
| 35 | EndM
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | ;
|
|---|
| 39 | ; An ORG directive resets the location counter where code and data is
|
|---|
| 40 | ; generated. If the location counter is reset back to a point where
|
|---|
| 41 | ; code or data already has been generated, this will be overwritten
|
|---|
| 42 | ; without warning.
|
|---|
| 43 | ; This macro can be used with every ORG directive to check for this condition,
|
|---|
| 44 | ; and when it occurs further assembly is terminated.
|
|---|
| 45 |
|
|---|
| 46 | ; NOTE: Overlapchecking in JWasm is not as reliable as in Tasm.
|
|---|
| 47 | ; Because it's a single pass assembler, the current location can be
|
|---|
| 48 | ; incorrect. Tasm with multiple passes works correct.
|
|---|
| 49 | ; FIXME: Get JWasm and Tasm use some common ECHO/%OUT method.
|
|---|
| 50 | ; (Tasm only pases first word of non-quoted string to a macro)
|
|---|
| 51 | check_overlap MACRO loc
|
|---|
| 52 |
|
|---|
| 53 | ; Exit macro immediately if no overlap.
|
|---|
| 54 | ; We don't want to assign values to z_last_... if there is no
|
|---|
| 55 | ; overlap because they would then hold the values the last time this
|
|---|
| 56 | ; macro was called and not those of the last overlap.
|
|---|
| 57 | IF (loc - $) LE 0
|
|---|
| 58 | ;~ IF ($ - loc) GE 0
|
|---|
| 59 | EXITM
|
|---|
| 60 | ENDIF
|
|---|
| 61 |
|
|---|
| 62 | ; Calculate the overlap.
|
|---|
| 63 | z_last_overlap_size = (loc - $)
|
|---|
| 64 | z_last_overlap_location = loc - z_last_overlap_size
|
|---|
| 65 |
|
|---|
| 66 | IFDEF JWASM
|
|---|
| 67 | ; Output message.
|
|---|
| 68 | ECHO
|
|---|
| 69 | ECHO ** ERROR: LOCATION OVERLAP DETECTED [JWASM] ! **
|
|---|
| 70 | ECHO . THIS IS MOST LIKELY CAUSED BY CODE / DATA
|
|---|
| 71 | ECHO . EXPANSION TOWARDS AN 'ORG' DIRECTIVE.
|
|---|
| 72 | ECHO . LOOK AT 'z_last_overlap_location' TO SEE WHERE.
|
|---|
| 73 | ECHO . LOOK AT 'z_last_overlap_size' TO SEE SIZE.
|
|---|
| 74 | ECHO . FORCING ERROR...
|
|---|
| 75 | ECHO
|
|---|
| 76 | ENDIF
|
|---|
| 77 | IFDEF TASM
|
|---|
| 78 | IF2
|
|---|
| 79 | ; Output message (only on pass2).
|
|---|
| 80 | %OUT
|
|---|
| 81 | %OUT ** ERROR: LOCATION OVERLAP DETECTED [TASM] ! **
|
|---|
| 82 | %OUT . THIS IS MOST LIKELY CAUSED BY CODE / DATA
|
|---|
| 83 | %OUT . EXPANSION TOWARDS AN 'ORG' DIRECTIVE.
|
|---|
| 84 | %OUT . LOOK AT 'z_last_overlap_location' TO WHERE.
|
|---|
| 85 | %OUT . LOOK AT 'z_last_overlap_size' TO SEE SIZE.
|
|---|
| 86 | %OUT . FORCING ERROR...
|
|---|
| 87 | %OUT
|
|---|
| 88 | ENDIF
|
|---|
| 89 | ENDIF
|
|---|
| 90 |
|
|---|
| 91 | ; Terminate assembly by forcing an error.
|
|---|
| 92 | .ERR
|
|---|
| 93 |
|
|---|
| 94 | ENDM
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | ; Shortcuts for pointer-types
|
|---|
| 98 | bptr equ byte ptr
|
|---|
| 99 | wptr equ word ptr
|
|---|
| 100 | dptr equ dword ptr
|
|---|
| 101 | qptr equ qword ptr
|
|---|
| 102 | tptr equ tbyte ptr
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 | sector_size equ 512
|
|---|
| 106 | image_size_60secs equ 7800h
|
|---|
| 107 | image_size_62secs equ 7c00h
|
|---|
| 108 |
|
|---|
| 109 | ;image_size equ image_size_60secs
|
|---|
| 110 | image_size equ image_size_62secs
|
|---|
| 111 |
|
|---|
| 112 | sector_count equ image_size / sector_size ; Image size in sectors
|
|---|
| 113 |
|
|---|
| 114 | IF image_size EQ image_size_60secs
|
|---|
| 115 | partition_count equ 30 ; Maximum number of partitions supported
|
|---|
| 116 | ELSE
|
|---|
| 117 | partition_count equ 45 ; Maximum number of partitions supported
|
|---|
| 118 | ENDIF
|
|---|