org $f800 start lds #$00ff ldad #$5678 * least significant word pshb psha ldad #$1234 * most significant word pshb psha ldad #$def0 * least significant word pshb psha ldad #$9abc * and most pshb psha jsr add32 * do the add pula * uncover the result pula pula pula pula * then get the result into regs pulb * 12345678 + pulx * 9abcdef0 = * acf13568 loop jmp loop * add two 32 bit quantities which were passed on the stack. * the additions are done one byte at the time and the first * argument is overwritten with the result. * on entry, the stack looks like this: * a[0] <--- sp+10 <--- x+9 * a[1] <--- sp+9 * a[2] <--- sp+8 * a[3] <--- sp+7 * b[0] <--- sp+6 * b[1] <--- sp+5 * b[2] <--- sp+4 * b[3] <--- sp+3 * return_address_low <--- sp+2 * return_address_high <--- sp+1 <--- x * <--- sp * just before exit, it looks like this: * a[0]+b[0] <--- sp+10 * a[1]+b[1] <--- sp+9 * a[2]+b[2] <--- sp+8 * a[3]+b[3] <--- sp+7 * b[0] <--- sp+6 * b[1] <--- sp+5 * b[2] <--- sp+4 * b[3] <--- sp+3 * return_address_low <--- sp+2 * return_address_high <--- sp+1 <--- x * <--- sp add32: ldx #0 tsx ldy #4 clc addloop: lda 9,x adca 5,x sta 9,x dex dey bne addloop rts org $fffe fdb start