ret¶
ret #K¶
指令格式¶
ret #K
影响标志¶
无
伪指令¶
1 | return and A = K |
指令描述¶
子程序返回,同时将立即数K存入累加器A;
范例¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /** * 测试A中为1的bit的数量是否为偶数: * 偶数return 1 * 奇数return 0 */ cseg f_is_bits_even_A: bset R0, 0 //R0[0] = 1 snz A //if A != 0 then skip next instruction end jmp end sbz A, 0 //if A[0] == 0 then skip next instruction end bcpl R0, 0 //R0[0] = ~R0[0] rsh A //A = A >> 1 jmp f_is_bits_even_A + 1 end: sbz R0, 0 //if R0[0] == 0 then skip next instruction end ret #1 //return 1 ret #0 //return 0 |