//sum of 1 ~ A
cseg
sum_A: mov R0, A //R0 = A
clr A //A = 0
add A, R0 //A = A + R0
dec R0 //R0 = R0 - 1
sz R0 //if R0 == 0 then skip next instruction end
jmp sum_A + 2
ret
//sum of 1 ~ A
cseg
sum_A: clr R0 //R0 = 0
add R0, A //R0 = R0 + A
dec R0 //R0 = R0 - 1
sz A, R0 //A = R0; if R0 == 0 then skip next instruction end
jmp sum_A + 1
ret