.def _test_asm ZZZ .equ 100 ; declare constant (not necessary here, just for example) .ref _x ; refer to global variable x ; two things get passed in: ; A4 = a ; B4 = b ; the code then computes a*x+b and returns the result _test_asm: MVKL .S1 _x, A0 ; here we put the address of the global variable x in B0 MVKH .S1 _x, A0 LDW .D1 *A0, A1 ; the contents of x are stored in A1 now NOP 4 MPYSP .M1 A1,A4,A5 ; A5 = A1*A4 (temp result = a*x) NOP 3 ADDSP .L1 A5,B4,A4 ; final result = (a*x)+b NOP 3 B B3 ; branch back to calling function ; note that function passes back result in A4 NOP 5 .end