-
Notifications
You must be signed in to change notification settings - Fork 86
Hacks and fixes to enable picolibc CI on MSP430 #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
7b871fc
1c49a3c
8ee0e1c
d81226e
7c9fef5
77d3d4e
e012af1
9c4d9a8
7ebd42b
a4a3277
78ddd21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,13 +160,15 @@ public MSP430Core(int type, ComponentRegistry registry, MSP430Config config) { | |
| @Override | ||
| public int read(int address, AccessMode mode, AccessType type) throws EmulationException { | ||
| if (address >= MAX_MEM) { | ||
| logw(WarningType.EXECUTION, "Read out of bounds"); | ||
| throw new EmulationException("Reading outside memory: 0x" + Utils.hex(address, 4)); | ||
| } | ||
| return memorySegments[address >> 8].read(address, mode, type); | ||
| } | ||
| @Override | ||
| public void write(int address, int data, AccessMode mode) throws EmulationException { | ||
| if (address >= MAX_MEM) { | ||
| logw(WarningType.EXECUTION, "write out of bounds"); | ||
| throw new EmulationException("Writing outside memory: 0x" + Utils.hex(address, 4)); | ||
| } | ||
| memorySegments[address >> 8].write(address, data, mode); | ||
|
|
@@ -454,10 +456,50 @@ public void writeRegister(int r, int value) { | |
| * Yet, this has been observed at least once with msp430-gcc 4.6.3. */ | ||
| System.out.println("Warning: tried to write odd PC, not allowed! PC=0x" + Integer.toHexString(value)); | ||
| value -= 1; | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accidental whitespace change. |
||
|
|
||
| /* SR can never take values above 0xfff */ | ||
| if (r == SR) { | ||
|
|
||
| /* semihosting by trapping and ignoring writes to SR */ | ||
|
|
||
| /* exit (0xf000) */ | ||
| if (value == 0xf000) { | ||
| int code = reg[15]; | ||
| System.exit(code); | ||
| } | ||
|
|
||
| /* putchar (0xf001) */ | ||
| if (value == 0xf001) { | ||
| int data = reg[12]; | ||
| System.out.print((char) data); | ||
| return; | ||
| } | ||
|
|
||
| /* message and value (char *, int) (0xf002) */ | ||
| if (value == 0xf002) { | ||
| int message = reg[12]; | ||
| int data = reg[13]; | ||
| char c; | ||
| System.out.printf("0x%x 0x%x: ", reg[0], message); | ||
| try { | ||
| int off; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the declaration of off can be in the for-header. |
||
| for (off = 0; off < 20 && (c = (char) currentSegment.read(message + off, AccessMode.BYTE, AccessType.READ)) != 0; off++) | ||
| System.out.print(c); | ||
| } catch(Exception e) { | ||
| System.out.printf("Bad message at 0x%x", reg[13]); | ||
| } | ||
| System.out.printf(" 0x%x %d\n", data, data); | ||
| return; | ||
| } | ||
|
|
||
| /* dump registers (0xf003) */ | ||
| if (value == 0xf003) { | ||
| for (int rn = 0; rn < 15; rn++) | ||
| System.out.printf("R%02d: 0x%05x ", rn, reg[rn]); | ||
| System.out.printf("\n"); | ||
| return; | ||
| } | ||
| value &= 0xfff; | ||
| } | ||
|
|
||
|
|
@@ -2027,7 +2069,8 @@ public int emulateOP(long maxCycles) throws EmulationException { | |
| tmpAdd = 1; | ||
| case SUBC: | ||
| // Both sub and subc does one complement (not) + 1 (or carry) | ||
| src = (src ^ 0xffff) & 0xffff; | ||
| int mask = word ? 0xffff : (wordx20 ? 0xfffff : 0xff); | ||
| src = (src ^ mask) & mask; | ||
| case ADDC: // ADDC | ||
| if (op == ADDC || op == SUBC) | ||
| tmpAdd = ((sr & CARRY) > 0) ? 1 : 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,7 +153,19 @@ public void setupNode() { | |
| SerialMon serial = new SerialMon((USARTSource)usart, "USCI A0 Port Output"); | ||
| registry.registerComponent("serialgui", serial); | ||
| } | ||
| } | ||
| } else { | ||
| // Send serial output to stdout | ||
| IOUnit usart = cpu.getIOUnit("USCI A0"); | ||
| if (usart instanceof USARTSource) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can become |
||
| USARTSource usartSource = (USARTSource) usart; | ||
| USARTListener listener = new USARTListener() { | ||
| public void dataReceived(USARTSource source, int data) { | ||
| System.out.print((char) data); | ||
| } | ||
| }; | ||
| usartSource.addUSARTListener(listener); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void setupGUI() { | ||
|
|
@@ -170,4 +182,4 @@ public static void main(String[] args) throws IOException { | |
| config.handleArguments(args); | ||
| node.setupArgs(config); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to initialize this one, 0 is the default value for fields of numeric types.