// Copyright (c) 2026 Petr Balvín (https://petrbalvin.org) // SPDX-License-Identifier: BSD-3-Clause #include "textflag.h" // add returns a + b. TEXT ·add(SB), NOSPLIT, $0-24 MOVD a+0(FP), R4 MOVD b+8(FP), R5 ADD R5, R4, R4 MOVD R4, ret+16(FP) RET // arith exercises the register-register integer set. TEXT ·arith(SB), NOSPLIT, $0-0 ADD R4, R5, R6 SUB R7, R8, R9 AND R10, R11, R12 ORR R12, R13, R14 EOR R14, R15, R16 CMP R16, R17 ADD R4, R5 SUB R6, R7 RET // branch exercises conditional and unconditional control flow. TEXT ·branch(SB), NOSPLIT, $0-0 BEQ done BNE skip BGE done BLT done BGT done BLE done skip: B loop loop: ADD R4, R5 RET done: RET // mov exercises the MOV pseudo-instruction. TEXT ·mov(SB), NOSPLIT, $0-16 MOVD $0, R4 MOVD $1, R5 MOVD $42, R6 MOVD a+0(FP), R7 MOVD R7, ret+0(FP) MOVW $100, R8 RET // frame exercises the prologue/epilogue of a function with a real frame. TEXT ·frame(SB), NOSPLIT, $32-8 MOVD arg+0(FP), R4 ADD $1, R4, R4 MOVD R4, ret+0(FP) RET