; Assembler emulator of future mcpu-cc MODEL output. ; ; The lifecycle shape is a compact pendulum-style MODEL regression fixture. ; INIT snapshots CONTROL ; into DATA, LIFE advances one model step and publishes one TRACE frame, and ; fini() marks graceful model finalization. ; ; This reduced fixture tests the HLL MODEL/CRT protocol, not RK4 numerics. .global init .global life .global fini .control .align 8 control_n: .integer 64, 3 control_error_step: .integer 64, 0 .data .align 8 model_n: .integer 64, 0 model_error_step: .integer 64, 0 model_step: .integer 64, 0 model_fini_marker: .integer 64, 0 .trace .align 8 trace_step: .integer 64, 0 .text ; int32 init(int64 argc, PTR64 argv) init: LDI r64@0x70200, 2 ICMP r64@0x70000, r64@0x70200 JNZ .L_init_bad_order ; The test invokes the MODEL without extra arguments. LDSP r64@0x70208, 8 LDI r64@0x70210, 1 ICMP r64@0x70208, r64@0x70210 JNZ .L_init_bad_args ; Negative CONTROL.n deliberately requests an init failure. LEA r64@0x70218, control_n LOADP r64@0x70220, r64@0x70218 CLR r64@0x70228 ICMP r64@0x70220, r64@0x70228 JS .L_init_fail STORE model_n, r64@0x70220 LEA r64@0x70218, control_error_step LOADP r64@0x70230, r64@0x70218 STORE model_error_step, r64@0x70230 CLR r64@0x70238 STORE model_step, r64@0x70238 STORE model_fini_marker, r64@0x70238 LDI r64@0x70000, 3 CLR r32@0x7fffc RET .L_init_fail: LDI r64@0x70000, 3 LDI r32@0x7fffc, 17 RET .L_init_bad_order: LDI r64@0x70000, 910 LDI r32@0x7fffc, 18 RET .L_init_bad_args: LDI r64@0x70000, 911 LDI r32@0x7fffc, 19 RET ; int32 life(void) life: LOAD r64@0x70300, model_step LDI r64@0x70308, 1 IADD r64@0x70300, r64@0x70300, r64@0x70308 STORE model_step, r64@0x70300 ; Optional positive LIFE error requested by CONTROL.error_step. LOAD r64@0x70310, model_error_step CLR r64@0x70318 ICMP r64@0x70310, r64@0x70318 JZ .L_no_life_error ICMP r64@0x70300, r64@0x70310 JNZ .L_no_life_error LDI r32@0x7fffc, 9 RET .L_no_life_error: ; Pendulum-style sequential stop: step == n + 1 means natural end. LOAD r64@0x70320, model_n IADD r64@0x70328, r64@0x70320, r64@0x70308 ICMP r64@0x70300, r64@0x70328 JZ .L_life_end LEA r64@0x70330, trace_step STOREP r64@0x70330, r64@0x70300 ; LIFE_CONTINUE == INT32_MIN. LDI r32@0x7fffc, -2147483648 RET .L_life_end: CLR r32@0x7fffc RET fini: LDI r64@0x70200, 3 ICMP r64@0x70000, r64@0x70200 JNZ .L_model_fini_bad LDI r64@0x70000, 4 LDI r64@0x70208, 1 STORE model_fini_marker, r64@0x70208 MOV r64@0x70010, r64@0x70208 RET .L_model_fini_bad: LDI r64@0x70000, 912 RET