DIVISION
;RESULT AND REMINDER STORED AT R12 & R11 RESPECTIVELY
.INCLUDE “msp430x2xx.inc”
ORG 0xf800
MOV #(WDTPW|WDTHOLD), &WDTCTL
CLR R12
MOV #25,R11 ;NUMBER TO BE DIVIDED(25)
MOV #7,R13 ;DIVIDER(7)
L1: CMP R13,R11
JL L3
INC R12
SUB R13,R11
JMP L1
L3: JMP L3
ORG 0xfffe
DW 0xF800
DIVISION USING FUNCTION CALLING
;RESULT AND REMINDER STORED AT R12 & R11 RESPECTIVELY
.INCLUDE “msp430x2xx.inc”
ORG 0xf800
MOV #(WDTPW|WDTHOLD), &WDTCTL
CLR R12
MOV #25,R11 ;NUMBER TO BE DIVIDED(25)
MOV #7,R13 ;DIVIDER(7)
CALL #DIVISION
DIVISION:
CMP R13,R11
JL L3
INC R12
SUB R13,R11
JMP DIVISION
RET
L3: JMP L3
ORG 0xfffe
DW 0xF800
MULTIPLICATION
;RESULT STORED AT R15
.INCLUDE “msp430x2xx.inc”
ORG 0xf800
MOV #(WDTPW|WDTHOLD), &WDTCTL
CLR R13
MOV #5,R15 ;1st NUMBER
MOV #6,R14 ;2nd NUMBER
TST R14 ;TESTING FOR 0
JZ L2
TST R15
JZ L2
L1: ADD R15,R13
DEC R14
TST R14
JZ L2
JMP L1
L2: JMP L2
ORG 0xfffe
DW 0xF800
MULTIPLICATION FASTER
;RESULT STORED AT R13
.INCLUDE “msp430x2xx.inc”
ORG 0xf800
MOV #(WDTPW|WDTHOLD), &WDTCTL
CLR R13
MOV #1,R15 ;1st NUMBER
MOV #8,R14 ;2nd NUMBER
CMP R15,R14
JGE L1
TST R14
JZ L2
MOV R15,R13
L5: DEC R14
TST R14
JZ L2
ADD R15,R13
JMP L5
L1: TST R15
JZ L2
MOV R14,R13
L3: DEC R15
TST R15
JZ L2
ADD R14,R13
JMP L3
L2: JMP L2
ORG 0xfffe
DW 0xF800
MULTIPLICATION USING FUNCTION CALLING
;RESULT STORED AT R13
.INCLUDE “msp430x2xx.inc”
ORG 0xf800
MOV #(WDTPW|WDTHOLD), &WDTCTL
CLR R13
MOV #0,R15 ;1st NUMBER
MOV #0,R14 ;2nd NUMBER
CALL #MUX
L2: JMP L2
MUX: TST R14 ;TESTING FOR 0
JZ L2
TST R15
JZ L2
L1: ADD R15,R13
DEC R14
TST R14
JZ L2
JMP L1
ORG 0xfffe
DW 0xF800