0% found this document useful (0 votes)
20 views4 pages

MA Lab Exp1-2 (A)

The document contains assembly language code for various experiments, including the addition of 8-bit and 16-bit numbers, N-bit array addition, counting the number of 1s in a byte, and finding the square of numbers using a data pointer. Each experiment is structured with comments explaining the purpose and functionality of the code. The code is organized with specific memory locations and operations to achieve the desired results.

Uploaded by

shindevedant60
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

MA Lab Exp1-2 (A)

The document contains assembly language code for various experiments, including the addition of 8-bit and 16-bit numbers, N-bit array addition, counting the number of 1s in a byte, and finding the square of numbers using a data pointer. Each experiment is structured with comments explaining the purpose and functionality of the code. The code is organized with specific memory locations and operations to achieve the desired results.

Uploaded by

shindevedant60
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

NAME: Vedant Shinde

PRN:1032233457

//EXP1:A
;//Addition of two 8 bit numbers
ORG 00H ;start at location
MOV R5,#25H ;load 25H into R5
MOV R7,#34H ;load 34H into R7
MOV A,#0 ;Load 0 into A
ADD A,R5 ;Add content of R5 to A
ADD A,R7 ;Add content of R7 to A
ADD A,#12H ;Now A=A+12H
HERE:SJMP HERE ;stay in this loop
END
--------------------------------------------------------------------------------------------------------------------------------------

//EXP 1:B (ADD 16-BIT NUMBERS 12345678 RESULTS STORE IN R6 AND R5)

ORG 0000H ;START AT LOCATION


MOV R0,#34H ;LOAD 34 INTO R0
MOV A,#78H ;LOAD 34 INTO A
ADD A,R0 ;ADD CONTENT R0 TO A
MOV R5,A ;LOAD A INTO R5
MOV R2,#12H ;LOAD 12 INTO R2
MOV A,#56H ;LOAD 56 INTO A
ADDC A,R2 ;ADD CONTENT R2 TO A
MOV R6,A ;LOAD A INTO R6
END
C.
//N BIT ARRAY ADDITION

ORG 0000H
MOV R1,#05 ;counter for addition of numbers
MOV R0,#40H ;memory address 40 contents to be shifted to R0
LABEL:ADD A,@R0 ;start addition
INC R0
DJNZ R1,LABEL ;continue counter R1 addition address reg R0 till becomes 0
MOV R6,A
MOV 46H,R6
END

//EXP 2:B

;counting Number of 1s in a byte


;counter for:how many times carry flag was set
;counter for checking all 8-bits in a given table
;R1:to counrt how many times carry flag was set
;R2:to scan all 8-bits

ORG 0000H
MOV R1,#00H; counting how many times carry flag is set
MOV R2,#08H; scanning of bits 8 times for a byte
MOV A,#0FFH; load the number to be checked into accumulator
back:RRC A; rotate accumulator right through carry
JC Count
SJMP NEXT
COUNT: INC R1
NEXT:DJNZ R2,BACK
END

//EXP 2:A
; Finding square of numbers using DPTR
ORG 0000H
MOV DPTR, #0100H
MOV R1, #40H
MOV R0, #09H

BACK:
MOV A, R0
MOVC A, @A+DPTR
MOV @R1, A
INC R1
DEC R0
JNZ BACK

ORG 0100H
TABLE: DB 0,1,4,9,16,25,36,49,64,81
END

C .Find whether number positive or Negative


;To find whether the number is positive or negative if pos acc will have 00h if neg 01h
ORG 0000H
MOV A,#08H
RLC A
JC NEGATIVE
SJMP POSITIVE
NEGATIVE: MOV A,#01H
SJMP TERMINATE
POSITIVE: MOV A,#00H
TERMINATE: NOP
END

You might also like