I cannot pass up an opportunity to recommend again the excellent programming manual linked at the top of the page at
http://6502.org/documents/datasheets/wdc/ . Actually though, any 65-family programming manual should cover this. [
Edit, 4/9/15: I was recommending the Liechty & Eyes manual based on my paper copy, not realizing there have been a lot of problems with the .pdf version. WDC just scanned the paper version and OCR'ed it to get rid of all the problems of the previous .pdf version (Where did they get it from??) and they have it on their site now for free download at
http://65xx.com/Products/Programming_an ... e-Manuals/ .)
The processor only deals with 8 bits at a time; but you will have wider numbers in memory. Say you have two 3-byte (ie, 24-bit) variables in memory, and call them VAR_A_L, VAR_A_M, and VAR_A_H, for variable A low, middle, and high bytes, and the same for variable B. To add the two together and leave the result in variable B, you would do:
Code:
CLC
LDA VAR_A_L
ADC VAR_B_L
STA VAR_B_L
LDA VAR_A_M
ADC VAR_B_M
STA VAR_B_M
LDA VAR_A_H
ADC VAR_B_H
STA VAR_B_H
At the end, the 24-bit sum will be in variable B. The carry flag will tell if the three bytes were not enough to hold it all, and the overflow flag will tell if the high bit is valid as a sign byte, if indeed you're using signed numbers. (The addition works the same whether they're signed or not; but the interpretation will be different, depending on the application.)
Subtraction works similarly. This website's source-code repository has routines for multiplication and division, and as you can imagine, you just keep putting together building blocks into higher and higher level program components until you're doing complex math.