0001 f800 org $f800 0002 0003 start 0004 f800 8e 00 ff lds #$00ff 0005 0006 f803 cc 56 78 ldad #$5678 * least significant word 0007 f806 37 pshb 0008 f807 36 psha 0009 f808 cc 12 34 ldad #$1234 * most significant word 0010 f80b 37 pshb 0011 f80c 36 psha 0012 0013 f80d cc de f0 ldad #$def0 * least significant word 0014 f810 37 pshb 0015 f811 36 psha 0016 f812 cc 9a bc ldad #$9abc * and most 0017 f815 37 pshb 0018 f816 36 psha 0019 0020 f817 bd f8 24 jsr add32 * do the add 0021 f81a 32 pula * uncover the result 0022 f81b 32 pula 0023 f81c 32 pula 0024 f81d 32 pula 0025 0026 f81e 32 pula * then get the result into regs 0027 f81f 33 pulb * 12345678 + 0028 f820 38 pulx * 9abcdef0 = 0029 * acf13568 0030 0031 0032 f821 7e f8 21 loop jmp loop 0033 0034 0035 * add two 32 bit quantities which were passed on the stack. 0036 * the additions are done one byte at the time and the first 0037 * argument is overwritten with the result. 0038 0039 * on entry, the stack looks like this: 0040 0041 * a[0] <--- sp+10 <--- x+9 0042 * a[1] <--- sp+9 0043 * a[2] <--- sp+8 0044 * a[3] <--- sp+7 0045 * b[0] <--- sp+6 0046 * b[1] <--- sp+5 0047 * b[2] <--- sp+4 0048 * b[3] <--- sp+3 0049 * return_address_low <--- sp+2 0050 * return_address_high <--- sp+1 <--- x 0051 * <--- sp 0052 0053 * just before exit, it looks like this: 0054 * a[0]+b[0] <--- sp+10 0055 * a[1]+b[1] <--- sp+9 0056 * a[2]+b[2] <--- sp+8 0057 * a[3]+b[3] <--- sp+7 0058 * b[0] <--- sp+6 0059 * b[1] <--- sp+5 0060 * b[2] <--- sp+4 0061 * b[3] <--- sp+3 0062 * return_address_low <--- sp+2 0063 * return_address_high <--- sp+1 <--- x 0064 * <--- sp 0065 add32: 0066 f824 ce 00 00 ldx #0 0067 f827 30 tsx 0068 f828 18 ce 00 04 ldy #4 0069 f82c 0c clc 0070 addloop: 0071 f82d a6 09 lda 9,x 0072 f82f a9 05 adca 5,x 0073 f831 a7 09 sta 9,x 0074 f833 09 dex 0075 f834 18 09 dey 0076 f836 26 f5 bne addloop 0077 0078 f838 39 rts 0079 0080 fffe org $fffe 0081 fffe f8 00 fdb start