Write a program for subtractions, addition, and multiplication of two 8 bit and 16 bit numbers in assembly language in direct, immidiate, register,indirect, register mode. - Codeprg

Breaking

programing News Travel Computer Engineering Science Blogging Earning

Friday, 8 May 2020

Write a program for subtractions, addition, and multiplication of two 8 bit and 16 bit numbers in assembly language in direct, immidiate, register,indirect, register mode.

;IMMEDIATE ADDRESSING MODE
;ADDITION 8BIT
;mov a,#5H
;mov r0,#5H
;add a,r0

;SUBSTRACTION 8BIT
;MOV A,#64H
;MOV R0,#34H
;SUBB A, R0

ADDITION OF 16BITS
MOV A,#020H
ADD A,#0DEH
MOV R0,A
MOV A,#65H
ADDC A,#0ABH
MOV R1,A
END

;SUBSTRACTION OF 16BITS
;MOV A,#0DEH
;SUBB A,#020H
;MOV R0,A
;MOV A,#0ABH
;SUBB A,#065H
;MOV R1,A
;END

;DIRECT ADDRESSING MODE
;ADDITION OF 8BITS
;MOV R1,#23H
;MOV R2,#21H
;MOV A,R1
;ADD A,R2
END

;SUBSTRACTION OF 8 BIT
;MOV R1,#0A3H
;MOV R2,#89H
;MOV A,R1
;SUBB A,R2
END

;ADDITION OF 16BITS
;MOV R1,#0ABH
;MOV R2,#012H
;MOV R3,#026H
;MOV R4,#78H
;MOV A,R1
;ADD A,R3
;MOV R6,A
;MOV A,R2
;ADDC A,R4
;MOV R7,A
END

;SUBSTRACTION OF 16BITS
;MOV R1,#0ABH
;MOV R2,#012H
;MOV R3,#026H
;MOV R4,#78H
;MOV A,R2
;SUBB A,R4
;MOV R6,A
;MOV A,R1
;ADDC A,R3
;MOV R7,A
END

;INDIRECT ADDRESING MODE
;ADDITION OF 8BITS
;MOV A,23H
;ADD A,24H
END

;SUBSTRACTION OF 8BITS
;MOV A,23H
;SUBB A,24H
END

;ADDITION OF 16BITS
;MOV A,23H
;ADD A,25H
;MOV R6,A
;MOV A,22H
;ADDC A,24H
;MOV R7,A

;SUBSTRACTION OF 16BITS
;MOV A,23H
;SUBB A,25H
;MOV R6,A
;MOV A,22H
;SUBB A,24H
;MOV R7,A
END

;RESITER INDIRECT 
;ADDITION  OF 8BITS
MOV R1,23H
MOV R2,24H
MOV A,R1
ADD A,R2
END

;SUSTRACTION O 8BITS
MOV R1,23H
MOV R2,24H
MOV A,R1
SUBB A,R2
END

;ADDITION OF 16 BITS
MOV R1,23H
MOV R2,25H
MOV A,R1
ADD A,R2
MOV R6,A
MOV R3,22H
MOV R4,24H
MOV A,R3
ADDC A,R4
MOV R7,A
END;

;SUBSTRACTION OF 16BITS
MOV R1,23H
MOV R2,25H
MOV A,R1
SUBB A,R2
MOV R6,A
MOV R3,22H
END

MOV R4,24H
MOV A,R3
SUBB A,R4
MOV R7,A
END

MULTIPLE 8 BIT 

       MOV R0, #20H;set source address 20H to R0
        MOV R1, #30H;set destination address 30H to R1

        MOV A, @R0;take the first operand from source to register A
        INC R0; Point to the next location
        MOV B,@R0;take the second operand from source to register B

        MUL AB ;Multiply A and B

        MOV @R1, B; Store higher order byte to 30H
        INC R1; Increase R1 to point to the next location
        MOV @R1, A;Store lower order byte to 31H