home *** CD-ROM | disk | FTP | other *** search
/ A.N.A.L.O.G. Magazine 1989 December / 89_dec.atr / asmed.src < prev    next >
Text File  |  2023-02-26  |  2KB  |  1 lines

  1. 0 ;LIST#D:MYUSR.ASM¢10 ;ASM ,,#D:MYUSR.OBJ¢11 SUM = $D4¢12 NUM1 =$E0¢13 NUM2 = $E2¢20  *=1536       ; Assemble for PAGE 6.¢30 ADDTHEM PLA   ; First off the stack is parameter count.¢40  BEQ ERROR    ; Always check for no parameters ERROR.¢50  CMP #2       ; Did we get exactly 2 parameters?¢60  BEQ AOK¢70  TAX          ; No, clean up stack and return safely.¢80 CLEANUP PLA   ; Two bytes per parameter.¢90  PLA¢100  DEX         ; Get all the parameters off?¢110  BNE CLEANUP ; when all gone, just the valid return addr¢120 ERROR RTS    ; is at the top of the stack for the RTS.¢130 ; We have valid input, compute the sum.¢140 ; The first parameter in the USR call (after the addr)¢150 ; is the first parameter off the stack, high-byte¢160 ; low-byte sequence. REMEMBER this!¢170 AOK PLA      ; GetNUM1, high byte¢180  STA NUM1+1¢190  PLA         ; Get NUM1, low byte¢200  STA NUM1¢210  PLA         ; Get NUM2, high byte¢220  STA NUM2+1¢230  PLA         ; Get NUM2, low byte¢240  STA NUM2¢250 ; Now we have the data in temporary storage¢260 ; and the stack is cleared of parameters.¢270 ; Just the return address (to get us back to BASIC)¢280 ; is at the top of the stack, which gets pulled off¢290 ; into the program counter automatically by the RTS¢300 ; instruction.¢310  CLC         ; Must clear the carry flag first.¢320  LDA NUM1    ; Low byte of first integer to add.¢330  ADC NUM2    ; Add to low byte of second integer.¢340  STA SUM     ; And store in low byte of their SUM.¢350  LDA NUM1+1  ; Now add high bytes, leave carry alone.¢360  ADC NUM2+1  ; It "carries over" from previous add.¢370  STA SUM+1   ; And their summation is complete.¢380  RTS         ; Back to BASIC¢