]> git.the-white-hart.net Git - atmega/siggen.git/commitdiff
Fix EXT macro bug and add out-of-range test prints
authoruser <none>
Fri, 18 Aug 2023 01:12:11 +0000 (20:12 -0500)
committeruser <none>
Fri, 18 Aug 2023 01:12:11 +0000 (20:12 -0500)
These prints are ugly, but they'll print 0x01 when a branch target is
out of range, and 0x00 if a branch is fine.

asm_2/tbc.inc

index 7523e1751eb0ee7fa12998d88872b378fa5edc37..739c9821674169aa5da276f4818b2c5780b9d2c0 100644 (file)
 ; ----- Group B, branches
 
 .macro T_JTAB
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        .if @0 < 0 || @0 > 0x5
        .error "Tortoise Bytecode: invalid variable register (V0-V5 for JTAB)"
        .endif
 .endmacro
 
 .macro T_BLT
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0-(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 .endmacro
 
 .macro T_BGE
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0-(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 .endmacro
 
 .macro T_BV
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0-(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 .endmacro
 
 .macro T_BNV
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0-(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 .endmacro
 
 .macro T_BMI
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0-(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 .endmacro
 
 .macro T_BPL
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0-(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 .endmacro
 
 .macro T_BZ
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0-(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 .endmacro
 
 .macro T_BNZ
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 .endmacro
 
 .macro T_BC
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0-(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 .endmacro
 
 .macro T_BNC
+       .message "Branch at ", PC, " ", (@0-(PC+1-PCERROR) < -0x80) || (@0-(PC+1-PCERROR) >= 0x80)
        ;.if (@0-(PC+1-PCERROR)) < -0x80 || (@0-(PC+1-PCERROR)) >= 0x80
        ;.error "Tortoise Bytecode: branch target out of range"
        ;.endif
 ; ----- Miscellaneous
 
 .macro T_JAL
+       .message "Jump at ", PC, "   ", (@0-(PC+1-PCERROR) < -0x800) || (@0-(PC+1-PCERROR) >= 0x800)
        ;.if (@0-(PC+1-PCERROR)) < -0x800 || (@0-(PC+1-PCERROR)) >= 0x800
        ;.error "Tortoise Bytecode: jump target out of range"
        ;.endif
 .endmacro
 
 .macro T_JMP
+       .message "Jump at ", PC, "   ", (@0-(PC+1-PCERROR) < -0x800) || (@0-(PC+1-PCERROR) >= 0x800)
        ;.if (@0-(PC+1-PCERROR)) < -0x800 || (@0-(PC+1-PCERROR)) >= 0x800
        ;.error "Tortoise Bytecode: jump target out of range"
        ;.endif
 .endmacro
 
 .macro T_EXT
+       .message "Ext at ", PC, "    ", (@0 < 0) || (@0 > 0xfff)
        ;.if @0 < 0 || @0 > 0xfff
        ;.error "Tortoise Bytecode: EXT target out of range"
        ;.endif
-       .dw     (0xe << 12) | (HIGH(@0)&0x0f) | LOW(@0)
+       .dw     (0xe << 12) | ((HIGH(@0)&0x0f) << 8) | LOW(@0)
 .endmacro
 
 .macro T_CLR