; Ross Zwisler 8-16-02 ; errors.asm: This file was created to demonstrate the different error messages ; that are generated by the SRCTools parser. This file only covers semantic ; errors, which are reported in the .lst file. Syntatic errors prohibit the ; creation of a .lst file (and a parse tree), and are handled differently. ; Note that whenever an invalid value is found, it is assembled to the value 0 ; in the hex machine word. ; ########### NOTE ########### ; As of SRCTools version 3.0.3, assemble time arithmetic is allowed, and all ; constants are tried as both unsigned and signed. So, for instance, if ; we were using only 4 bits, both 15 and -1 would both be 1111b. They would ; both be valid and indistinguishable. Thus, many of the cases in this file ; no longer generate errors. ; the largest binary argument for a .org (unsigned) .org 11111111111111111111111111111111b ; 32 bits .org 100000000000000000000000000000000B ; 33 bits, ERROR ; the largest hex argument for a .org (unsigned) .org FFFFFFFFh ; 32 bits .org 0x100000000 ; 33 bits, ERROR ; the largest decimal argument for a .org (unsigned) .org 4294967295 ; 2^32 - 1 .org 4294967296 ; 2^32, ERROR ; the smallest decimal argument for a .org (unsigned) .org 0 .org -1 ; negative argument, ERROR ; the maximum binary arguments to a .equ (signed) Lbl1: .equ 1111111111111111111111111111111B ; 31 bits, positive Lbl2: .equ 10000000000000000000000000000000B ; 32 bits, negative Lbl3: .equ 11111111111111111111111111111111b ; 32 bits, -1 Lbl4: .equ 100000000000000000000000000000000b ; 33 bits, ERROR ; the largest decimal argument for a .equ (signed) Lbl5: .equ 2147483647 ; 2^31 - 1 Lbl6: .equ 2147483648 ; 2^31, ERROR ; the smallest decimal argument for a .equ (signed) Lbl7: .equ -2147483648 ; -2^31 Lbl8: .equ -2147483649 ; -(2^31+1), ERROR ; the largest hex for a .equ (signed) Lbl9: .equ 0x7FFFFFFF ; positive Lbl10: .equ 80000000h ; negative Lbl11: .equ FFFFFFFFH ; -1 Lbl12: .equ 0x100000000 ; ERROR ; the largest binary argument for a .db (unsigned) .db 11111111111111111111111111111111b ; 32 bits, or all but 1 byte of memory .db 100000000000000000000000000000000B ; 33 bits, ERROR ; the largest hex argument for a .db (unsigned) .db FFFFFFFFh ; 32 bits, all but 1 byte of memory .db 100000000H ; 33 bits, ERROR ; the largest decimal argument for a .db (unsigned) .db 4294967295 ; 2^32 - 1 .db 4294967296 ; 2^32, ERROR ; the smallest decimal argument for a .db (unsigned) .db 0 .db -1 ; negative argument, ERROR ; the largest binary argument for a .dh (unsigned) .dh 1111111111111111111111111111111b ; 31 bits, or all but 2 bytes (one halfword) of memory .dh 10000000000000000000000000000000B ; 32 bits, ERROR ; the largest hex argument for a .dh (unsigned) .dh 7FFFFFFFh ; 31 bits, all but 1 halfword of memory .dh 80000000H ; 32 bits, ERROR ; the largest decimal argument for a .dh (unsigned) .dh 2147483647 ; 2^31 - 1 .dh 2147483648 ; 2^31, ERROR ; the smallest decimal argument for a .dh (unsigned) .dh 0 .dh -1 ; negative argument, ERROR ; the largest binary argument for a .dw (unsigned) .dw 111111111111111111111111111111b ; 30 bits, or all but 1 word of memory .dw 1000000000000000000000000000000B ; 31 bits, ERROR ; the largest hex argument for a .dw (unsigned) .dw 3FFFFFFFh ; 30 bits, all but 1 word of memory .dw 40000000H ; 31 bits, ERROR ; the largest decimal argument for a .dw (unsigned) .dw 1073741823 ; 2^30 - 1 .dw 1073741824 ; 2^30, ERROR ; the smallest decimal argument for a .dw (unsigned) .dw 0 .dw -1 ; negative argument, ERROR ; C1 is only used in relative addresses. Hence, the values that are allowable ; for C1 depend on where the location counter is. (The value stored in the ; machine word is the difference between the desintation address and the ; location counter incremented by four.) Before each ldr I .org to 0xfffffffc ; so that the value stored in the machine word will be the difference from ; address zero. ; the largest binary argument for C1 (22 bits, signed) .org 0xfffffffc ldr r2, 111111111111111111111b ; 21 bits .org 0xfffffffc ldr r2, 1000000000000000000000B ; 22 bits, ERROR ; the largest hex argument for C1 (22 bits, signed) .org 0xfffffffc ldr r2, 1FFFFFh ; 21 bits .org 0xfffffffc ldr r2, 200000H ; 22 bits, ERROR ; the largest decimal argument for C1 (22 bits, signed) .org 0xfffffffc ldr r2, 2097151 ; 2^21 -1 .org 0xfffffffc ldr r2, 2097152 ; 2^21, ERROR ; the smallest decimal argument for C1 (22 bits, signed) .org 0xfffffffc ldr r2, -2097152 ; -2^21 .org 0xfffffffc ldr r2, -2097153 ; -(2^21+1), ERROR ; For C1, if I .org to another value, I can put in a larger constant as long ; as the difference is still within range. (It works for all number formats) .org 1ffffffch ; so base address will be 0x20000000 ldr r2, 0x201fffff ; difference is 0x1fffff .org 1ffffffch ; so base address will be 0x20000000 ldr r2, 0x20200000 ; difference is 0x200000, ERROR ; It also works for negative offsets .org 1ffffffch ; so base address will be 0x20000000 ldr r2, 0x1fe00000 ; difference is -2097152 .org 1ffffffch ; so base address will be 0x20000000 ldr r2, 0x1fdfffff ; difference is -2097153, ERROR ; the largest binary argument for C2 (17 bits, signed) ld r2, 1111111111111111b ; 16 bits ld r2, 10000000000000000B ; 17 bits, ERROR ; the largest hex argument for C2 (17 bits, signed) ld r2, FFFFh ; 16 bits ld r2, 10000H ; 17 bits, ERROR ; the largest decimal argument for C2 (17 bits, signed) ld r2, 65535 ; 2^16 -1 ld r2, 65536 ; 2^16, ERROR ; the smallest decimal argument for C2 (17 bits, signed) ld r2, -65536 ; -2^16 ld r2, -65537 ; -(2^16+1), ERROR ; the largest binary argument for C3 (12 bits, signed) shr r2, r3, 11111111111b ; 11 bits shr r2, r3, 100000000000B ; 12 bits, ERROR ; the largest hex argument for C3 (12 bits, signed) shr r2, r3, 7FFh ; 11 bits shr r2, r3, 800H ; 12 bits, ERROR ; the largest decimal argument for C3 (12 bits, signed) shr r2, r3, 2047 ; 2^11 -1 shr r2, r3, 2048 ; 2^11, ERROR ; the largest decimal argument for C3 (12 bits, signed) shr r2, r3, -2048 ; -2^11 shr r2, r3, -2049 ; -(2^11+1), ERROR ; the largest binary argument for .dcb (signed) .dcb 1111111b ; 7 bits .dcb 10000000B ; 8 bits, ERROR ; the largest hex argument for .dcb (signed) .dcb 7Fh ; 7 bits .dcb 80h ; 8 bits, ERROR ; the largest decimal argument for .dcb (signed) .dcb 127 ; 2^7 - 1 .dcb 128 ; 2^7, ERROR ; the smallest decimal argument for .dcb (signed) .dcb -128 ; -2^7 .dcb -129 ; -(2^7+1), ERROR ; the largest binary argument for .dch (signed) .dch 111111111111111b ; 15 bits .dch 1000000000000000B ; 16 bits, ERROR ; the largest hex argument for .dch (signed) .dch 7FFFh ; 15 bits .dch 8000h ; 16 bits, ERROR ; the largest decimal argument for .dch (signed) .dch 32767 ; 2^16 - 1 .dch 32768 ; 2^16, ERROR ; the smallest decimal argument for .dch (signed) .dch -32768 ; -2^16 .dch -32769 ; -(2^16+1), ERROR ; the largest binary argument for .dc (signed) .dc 11111111111111111111111111111111b ; 32 bits .dc 100000000000000000000000000000000B ; 33 bits, ERROR ; the largest hex argument for .dc (signed) .dc FFFFFFFFh ; 32 bits .dc 0x100000000 ; 33 bits, ERROR ; the largest decimal argument for .dc (signed) .dc 2147483647 ; 2^31 - 1 .dc 2147483648 ; 2^31, ERROR ; the smallest decimal argument for .dc (signed) .dc -2147483648 ; -2^31 .dc -2147483649 ; -(2^31+1), ERROR ; multiple label definitions LabDef1: add r2, r2, r2 LabDef1: add r2, r2, r2 ; has already been defined, ERROR LabDef1: .equ 2 ; has already been defined, ERROR ; forward references used in non-dc pseudo-ops .org LabDef1 ; OK, defined above .org LabDef2 ; ERROR TMP: .equ LabDef2 ; ERROR .db LabDef2 ; ERROR .dh LabDef2 ; ERROR .dc LabDef2 ; ERROR LabDef2: .equ 100 ; all of these are forward references to this label. ; must have label with .equ .equ 1000 ; undefined label addi r2, r2, NoLabelDef