hexed: use bin size for reloc; minor updates
[megadrive.git] / hexed / hexed.s
index b999de1..b7d9186 100644 (file)
@@ -1,6 +1,6 @@
 ###############################################################################
 #
-# Copyright (c) 2009, Gražvydas Ignotas
+# Copyright (c) 2009,2011 Gražvydas Ignotas
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 #       names of its contributors may be used to endorse or promote products
 #       derived from this software without specific prior written permission.
 #
-# THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
+# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND ANY
 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+# DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -215,6 +215,9 @@ safe_addrs:
        dc.l 0xa13000, 0xa130ff
 safe_addrs_end:
 
+sizeof_bin:
+       dc.l _edata
+
 txt_edit:
        .ascii  "- edit -\0"
 txt_a_confirm:
@@ -269,7 +272,8 @@ main:
        bne             0f
 
        move.l          #0,a0
-       move.w          #0x2000/8-1,d0
+       move.l          (sizeof_bin,pc),d0
+       lsr.l           #3,d0
 1:
        move.l          (a0)+,(a1)+
        move.l          (a0)+,(a1)+
@@ -286,7 +290,8 @@ main:
 
        /* copy, assume 8K size */
        move.l          #0xFF0100,a1
-       move.w          #0x2000/8-1,d0
+       move.l          (sizeof_bin,pc),d0
+       lsr.l           #3,d0
 1:
        move.l          (a0)+,(a1)+
        move.l          (a0)+,(a1)+
@@ -443,6 +448,7 @@ no_auto_transfer:
        lea             (jumptab,pc,d0),a0
        jmp             (a0)
 jumptab:
+       /* branch insns here because we want to be position independent */
        bra             mode_main
        bra             mode_val_input
        bra             mode_edit_val   /* edit val in editor */