Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .include "m2560def.inc"
- .def num1 = r25
- .def num2 = r23
- .def highreg = r24
- .def minusreg = r21
- .def temp1 = r22
- .cseg
- init:
- main:
- //addition
- ldi num1,0x49
- ldi r16,0x03
- sts 0x0203,r16
- ldi highreg,0x00
- lds num2,0x0203
- mov temp1,num1
- add num1,num2
- ldi r16,0x06
- add num1,r16
- brhc HFLAGCLEAR
- CHECKOVERFLOW:
- add temp1,num2
- ldi r16,0x76
- add temp1,r16
- brcs ADDHIGHREG
- //subtraction
- SUBTRACTION:
- ldi num1,0x49
- lds num2,0x0203
- mov temp1,num1
- sub num1,num2
- brhs HFLAGSET
- CHECKMIMUS:
- sub temp1,num2
- brmi ADDMINUS
- rjmp main
- ADDHIGHREG:
- inc highreg
- ldi r16,0x60
- add num1,r16
- rjmp SUBTRACTION
- HFLAGCLEAR:
- subi num1,0x06
- rjmp CHECKOVERFLOW
- HFLAGSET:
- subi num1,0x06
- rjmp CHECKMIMUS
- ADDMINUS:
- bset 0
- ror minusreg
- rjmp main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement