diff --git a/Asm65/Formatter.cs b/Asm65/Formatter.cs index 022730a..5ef0ef4 100644 --- a/Asm65/Formatter.cs +++ b/Asm65/Formatter.cs @@ -535,12 +535,12 @@ namespace Asm65 { } /// - /// Formats a value as decimal. + /// Formats a 32-bit integer value as unsigned decimal. /// /// Value to convert. /// Formatted string. public string FormatDecimalValue(int value) { - return value.ToString(); + return ((uint)value).ToString(); } /// diff --git a/CommonUtil/BitTwiddle.cs b/CommonUtil/BitTwiddle.cs index f5b5fd4..ddfbaf8 100644 --- a/CommonUtil/BitTwiddle.cs +++ b/CommonUtil/BitTwiddle.cs @@ -90,5 +90,20 @@ namespace CommonUtil { // all the bits to the right of it, then just count the 1s. return CountOneBits(IsolateLeastSignificantOne(val) - 1); } + + /// + /// Sign-extends an integer value. + /// + /// Value to extend. + /// Number of significant bytes (1-4). + /// Sign-extended value, or original value if byteLen is invalid. + public static int SignExtend(int val, int byteLen) { + if (byteLen < 1 || byteLen >= 4) { + // invalid, or nothing to do + return val; + } + int shiftCount = (4 - byteLen) * 8; + return (val << shiftCount) >> shiftCount; + } } } diff --git a/SourceGen/SGTestData/20020-operand-formats b/SourceGen/SGTestData/20020-operand-formats new file mode 100644 index 0000000..5543625 Binary files /dev/null and b/SourceGen/SGTestData/20020-operand-formats differ diff --git a/SourceGen/SGTestData/20020-operand-formats.dis65 b/SourceGen/SGTestData/20020-operand-formats.dis65 new file mode 100644 index 0000000..d98206d --- /dev/null +++ b/SourceGen/SGTestData/20020-operand-formats.dis65 @@ -0,0 +1,487 @@ +### 6502bench SourceGen dis65 v1.0 ### +{ +"_ContentVersion":3, +"FileDataLength":165, +"FileDataCrc32":-689690654, +"ProjectProps":{ +"CpuName":"6502", +"IncludeUndocumentedInstr":false, +"TwoByteBrk":false, +"EntryFlags":32702671, +"AutoLabelStyle":"Simple", +"AnalysisParams":{ +"AnalyzeUncategorizedData":true, +"DefaultTextScanMode":"LowHighAscii", +"MinCharsForString":4, +"SeekNearbyTargets":true, +"SmartPlpHandling":true}, + +"PlatformSymbolFileIdentifiers":[], +"ExtensionScriptFileIdentifiers":[], +"ProjectSyms":{ +}}, + +"AddressMap":[{ +"Offset":0, +"Addr":4096}], +"TypeHints":[{ +"Low":0, +"High":0, +"Hint":"Code"}], +"StatusFlagOverrides":{ +}, + +"Comments":{ +}, + +"LongComments":{ +"-2147483647":{ +"Text":"Project file was edited to force ASCII formatting for some operands.", +"BoxMode":false, +"MaxWidth":80, +"BackgroundColor":0}}, + +"Notes":{ +}, + +"UserLabels":{ +"129":{ +"Label":"more_ascii", +"Value":4225, +"Source":"User", +"Type":"GlobalAddr", +"LabelAnno":"None"}, + +"93":{ +"Label":"skipdata", +"Value":4189, +"Source":"User", +"Type":"GlobalAddr", +"LabelAnno":"None"}}, + +"OperandFormats":{ +"10":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"12":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"15":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"17":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"20":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"22":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"25":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"27":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"30":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Binary", +"SymbolRef":null}, + +"32":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Binary", +"SymbolRef":null}, + +"35":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Binary", +"SymbolRef":null}, + +"37":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Binary", +"SymbolRef":null}, + +"43":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Hex", +"SymbolRef":null}, + +"44":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Hex", +"SymbolRef":null}, + +"46":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Hex", +"SymbolRef":null}, + +"49":{ +"Length":4, +"Format":"NumericLE", +"SubFormat":"Hex", +"SymbolRef":null}, + +"53":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"54":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"56":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"59":{ +"Length":4, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"63":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"64":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"66":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"69":{ +"Length":4, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"73":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Binary", +"SymbolRef":null}, + +"74":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Binary", +"SymbolRef":null}, + +"76":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Binary", +"SymbolRef":null}, + +"79":{ +"Length":4, +"Format":"NumericLE", +"SubFormat":"Binary", +"SymbolRef":null}, + +"83":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"84":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"86":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"89":{ +"Length":4, +"Format":"NumericLE", +"SubFormat":"Decimal", +"SymbolRef":null}, + +"93":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"95":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"97":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"100":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"102":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"104":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"106":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"108":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"110":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"112":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"114":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"116":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"118":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"120":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"122":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"124":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"129":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"131":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Hex", +"SymbolRef":null}, + +"134":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Address", +"SymbolRef":null}, + +"136":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Address", +"SymbolRef":null}, + +"139":{ +"Length":2, +"Format":"NumericBE", +"SubFormat":"Address", +"SymbolRef":null}, + +"141":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Symbol", +"SymbolRef":{ +"Label":"more_ascii", +"Part":"Low"}}, + +"142":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Symbol", +"SymbolRef":{ +"Label":"more_ascii", +"Part":"High"}}, + +"143":{ +"Length":2, +"Format":"NumericLE", +"SubFormat":"Address", +"SymbolRef":null}, + +"145":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Address", +"SymbolRef":null}, + +"148":{ +"Length":4, +"Format":"NumericLE", +"SubFormat":"Address", +"SymbolRef":null}, + +"152":{ +"Length":2, +"Format":"NumericBE", +"SubFormat":"Address", +"SymbolRef":null}, + +"154":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"155":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"156":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"157":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"158":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"Ascii", +"SymbolRef":null}, + +"159":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"160":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"161":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"162":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"163":{ +"Length":1, +"Format":"NumericLE", +"SubFormat":"HighAscii", +"SymbolRef":null}}, + +"LvTables":{ +}, + +"Visualizations":[], +"VisualizationAnimations":[], +"VisualizationSets":{ +}} diff --git a/SourceGen/SGTestData/20022-operand-formats b/SourceGen/SGTestData/20022-operand-formats index 3dbfc61..e29863c 100644 Binary files a/SourceGen/SGTestData/20022-operand-formats and b/SourceGen/SGTestData/20022-operand-formats differ diff --git a/SourceGen/SGTestData/20022-operand-formats.dis65 b/SourceGen/SGTestData/20022-operand-formats.dis65 index e23d6c5..bb1aacc 100644 --- a/SourceGen/SGTestData/20022-operand-formats.dis65 +++ b/SourceGen/SGTestData/20022-operand-formats.dis65 @@ -1,13 +1,13 @@ ### 6502bench SourceGen dis65 v1.0 ### { "_ContentVersion":3, -"FileDataLength":143, -"FileDataCrc32":-2044577818, +"FileDataLength":62, +"FileDataCrc32":946946401, "ProjectProps":{ "CpuName":"65816", "IncludeUndocumentedInstr":false, "TwoByteBrk":false, -"EntryFlags":33489103, +"EntryFlags":32702671, "AutoLabelStyle":"Simple", "AnalysisParams":{ "AnalyzeUncategorizedData":true, @@ -36,7 +36,7 @@ "LongComments":{ "-2147483647":{ -"Text":"Project file was edited for some ASCII operands.", +"Text":"Project file was edited to force ASCII formatting for some operands.", "BoxMode":false, "MaxWidth":80, "BackgroundColor":0}}, @@ -45,405 +45,89 @@ }, "UserLabels":{ -"63":{ -"Label":"skipdata", -"Value":4159, -"Source":"User", -"Type":"LocalOrGlobalAddr", -"LabelAnno":"None"}, - -"112":{ -"Label":"more_ascii", -"Value":4208, -"Source":"User", -"Type":"LocalOrGlobalAddr", -"LabelAnno":"None"}}, +}, "OperandFormats":{ -"4":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Hex", -"SymbolRef":null}, - -"6":{ +"7":{ "Length":3, "Format":"NumericLE", -"SubFormat":"Hex", +"SubFormat":"Decimal", "SymbolRef":null}, -"9":{ -"Length":4, +"10":{ +"Length":3, "Format":"NumericLE", -"SubFormat":"Hex", +"SubFormat":"Decimal", "SymbolRef":null}, "13":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Decimal", -"SymbolRef":null}, - -"15":{ "Length":3, "Format":"NumericLE", -"SubFormat":"Decimal", +"SubFormat":"Binary", "SymbolRef":null}, -"18":{ -"Length":4, +"19":{ +"Length":3, "Format":"NumericLE", "SubFormat":"Decimal", "SymbolRef":null}, "22":{ -"Length":2, +"Length":3, "Format":"NumericLE", -"SubFormat":"Binary", +"SubFormat":"Decimal", "SymbolRef":null}, -"24":{ +"25":{ "Length":3, "Format":"NumericLE", "SubFormat":"Binary", "SymbolRef":null}, -"27":{ +"32":{ "Length":4, "Format":"NumericLE", -"SubFormat":"Binary", -"SymbolRef":null}, - -"33":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Hex", -"SymbolRef":null}, - -"34":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Hex", +"SubFormat":"Decimal", "SymbolRef":null}, "36":{ -"Length":3, -"Format":"NumericLE", -"SubFormat":"Hex", -"SymbolRef":null}, - -"39":{ "Length":4, "Format":"NumericLE", -"SubFormat":"Hex", +"SubFormat":"Decimal", "SymbolRef":null}, -"43":{ -"Length":1, +"40":{ +"Length":4, "Format":"NumericLE", -"SubFormat":"Decimal", +"SubFormat":"Binary", "SymbolRef":null}, "44":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Decimal", -"SymbolRef":null}, - -"46":{ "Length":3, "Format":"NumericLE", -"SubFormat":"Decimal", +"SubFormat":"Ascii", "SymbolRef":null}, -"49":{ -"Length":4, +"47":{ +"Length":3, "Format":"NumericLE", -"SubFormat":"Decimal", +"SubFormat":"HighAscii", +"SymbolRef":null}, + +"50":{ +"Length":3, +"Format":"NumericLE", +"SubFormat":"Ascii", "SymbolRef":null}, "53":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Binary", -"SymbolRef":null}, - -"54":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Binary", -"SymbolRef":null}, - -"56":{ -"Length":3, -"Format":"NumericLE", -"SubFormat":"Binary", -"SymbolRef":null}, - -"59":{ -"Length":4, -"Format":"NumericLE", -"SubFormat":"Binary", -"SymbolRef":null}, - -"63":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"65":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"67":{ -"Length":3, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"70":{ "Length":4, "Format":"NumericLE", "SubFormat":"Ascii", "SymbolRef":null}, -"74":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"76":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"78":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"80":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"82":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"84":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"86":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"88":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"90":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"92":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"94":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"96":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"98":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"100":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"102":{ -"Length":3, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"105":{ -"Length":3, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"108":{ -"Length":3, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"112":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"113":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"114":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"117":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Address", -"SymbolRef":null}, - -"119":{ -"Length":3, -"Format":"NumericLE", -"SubFormat":"Address", -"SymbolRef":null}, - -"122":{ -"Length":2, -"Format":"NumericBE", -"SubFormat":"Address", -"SymbolRef":null}, - -"124":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Symbol", -"SymbolRef":{ -"Label":"more_ascii", -"Part":"Low"}}, - -"125":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Symbol", -"SymbolRef":{ -"Label":"more_ascii", -"Part":"High"}}, - -"126":{ -"Length":2, -"Format":"NumericLE", -"SubFormat":"Symbol", -"SymbolRef":{ -"Label":"more_ascii", -"Part":"Low"}}, - -"128":{ -"Length":3, -"Format":"NumericLE", -"SubFormat":"Symbol", -"SymbolRef":{ -"Label":"more_ascii", -"Part":"Low"}}, - -"131":{ -"Length":2, -"Format":"NumericBE", -"SubFormat":"Symbol", -"SymbolRef":{ -"Label":"more_ascii", -"Part":"Low"}}, - -"133":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"134":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"135":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"136":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"137":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"Ascii", -"SymbolRef":null}, - -"138":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"139":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"140":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"141":{ -"Length":1, -"Format":"NumericLE", -"SubFormat":"HighAscii", -"SymbolRef":null}, - -"142":{ -"Length":1, +"57":{ +"Length":4, "Format":"NumericLE", "SubFormat":"HighAscii", "SymbolRef":null}}, diff --git a/SourceGen/SGTestData/Expected/20020-operand-formats_64tass.S b/SourceGen/SGTestData/Expected/20020-operand-formats_64tass.S new file mode 100644 index 0000000..873384a --- /dev/null +++ b/SourceGen/SGTestData/Expected/20020-operand-formats_64tass.S @@ -0,0 +1,90 @@ +;Project file was edited to force ASCII formatting for some operands. + .cpu "6502" + .enc sg_hiascii + .cdef $20,$7e,$a0 + .enc sg_ascii + .cdef $20,$7e,$20 +* = $1000 + lda $01 + lda $0102 + lda $fe + lda $feff + lda 1 + lda 258 + lda 254 + lda 65279 + lda 1 + lda 258 + lda 254 + lda 65279 + lda %00000001 + lda %0000000100000010 + lda %11111110 + lda %1111111011111111 + jmp skipdata + + .byte $01 + .word $0201 + .long $030201 + .dword $04030201 + .byte 1 + .word 513 + .long 197121 + .dword 67305985 + .byte 1 + .word 513 + .long 197121 + .dword 67305985 + .byte %00000001 + .word %0000001000000001 + .long %000000110000001000000001 + .dword %00000100000000110000001000000001 + .byte 255 + .word 65279 + .long 16645887 + .dword 4244504319 + +skipdata lda #'h' + lda 'h' + lda @w'h' + lda #$1f + lda #' ' + lda #'"' + lda #$27 + lda #'~' + lda #$7f + lda #$80 + lda #$9f + lda #' ' | $80 + lda #'"' | $80 + lda #$a7 + lda #'~' | $80 + lda #$ff + jmp L10A4 + +more_ascii .byte 'h' + .byte $80 + .word $6868 + .byte $80 + .word skipdata + .long skipdata + .byte $10,$5d + .byte more_ascii + .word more_ascii + .long more_ascii + .dword more_ascii + .byte $10,$81 + .byte '[' + .byte '{' + .byte '|' + .byte '}' + .byte ',' + .byte '[' | $80 + .byte '{' | $80 + .byte '|' | $80 + .byte '}' | $80 + .byte ',' | $80 + +L10A4 rts + diff --git a/SourceGen/SGTestData/Expected/20020-operand-formats_Merlin32.S b/SourceGen/SGTestData/Expected/20020-operand-formats_Merlin32.S new file mode 100644 index 0000000..198ab54 --- /dev/null +++ b/SourceGen/SGTestData/Expected/20020-operand-formats_Merlin32.S @@ -0,0 +1,85 @@ +;Project file was edited to force ASCII formatting for some operands. + org $1000 + lda $01 + lda $0102 + lda $fe + lda $feff + lda 1 + lda 258 + lda 254 + lda 65279 + lda 1 + lda 258 + lda 254 + lda 65279 + lda %00000001 + lda %0000000100000010 + lda %11111110 + lda %1111111011111111 + jmp skipdata + + dfb $01 + dw $0201 + adr $030201 + adrl $04030201 + dfb 1 + dw 513 + adr 197121 + adrl 67305985 + dfb 1 + dw 513 + adr 197121 + adrl 67305985 + dfb %00000001 + dw %0000001000000001 + adr %000000110000001000000001 + adrl %00000100000000110000001000000001 + dfb 255 + dw 65279 + adr 16645887 + adrl 4244504319 + +skipdata lda #'h' + lda 'h' + lda: 'h' + lda #$1f + lda #' ' + lda #'"' + lda #$27 + lda #'~' + lda #$7f + lda #$80 + lda #$9f + lda #" " + lda #$a2 + lda #"'" + lda #"~" + lda #$ff + jmp L10A4 + +more_ascii dfb 'h' + dfb $80 + dw $6868 + dfb $80 + dw skipdata + adr skipdata + ddb skipdata + dfb more_ascii + dw more_ascii + adr more_ascii + adrl more_ascii + ddb more_ascii + dfb '[' + dfb $7b + dfb '|' + dfb $7d + dfb ',' + dfb "[" + dfb $fb + dfb "|" + dfb $fd + dfb "," + +L10A4 rts + diff --git a/SourceGen/SGTestData/Expected/20020-operand-formats_acme.S b/SourceGen/SGTestData/Expected/20020-operand-formats_acme.S new file mode 100644 index 0000000..68d2dc9 --- /dev/null +++ b/SourceGen/SGTestData/Expected/20020-operand-formats_acme.S @@ -0,0 +1,86 @@ +;Project file was edited to force ASCII formatting for some operands. + !cpu 6502 +* = $1000 + lda $01 + lda $0102 + lda $fe + lda $feff + lda 1 + lda 258 + lda 254 + lda 65279 + lda 1 + lda 258 + lda 254 + lda 65279 + lda %00000001 + lda %0000000100000010 + lda %11111110 + lda %1111111011111111 + jmp skipdata + + !byte $01 + !word $0201 + !24 $030201 + !32 $04030201 + !byte 1 + !word 513 + !24 197121 + !32 67305985 + !byte 1 + !word 513 + !24 197121 + !32 67305985 + !byte %00000001 + !word %0000001000000001 + !24 %000000110000001000000001 + !32 %00000100000000110000001000000001 + !byte 255 + !word 65279 + !24 16645887 + !32 4244504319 + +skipdata lda #'h' + lda 'h' + lda+2 'h' + lda #$1f + lda #' ' + lda #'"' + lda #$27 + lda #'~' + lda #$7f + lda #$80 + lda #$9f + lda #' ' | $80 + lda #'"' | $80 + lda #$a7 + lda #'~' | $80 + lda #$ff + jmp L10A4 + +more_ascii !byte 'h' + !byte $80 + !word $6868 + !byte $80 + !word skipdata + !24 skipdata + !byte $10,$5d + !byte more_ascii + !word more_ascii + !24 more_ascii + !32 more_ascii + !byte $10,$81 + !byte '[' + !byte '{' + !byte '|' + !byte '}' + !byte ',' + !byte '[' | $80 + !byte '{' | $80 + !byte '|' | $80 + !byte '}' | $80 + !byte ',' | $80 + +L10A4 rts + diff --git a/SourceGen/SGTestData/Expected/20020-operand-formats_cc65.S b/SourceGen/SGTestData/Expected/20020-operand-formats_cc65.S new file mode 100644 index 0000000..c967835 --- /dev/null +++ b/SourceGen/SGTestData/Expected/20020-operand-formats_cc65.S @@ -0,0 +1,87 @@ +;Project file was edited to force ASCII formatting for some operands. + .setcpu "6502" +; .segment "SEG000" + .org $1000 + lda $01 + lda $0102 + lda $fe + lda $feff + lda 1 + lda 258 + lda 254 + lda 65279 + lda 1 + lda 258 + lda 254 + lda 65279 + lda %00000001 + lda %0000000100000010 + lda %11111110 + lda %1111111011111111 + jmp skipdata + + .byte $01 + .word $0201 + .faraddr $030201 + .dword $04030201 + .byte 1 + .word 513 + .faraddr 197121 + .dword 67305985 + .byte 1 + .word 513 + .faraddr 197121 + .dword 67305985 + .byte %00000001 + .word %0000001000000001 + .faraddr %000000110000001000000001 + .dword %00000100000000110000001000000001 + .byte 255 + .word 65279 + .faraddr 16645887 + .dword 4244504319 + +skipdata: lda #'h' + lda 'h' + lda a:'h' + lda #$1f + lda #' ' + lda #'"' + lda #$27 + lda #'~' + lda #$7f + lda #$80 + lda #$9f + lda #' ' | $80 + lda #'"' | $80 + lda #$a7 + lda #'~' | $80 + lda #$ff + jmp L10A4 + +more_ascii: .byte 'h' + .byte $80 + .word $6868 + .byte $80 + .word skipdata + .faraddr skipdata + .dbyt skipdata + .byte more_ascii + .word more_ascii + .faraddr more_ascii + .dword more_ascii + .dbyt more_ascii + .byte '[' + .byte '{' + .byte '|' + .byte '}' + .byte ',' + .byte '[' | $80 + .byte '{' | $80 + .byte '|' | $80 + .byte '}' | $80 + .byte ',' | $80 + +L10A4: rts + diff --git a/SourceGen/SGTestData/Expected/20020-operand-formats_cc65.cfg b/SourceGen/SGTestData/Expected/20020-operand-formats_cc65.cfg new file mode 100644 index 0000000..b8edb7a --- /dev/null +++ b/SourceGen/SGTestData/Expected/20020-operand-formats_cc65.cfg @@ -0,0 +1,11 @@ +# 6502bench SourceGen generated linker script for 20020-operand-formats +MEMORY { + MAIN: file=%O, start=%S, size=65536; +# MEM000: file=%O, start=$1000, size=165; +} +SEGMENTS { + CODE: load=MAIN, type=rw; +# SEG000: load=MEM000, type=rw; +} +FEATURES {} +SYMBOLS {} diff --git a/SourceGen/SGTestData/Expected/20022-operand-formats_64tass.S b/SourceGen/SGTestData/Expected/20022-operand-formats_64tass.S index 59e464a..8186a23 100644 --- a/SourceGen/SGTestData/Expected/20022-operand-formats_64tass.S +++ b/SourceGen/SGTestData/Expected/20022-operand-formats_64tass.S @@ -1,4 +1,4 @@ -;Project file was edited for some ASCII operands. +;Project file was edited to force ASCII formatting for some operands. .cpu "65816" .enc sg_hiascii .cdef $20,$7e,$a0 @@ -9,75 +9,25 @@ .xs clc xce - sep #$30 - lda $01 - lda $0102 - lda $010203 - lda 1 - lda 258 - lda 66051 - lda %00000001 - lda %0000000100000010 - lda %000000010000001000000011 - bra skipdata - - .byte $01 - .word $0201 - .long $030201 - .dword $04030201 - .byte 1 - .word 513 - .long 197121 - .dword 67305985 - .byte %00000001 - .word %0000001000000001 - .long %000000110000001000000001 - .dword %00000100000000110000001000000001 - -skipdata lda #'h' - lda 'h' - lda @w'h' - lda @l'h' - lda #$1f - lda #' ' - lda #'"' - lda #$27 - lda #'~' - lda #$7f - lda #$80 - lda #$9f - lda #' ' | $80 - lda #'"' | $80 - lda #$a7 - lda #'~' | $80 - lda #$ff - rep #'0' + rep #$30 .al .xl + lda #$1234 + lda #4660 + lda #4660 + lda #%0001001000110100 + lda #$fffe + lda #65534 + lda #65534 + lda #%1111111111111110 + lda $fffefd + lda 16776957 + lda 16776957 + lda %111111111111111011111101 lda #'h' lda #'H' | $80 lda #$6868 + lda @l'h' + lda @l'H' | $80 rts -_more_ascii .byte 'h' - .byte $80 - .word $6868 - .byte $80 - .word skipdata - .long skipdata - .byte $10,$3f - .byte <_more_ascii - .byte >_more_ascii - .word _more_ascii - .long _more_ascii - .byte $10,$70 - .byte '[' - .byte '{' - .byte '|' - .byte '}' - .byte ',' - .byte '[' | $80 - .byte '{' | $80 - .byte '|' | $80 - .byte '}' | $80 - .byte ',' | $80 diff --git a/SourceGen/SGTestData/Expected/20022-operand-formats_Merlin32.S b/SourceGen/SGTestData/Expected/20022-operand-formats_Merlin32.S index 3727e6a..348136d 100644 --- a/SourceGen/SGTestData/Expected/20022-operand-formats_Merlin32.S +++ b/SourceGen/SGTestData/Expected/20022-operand-formats_Merlin32.S @@ -1,75 +1,25 @@ -;Project file was edited for some ASCII operands. +;Project file was edited to force ASCII formatting for some operands. org $1000 clc xce - sep #$30 - lda $01 - lda $0102 - ldal $010203 - lda 1 - lda 258 - ldal 66051 - lda %00000001 - lda %0000000100000010 - ldal %000000010000001000000011 - bra skipdata - - dfb $01 - dw $0201 - adr $030201 - adrl $04030201 - dfb 1 - dw 513 - adr 197121 - adrl 67305985 - dfb %00000001 - dw %0000001000000001 - adr %000000110000001000000001 - adrl %00000100000000110000001000000001 - -skipdata lda #'h' - lda 'h' - lda: 'h' - ldal 'h' - lda #$1f - lda #' ' - lda #'"' - lda #$27 - lda #'~' - lda #$7f - lda #$80 - lda #$9f - lda #" " - lda #$a2 - lda #"'" - lda #"~" - lda #$ff - rep #'0' + rep #$30 mx %00 + lda #$1234 + lda #4660 + lda #4660 + lda #%0001001000110100 + lda #$fffe + lda #65534 + lda #65534 + lda #%1111111111111110 + ldal $fffefd + ldal 16776957 + ldal 16776957 + ldal %111111111111111011111101 lda #'h' lda #"H" lda #$6868 + ldal 'h' + ldal "H" rts -:more_ascii dfb 'h' - dfb $80 - dw $6868 - dfb $80 - dw skipdata - adr skipdata - ddb skipdata - dfb <:more_ascii - dfb >:more_ascii - dw :more_ascii - adr :more_ascii - ddb :more_ascii - dfb '[' - dfb $7b - dfb '|' - dfb $7d - dfb ',' - dfb "[" - dfb $fb - dfb "|" - dfb $fd - dfb "," diff --git a/SourceGen/SGTestData/Expected/20022-operand-formats_acme.S b/SourceGen/SGTestData/Expected/20022-operand-formats_acme.S index 331a3db..4af5457 100644 --- a/SourceGen/SGTestData/Expected/20022-operand-formats_acme.S +++ b/SourceGen/SGTestData/Expected/20022-operand-formats_acme.S @@ -1,79 +1,29 @@ -;Project file was edited for some ASCII operands. +;Project file was edited to force ASCII formatting for some operands. !cpu 65816 * = $1000 !as !rs clc xce - sep #$30 - lda $01 - lda $0102 - lda+3 $010203 - lda 1 - lda 258 - lda+3 66051 - lda %00000001 - lda %0000000100000010 - lda+3 %000000010000001000000011 - bra skipdata - - !byte $01 - !word $0201 - !24 $030201 - !32 $04030201 - !byte 1 - !word 513 - !24 197121 - !32 67305985 - !byte %00000001 - !word %0000001000000001 - !24 %000000110000001000000001 - !32 %00000100000000110000001000000001 - -skipdata lda #'h' - lda 'h' - lda+2 'h' - lda+3 'h' - lda #$1f - lda #' ' - lda #'"' - lda #$27 - lda #'~' - lda #$7f - lda #$80 - lda #$9f - lda #' ' | $80 - lda #'"' | $80 - lda #$a7 - lda #'~' | $80 - lda #$ff - rep #'0' + rep #$30 !al !rl + lda #$1234 + lda #4660 + lda #4660 + lda #%0001001000110100 + lda #$fffe + lda #65534 + lda #65534 + lda #%1111111111111110 + lda+3 $fffefd + lda+3 16776957 + lda+3 16776957 + lda+3 %111111111111111011111101 lda #'h' lda #'H' | $80 lda #$6868 + lda+3 'h' + lda+3 'H' | $80 rts -@more_ascii !byte 'h' - !byte $80 - !word $6868 - !byte $80 - !word skipdata - !24 skipdata - !byte $10,$3f - !byte <@more_ascii - !byte >@more_ascii - !word @more_ascii - !24 @more_ascii - !byte $10,$70 - !byte '[' - !byte '{' - !byte '|' - !byte '}' - !byte ',' - !byte '[' | $80 - !byte '{' | $80 - !byte '|' | $80 - !byte '}' | $80 - !byte ',' | $80 diff --git a/SourceGen/SGTestData/Expected/20022-operand-formats_cc65.S b/SourceGen/SGTestData/Expected/20022-operand-formats_cc65.S index 8eef614..4899dd9 100644 --- a/SourceGen/SGTestData/Expected/20022-operand-formats_cc65.S +++ b/SourceGen/SGTestData/Expected/20022-operand-formats_cc65.S @@ -1,4 +1,4 @@ -;Project file was edited for some ASCII operands. +;Project file was edited to force ASCII formatting for some operands. .setcpu "65816" ; .segment "SEG000" .org $1000 @@ -6,75 +6,25 @@ .i8 clc xce - sep #$30 - lda $01 - lda $0102 - lda $010203 - lda 1 - lda 258 - lda 66051 - lda %00000001 - lda %0000000100000010 - lda %000000010000001000000011 - bra skipdata - - .byte $01 - .word $0201 - .faraddr $030201 - .dword $04030201 - .byte 1 - .word 513 - .faraddr 197121 - .dword 67305985 - .byte %00000001 - .word %0000001000000001 - .faraddr %000000110000001000000001 - .dword %00000100000000110000001000000001 - -skipdata: lda #'h' - lda 'h' - lda a:'h' - lda f:'h' - lda #$1f - lda #' ' - lda #'"' - lda #$27 - lda #'~' - lda #$7f - lda #$80 - lda #$9f - lda #' ' | $80 - lda #'"' | $80 - lda #$a7 - lda #'~' | $80 - lda #$ff - rep #'0' + rep #$30 .a16 .i16 + lda #$1234 + lda #4660 + lda #4660 + lda #%0001001000110100 + lda #$fffe + lda #65534 + lda #65534 + lda #%1111111111111110 + lda $fffefd + lda 16776957 + lda 16776957 + lda %111111111111111011111101 lda #'h' lda #'H' | $80 lda #$6868 + lda f:'h' + lda f:'H' | $80 rts -@more_ascii: .byte 'h' - .byte $80 - .word $6868 - .byte $80 - .word skipdata - .faraddr skipdata - .dbyt skipdata - .byte <@more_ascii - .byte >@more_ascii - .word @more_ascii - .faraddr @more_ascii - .dbyt @more_ascii - .byte '[' - .byte '{' - .byte '|' - .byte '}' - .byte ',' - .byte '[' | $80 - .byte '{' | $80 - .byte '|' | $80 - .byte '}' | $80 - .byte ',' | $80 diff --git a/SourceGen/SGTestData/Expected/20022-operand-formats_cc65.cfg b/SourceGen/SGTestData/Expected/20022-operand-formats_cc65.cfg index 676945d..408a655 100644 --- a/SourceGen/SGTestData/Expected/20022-operand-formats_cc65.cfg +++ b/SourceGen/SGTestData/Expected/20022-operand-formats_cc65.cfg @@ -1,7 +1,7 @@ # 6502bench SourceGen generated linker script for 20022-operand-formats MEMORY { MAIN: file=%O, start=%S, size=65536; -# MEM000: file=%O, start=$1000, size=143; +# MEM000: file=%O, start=$1000, size=62; } SEGMENTS { CODE: load=MAIN, type=rw; diff --git a/SourceGen/SGTestData/Source/20020-operand-formats.S b/SourceGen/SGTestData/Source/20020-operand-formats.S new file mode 100644 index 0000000..06c0b42 --- /dev/null +++ b/SourceGen/SGTestData/Source/20020-operand-formats.S @@ -0,0 +1,99 @@ +; Copyright 2018 faddenSoft. All Rights Reserved. +; See the LICENSE.txt file for distribution terms (Apache 2.0). +; +; Basic tests for 6502. +; +; Assembler: Merlin 32 + + org $1000 + +; Basic operand formats. Show first set as hex, second as decimal, +; third as sign-extended decimal, fourth as binary. + lda $01 + lda $0102 + lda $fe + lda $feff + + lda $01 + lda $0102 + lda $fe + lda $feff + + lda $01 + lda $0102 + lda $fe + lda $feff + + lda $01 + lda $0102 + lda $fe + lda $feff + + jmp :skipdata + +; Now hex/decimal/sdec/binary, each with .dd1/.dd2/.dd3/.dd4 + hex 01010201020301020304 + hex 01010201020301020304 + hex 01010201020301020304 + hex 01010201020301020304 + +; bonus round for sdec + hex fffffefffefdfffefdfc + +:skipdata + +; Convert these to ASCII; requires editing file. The code generator +; should display some of these as hex. + lda #$68 + lda $68 + lda: $0068 + + lda #$1f + lda #$20 + lda #$22 + lda #$27 + lda #$7e + lda #$7f + lda #$80 + lda #$9f + lda #$a0 + lda #$a2 + lda #$a7 + lda #$fe + lda #$ff + + jmp end + +; Continuing with ASCII +:ascii + dfb $68 + dfb $80 + dw $6868 + dfb $80 + + +; Format first set as address, second set as symbol. + dw :skipdata + adr :skipdata + dfb >:skipdata,:skipdata ;format as big-endian address + + dfb :ascii + dfb >:ascii + dw :ascii + adr :ascii + adrl :ascii + dfb >:ascii,:ascii ;format as big-endian symbol + +; Merlin 1.0 has trouble with "DFB '{'". Test it and the neighbors. + dfb '[' + dfb $7b + dfb $7c + dfb $7d + dfb ',' + dfb "[" + dfb $fb + dfb $fc + dfb $fd + dfb "," + +end rts diff --git a/SourceGen/SGTestData/Source/20022-operand-formats.S b/SourceGen/SGTestData/Source/20022-operand-formats.S index c8eba10..dede49a 100644 --- a/SourceGen/SGTestData/Source/20022-operand-formats.S +++ b/SourceGen/SGTestData/Source/20022-operand-formats.S @@ -1,97 +1,40 @@ ; Copyright 2018 faddenSoft. All Rights Reserved. ; See the LICENSE.txt file for distribution terms (Apache 2.0). ; +; Extended tests for 65816. +; ; Assembler: Merlin 32 org $1000 -; 65816 with short regs +; 65816 with long regs clc xce - sep #$30 - mx %11 - -; Basic operand formats. Show first set as hex, second as decimal, -; third as binary. - lda $01 - lda $0102 - ldal $010203 - - lda $01 - lda $0102 - ldal $010203 - - lda $01 - lda $0102 - ldal $010203 - - bra :skipdata - -; Now hex/decimal/binary, 1-2-3-4 bytes, in data area. - hex 01010201020301020304 - hex 01010201020301020304 - hex 01010201020301020304 - -:skipdata - -; Convert these to ASCII; requires editing file. The code generator -; should display some of these as hex. - lda #$68 - lda $68 - lda: $0068 - ldal $000068 - - lda #$1f - lda #$20 - lda #$22 - lda #$27 - lda #$7e - lda #$7f - lda #$80 - lda #$9f - lda #$a0 - lda #$a2 - lda #$a7 - lda #$fe - lda #$ff - -; Switch to long regs, continue with ASCII. rep #$30 mx %00 - lda #$0068 - lda #$00c8 +; hex/dec/sdec/bin + lda #$1234 + lda #$1234 + lda #$1234 + lda #$1234 + + lda #$fffe + lda #$fffe + lda #$fffe + lda #$fffe + + ldal $fffefd + ldal $fffefd + ldal $fffefd + ldal $fffefd + +; ASCII + lda #$0068 ;'h' + lda #$00c8 ;"h" lda #$6868 + ldal $000068 ;'h' + ldal $0000c8 ;"h" + rts - -; Continuing with ASCII -:ascii - dfb $68 - dfb $80 - dw $6868 - dfb $80 - - -; Format first set as address, second set as symbol. - dw :skipdata - adr :skipdata - dfb >:skipdata,:skipdata ;format as big-endian address - - dfb :ascii - dfb >:ascii - dw :ascii - adr :ascii - dfb >:ascii,:ascii ;format as big-endian symbol - -; Merlin 1.0 has trouble with "DFB '{'". - dfb '[' - dfb $7b - dfb $7c - dfb $7d - dfb ',' - dfb "[" - dfb $fb - dfb $fc - dfb $fd - dfb ","