MSP430 Time Machine

G2553 · 512 B RAM · 16 KB flash
made with yaks.app
10/s
step 0 / 0 0 cycles 0 µs @ 1 MHz
Ready

Source

CPU

16 registers × 16 bits
MSP430 G2553 P1.0 P1.6 P2.7 … P2.0 RESET S2·P1.3 LaunchPad

Just happened

RAM

512 bytes · 0x0200–0x03FF

Click a byte (or a register) to inspect it and jump to the moment it last changed.

Peripherals

memory-mapped at 0x0000–0x01FF

Save program

Share this program

Creating a link stores this program (its name, code and speed) here, so anyone with the link can open it: no account needed. They get their own copy to run, rewind and change, and can share their version the same way.

The MSP430 Time Machine

A simulation of the MSP430G2553, the chip on TI's LaunchPad: a 16-bit CPU with 16 registers, 512 bytes of RAM and 16 KB of flash. Every instruction you run is recorded, so you can step backwards, scrub the timeline, and find the exact moment any byte changed.

Getting around

→step one instruction←step back in time
Spacerun / pauseShift→step over a CALL
Home Endstart / end of historyCtrl⏎assemble & restart
B (hold)press button S2gutter clicktoggle a breakpoint

Drag the timeline to travel; scroll on it to zoom. Its green dots are the program counter over time, so loops show up as patterns and calls as jumps between labels. The red and green lanes underneath are the LEDs. Click any RAM byte to see who wrote it last, jump there, or set a watch that pauses the moment it changes. Double-click a byte or register to change its value.

Sharing

Share ↗ stores your program and gives you a short link to it, no account needed. Whoever opens it gets their own copy to run, rewind and change, and can share their version the same way. Anyone who has the link can open a shared program. As you edit, the address bar also keeps your work, so reloading never loses it.

Addressing modes

Every source operand uses one of seven modes. Destinations can use the first four.

WriteModeMeansExtra word?
R5registerthe value in R5no
4(R5)indexedmemory at R5 + 4yes (the 4)
totalsymbolicmemory at a label, stored relative to the PCyes
&P1OUTabsolutememory at a fixed addressyes
@R5indirectmemory at the address in R5no
@R5+auto-incrementthe same, then R5 += 2 (or 1 for .b)no
#42immediatethe number itselfyes, unless it's 0, 1, 2, 4, 8 or −1

The constant generator (R2 and R3) supplies 0, 1, 2, 4, 8 and −1 for free, which is why inc, clr and friends are only 2 bytes.

The 27 instructions

Two operandsmov add addc sub subc cmp dadd bit bic bis xor and
One operandrrc rra swpb sxt push call reti
Jumps (±1 KB)jmp jeq/jz jne/jnz jc/jhs jnc/jlo jn jge jl
Emulatednop ret pop br clr inc incd dec decd tst inv rla rlc adc sbc dadc setc clrc setz clrz setn clrn eint dint — names for one of the above (the “Up next” card shows which)

Add .b to work on a byte; .w (or nothing) works on a 16-bit word.

Memory map

0x0000–0x000Fspecial function registers (IE1, IFG1…)
0x0010–0x01FFperipheral registers: ports, Timer_A, watchdog…
0x0200–0x03FFRAM — variables at the bottom, the stack grows down from the top
0x1000–0x10FFinformation flash (calibration constants)
0xC000–0xFFDFflash: your program
0xFFE0–0xFFFFinterrupt vectors; 0xFFFE holds the reset address

Assembler

TI (Code Composer) syntax: labels in column 1 or ending in :, comments after ;. The msp430g2553.h names (P1OUT, BIT3, WDTPW, TASSEL_1, LPM3, GIE…) are always defined. Directives: .text .data .bss .sect .org .word .byte .string .cstring .space .align .equ. $ is the current address, so jmp $ stops. Put the start address in the reset vector with .sect ".reset" / .short RESET (if you don't, it starts at 0xC000). Numbers: 42, 0x2A, 2Ah, 0b101010, '*'.

What's simulated

The full CPU (every instruction, addressing mode, flag and cycle count), ports P1 and P2 with the LaunchPad's LEDs and buttons, pin interrupts, Timer0_A3 (up, continuous and up/down modes, CCR0–2 and TAIV), the watchdog (including the reset when you forget it), low-power modes, and resets. MCLK and SMCLK run at 1 MHz, ACLK at 32,768 Hz. Not simulated: the second timer, serial, ADC, comparator, flash writes and clock configuration. For convenience SP starts at 0x0400 and .data is preloaded into RAM; on a real chip your startup code does both.