Your program — Lesson 1 of 5
; A traditional procedural program
; ─────────────────────────────────────────────────────
; DR1 holds A, DR2 holds B, result goes into DR1.
IADD DR1, DR1, #12 ; A = 12
IADD DR2, DR2, #30 ; B = 30
IADD DR1, DR1, DR2 ; A + B → DR1 = 42
HALT ; done — result is in DR1
; The programmer adds new capability defined objects using Pet Names
; ─────────────────────────────────────────────────────
; DR1 holds A, DR2 holds B, result goes into DR1.
abstraction MyCode {
capabilities {
myScratchPad RW
}
}
LOAD myScratchPad ; load local memory capability
IADD DR1, DR1, #12 ; A = 12
IADD DR2, DR2, #30 ; B = 30
IADD DR1, DR1, DR2 ; A + B → DR1 = 42
SDATA myScratchPad, #0, DR1 ; save result → myScratchPad[0]
RETURN ; return to caller
; Abstractions are saved as binary LUMPs
; ─────────────────────────────────────────────────────
; Lumps combine code and capabilities into a single
; Lazy-Load namespace object
abstraction MyCode {
capabilities {
sliderule E
}
method add {
IADD DR1, DR1, #12 ; A = 12
IADD DR2, DR2, #30 ; B = 30
Result = SlideRule (A + B) ; A + B → DR1 = 42
RETURN Result ; return to caller
}
}
0 · Start from an existing abstraction (optional)
1 · Your Idea
2 · Its Functions
Use › Step to walk through each instruction.
IDLE
PC —
DR0 —
DR1 —
DR2 —
DR3 —
Output