Write a simple assembly program for single byte arithmetic operations

 ; Single byte addition

ORG 0H ; Set the origin address


MOV A, #5 ; Load first operand into accumulator

ADD A, #3 ; Add second operand to accumulator


; Result is now in accumulator (A)


END


; Single byte subtraction

ORG 0H ; Set the origin address


MOV A, #8 ; Load minuend into accumulator

SUBB A, #3 ; Subtract subtrahend from accumulator


; Result is now in accumulator (A)


END


; Single byte multiplication 

ORG 0H ; Set the origin address


MOV A, #5 ; Load first operand into accumulator

MOV B, #3 ; Load second operand into register B

MUL AB ; Multiply A and B, result in A


; Result is now in accumulator (A)


END


; Single byte division 

ORG 0H ; Set the origin address


MOV A, #15 ; Load dividend into accumulator

MOV B, #3 ; Load divisor into register B

DIV AB ; Divide A by B, quotient in A, remainder in B


; Quotient is in accumulator (A), remainder is in B


END


Comments