Skip to content

Commit f4b5044

Browse files
timsherwoodclaude
andcommitted
Add two-pass assembly and require explicit ISA specification
- Implement two-pass assembly for forward label references - Require .isa directive or --isa flag (remove heuristic detection) - Add pseudo-instruction expansion for MIPS (blt, bge, ble, bgt) - Add pseudo-branch handling for RISC-V (ble, bgt, bleu, bgtu, etc.) - Fix x86-64 AT&T syntax (movslq, decq, incq, SIB addressing) - Fix ARM64 comment parsing for negative immediates (#-32) - Collect labels from all sections (not just standard ones) - Add .bss stack sections to RISC-V fibonacci/matrix examples - Add .isa directive to all 20 example programs - Add tests for ISA specification and forward references Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 25d95a3 commit f4b5044

25 files changed

Lines changed: 1246 additions & 50 deletions

File tree

examples/arm/array_stats/array_stats.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# 5. Conditional branches (b.lt, b.gt, b.eq)
1111
#
1212
# ============================================================================
13+
.isa arm64
14+
1315

1416
.data
1517

examples/arm/fibonacci/fibonacci.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# - Base case and recursive case handling
1616
# - Register save/restore conventions
1717
# ============================================================================
18+
.isa arm64
19+
1820

1921
.section .data
2022
# Input value: calculate Fibonacci(7)

examples/arm/guess_game/guess_game.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# guess is too high or too low.
1313
#
1414
# ============================================================================
15+
.isa arm64
16+
1517

1618
.data
1719

examples/arm/hello_asm/hello_asm.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# (mapachespim) run
1515
#
1616
# ============================================================================
17+
.isa arm64
18+
1719

1820
# ----------------------------------------------------------------------------
1921
# DATA SECTION

examples/arm/matrix_multiply/matrix_mult.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# - Register allocation and management
1414
# - ARM64 calling convention
1515
# ============================================================================
16+
.isa arm64
17+
1618

1719
.section .data
1820
# Matrix A (3x3) - stored in row-major order

examples/mips/array_stats/array_stats.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# 5. Conditional jumps (blt, bgt, beq)
1111
#
1212
# ============================================================================
13+
.isa mips32
14+
1315

1416
.data
1517

examples/mips/fibonacci/fibonacci.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# - Base case and recursive case handling
1616
# - Callee-saved register preservation ($s0-$s7)
1717
# ============================================================================
18+
.isa mips32
19+
1820

1921
.section .data
2022
# Input value: calculate Fibonacci(7)

examples/mips/guess_game/guess_game.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# guess is too high or too low.
1313
#
1414
# ============================================================================
15+
.isa mips32
16+
1517

1618
.data
1719

examples/mips/hello_asm/hello_asm.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# (mapachespim) run
1515
#
1616
# ============================================================================
17+
.isa mips32
18+
1719

1820
# ----------------------------------------------------------------------------
1921
# DATA SECTION

examples/mips/matrix_multiply/matrix_mult.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# - Register allocation and management
1414
# - MIPS calling convention
1515
# ============================================================================
16+
.isa mips32
17+
1618

1719
.section .data
1820
# Matrix A (3x3) - stored in row-major order

0 commit comments

Comments
 (0)