@@ -69,8 +69,8 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
6969 const char *Modifier) {
7070 const MCOperand &Base = MI->getOperand (OpNo);
7171 const MCOperand &Disp = MI->getOperand (OpNo+1 );
72-
73- // Print displacement first
72+ assert (Disp. isImm () ||
73+ Disp. isExpr () && " Unexpected type in displacement field " );
7474
7575 // If the global address expression is a part of displacement field with a
7676 // register base, we should not emit any prefix symbol here, e.g.
@@ -81,17 +81,26 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
8181 if (Base.getReg () == MSP430::SR)
8282 O << ' &' ;
8383
84+ if (Base.getReg () == MSP430::SR || Base.getReg () == MSP430::PC) {
85+ if (Disp.isExpr ())
86+ Disp.getExpr ()->print (O, &MAI);
87+ else
88+ O << Disp.getImm ();
89+ return ;
90+ }
91+
92+ // Print 0(Rn) as @Rn
93+ if (Disp.isImm () && Disp.getImm () == 0 ) {
94+ O << ' @' << getRegisterName (Base.getReg ());
95+ return ;
96+ }
97+
8498 if (Disp.isExpr ())
8599 Disp.getExpr ()->print (O, &MAI);
86- else {
87- assert (Disp.isImm () && " Expected immediate in displacement field" );
100+ else
88101 O << Disp.getImm ();
89- }
90102
91- // Print register base field
92- if ((Base.getReg () != MSP430::SR) &&
93- (Base.getReg () != MSP430::PC))
94- O << ' (' << getRegisterName (Base.getReg ()) << ' )' ;
103+ O << ' (' << getRegisterName (Base.getReg ()) << ' )' ;
95104}
96105
97106void MSP430InstPrinter::printIndRegOperand (const MCInst *MI, unsigned OpNo,
0 commit comments