@@ -97,7 +97,10 @@ function formatAddress(
9797 value : string ,
9898 specials : readonly string [ ] ,
9999 hadSizePrefix : boolean ,
100- skipNegative : boolean ,
100+ // Main path: preserve the original negative decimal instead of converting to hex.
101+ keepNegativeDecimal : boolean ,
102+ // Main path right operand only: leave a leading "-" alone instead of padding it.
103+ skipNegativePad : boolean ,
101104) : string {
102105 if ( ! value ) return value ;
103106
@@ -108,8 +111,7 @@ function formatAddress(
108111 ! value . startsWith ( "0x" )
109112 ) {
110113 const num = parseInt ( value , 10 ) ;
111- // Main path refuses to reformat negatives; recall/variable convert and pad through the sign.
112- if ( ! Number . isNaN ( num ) && ( num >= 0 || ! skipNegative ) ) {
114+ if ( ! Number . isNaN ( num ) && ( num >= 0 || ! keepNegativeDecimal ) ) {
113115 value = num . toString ( 16 ) ;
114116 }
115117 }
@@ -121,7 +123,7 @@ function formatAddress(
121123 if ( specials . includes ( value ) || value . includes ( "." ) ) {
122124 return value ;
123125 }
124- if ( skipNegative && value . startsWith ( "-" ) ) {
126+ if ( skipNegativePad && value . startsWith ( "-" ) ) {
125127 return value ;
126128 }
127129
@@ -201,7 +203,7 @@ function parseRecallOperand(operand: string): {
201203 type = size !== "" ? "m" : "v" ;
202204 }
203205
204- value = formatAddress ( value , RECALL_SPECIAL_CONSTANTS , size !== "" , false ) ;
206+ value = formatAddress ( value , RECALL_SPECIAL_CONSTANTS , size !== "" , false , false ) ;
205207
206208 return { type : type as MemType , size, value } ;
207209}
@@ -298,7 +300,7 @@ function parseVariableRightOperand(operand: string): {
298300 }
299301
300302 if ( ! value . includes ( "." ) ) {
301- value = formatAddress ( value , RECALL_SPECIAL_CONSTANTS , size !== "" , false ) ;
303+ value = formatAddress ( value , RECALL_SPECIAL_CONSTANTS , size !== "" , false , false ) ;
302304 }
303305
304306 return { type : type as MemType , size : size as MemSize , value } ;
@@ -446,8 +448,8 @@ function parseRequirement(req: string): ParsedRequirement | null {
446448 lMemory = lMemory . substring ( 1 ) ;
447449 }
448450
449- lMemory = formatAddress ( lMemory , MAIN_SPECIAL_CONSTANTS , lSize !== "" , false ) ;
450- rMemVal = formatAddress ( rMemVal , MAIN_SPECIAL_CONSTANTS , rSize !== "" , true ) ;
451+ lMemory = formatAddress ( lMemory , MAIN_SPECIAL_CONSTANTS , lSize !== "" , true , false ) ;
452+ rMemVal = formatAddress ( rMemVal , MAIN_SPECIAL_CONSTANTS , rSize !== "" , true , true ) ;
451453
452454 const isKnownLType = [ "d" , "p" , "b" , "v" , "~" , "f" , "recall" ] . includes ( lType ) ;
453455 if ( ! isKnownLType ) {
0 commit comments