A. Addition of two 8-bit data
ORG 0000H ; Set the starting address to 0000H
MOV A,30H ; Move the value from memory location 30H into accumulator A
MOV B,31H ; Move the value from memory location 31H into register B
ADD A,B ; Add the contents of register B to the value in accumulator A. Result gets stored in A
MOV 32H,A ; Store the result of the addition (SUM) into memory location 32H
JNC SKIP ; If no carry occurs (CY=0), Jump to the label SKIP
MOV A,#01H ; If carry occurs (CY=1), load the immediate value 01H into accumulator A
SJMP STOP ; Unconditionally jump to the label STOP to terminate further processing
SKIP: MOV A,#00H ; At label SKIP, load the immediate value 00H into accumulator A (no carry case)
STOP: MOV 33H,A ; At label STOP, store the value of CARRY (either 00H or 01H) into memory location 33H
SJMP $ ; Infinite loop to stop program execution
END ; End of the program
EXPERIMENT 3
B. Subtraction of two 8-bit data
ORG 0000H ; Set the starting address to 0000H
MOV A,40H ; Load the value from memory location 40H into accumulator A
MOV B,41H ; Load the value from memory location 41H into register B
CLR C ; Clear the carry flag (ensure no borrow occurs initially)
SUBB A,B ; Subtract the contents of register B from A
MOV 42H,A ; Store the result of the subtraction (DIFFERENCE) into memory location 42H
JNC SKIP ; If no borrow occurs (CY=0), jump to the label SKIP
MOV A,#01H ; If a borrow occurs (CY=1), load the immediate value 01H into accumulator A
SJMP STOP ; Unconditionally jump to the label STOP to terminate further processing
SKIP: MOV A,#00H ; At label SKIP, load the immediate value 00H into accumulator A (no borrow case)
STOP: MOV 43H,A ; At label STOP, store the value of BORROW (either 00H or 01H) into memory location 43H
SJMP $ ; Infinite loop to stop program execution (halts at the STOP label)
END ; End of the program
, EXPERIMENT 3
C. Multiplication of two 8-bit data
ORG 0000H ; Set the starting address to 0000H
MOV A,50H ; Load the value from memory location 50H into accumulator A
MOV B,51H ; Load the value from memory location 51H into register B
MUL AB ; Multiply the contents of A and B (A * B) and stored in A (lower byte) and B (higher byte).
MOV 52H,A ; Store the lower byte of the multiplication result (from A) into memory location 52H
MOV 53H,B ; Store the higher byte of the multiplication result (from B) into memory location 53H
SJMP $ ; Infinite loop to stop program execution (halts at this line)
END ; End of the program
EXPERIMENT 3
D. Multiplication of two 8-bit data
ORG 0000H ; Set the starting address to 0000H
MOV A,60H ; Load the value from memory location 60H into accumulator A (dividend)
MOV B,61H ; Load the value from memory location 61H into register B (divisor)
DIV AB ; Perform division: divide the value in A by the value in B and quotient is stored in A, and the
remainder is stored in B
MOV 62H,A ; Store the quotient (result of division) from A into memory location 62H
MOV 63H,B ; Store the remainder from B into memory location 63H
SJMP $ ; Infinite loop to stop program execution (halts here)
END ; End of the program