Skip to content

Commit 44e2db2

Browse files
committed
Added offset calculation in to_signal expression.
1 parent 4915ed1 commit 44e2db2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/codegen/c-sigprinter.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <stdlib.h>
12
#include "c-sigprinter.h"
23

34
// work buffer for all snprintf operations
@@ -176,7 +177,6 @@ std::string CSigPrinter::PrintSignalExpr(SignalDescriptor_t* sig,
176177
snprintf(workbuff, WBUFF_LEN, "(%s(_d[%d] & (%s)) << %d)", t64.c_str(), bn, msk[8].c_str(), slen);
177178
tosigexpr += workbuff;
178179

179-
180180
snprintf(workbuff, WBUFF_LEN, "((_m->%s >> %d) & (%s))", sig->Name.c_str(), slen, msk[8].c_str());
181181
AppendToByteLine(to_bytes[bn], workbuff);
182182
}
@@ -195,6 +195,17 @@ std::string CSigPrinter::PrintSignalExpr(SignalDescriptor_t* sig,
195195
}
196196
}
197197

198+
if (sig->Offset < 0)
199+
{
200+
snprintf(workbuff, WBUFF_LEN, "(%s) - %d", tosigexpr.c_str(), abs(sig->RawOffset));
201+
tosigexpr = workbuff;
202+
}
203+
else if (sig->Offset > 0)
204+
{
205+
snprintf(workbuff, WBUFF_LEN, "(%s) + %d", tosigexpr.c_str(), abs(sig->RawOffset));
206+
tosigexpr = workbuff;
207+
}
208+
198209
return tosigexpr;
199210
}
200211

@@ -210,4 +221,4 @@ void CSigPrinter::AppendToByteLine(std::string& expr, std::string str)
210221
// First appending
211222
expr = str;
212223
}
213-
}
224+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy