6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon Sep 30, 2024 12:42 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Nov 02, 2019 7:46 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
Addition and subtraction are easy enough. Work from the least significant byte to the most.
Code:
; C = A + B
clc
lda a0
adc b0
sta c0
lda a1
adc b1
sta c1
lda a2
adc b2
sta c2
lda a3
adc b3
sta c3

; C = A - B
sec
lda a0
sbc b0
sta c0
lda a1
sbc b1
sta c1
lda a2
sbc b2
sta c2
lda a3
sbc b3
sta c3

Check the code library for multiply and divide algorithms.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 02, 2019 11:44 pm 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
It really is the same as working out sums by hand - only the "digits" count up to 255 instead of only to 9.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: dmsc and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: