VTech Alphabert s Magic Readport User Manual Page 13

  • Download
  • Add to my manuals
  • Print
  • Page
    / 80
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 12
BM Dept., Govt. Engg. College, Gandhinagar Page 13
EXPERIMENT NO. 3
AIM: Write programs to ….
To add two sixteen bit numbers stored in DPTR and at memory location 40h,41h.Store
result in DPTR.
Multiply two 16 bit numbers. Assume that first 16 bit number is stored in register R6 and
R7, Second 16 bit number is stored in register R4 and R5. Store answer in register
R0,R1,R2 and R3.Load first value in R6 and R7
Program 1: To add two sixteen bit numbers stored in DPTR and at memory location 40h,
41h. Store result in DPTR.
ORG 00h
MOV DPTR,#2233h ;Transfer 16 bit data to DPTR
MOV 40h,#11h ;Transfer LSB of 16 bit data to location 40h
MOV 41h,#22h ;Transfer MSB of 16 bit data to location 41h
MOV A,40h ; Get LSB of 16 bit data in accumulator
ADD A,DPL ;Add with LSB of second data which is stored in
;DPTR
MOV DPL,A ;Save result back in DPL
MOV A,41h ;Get MSB of first data in accumulator
ADC A,DPH ;Add with MSB of second data consider previous
;carry.
MOV A,DPH ;Save result back in DPH
END
Program 2:
;Load first 16 bit value in R6 and R7
MOV R6,#11h
MOV R7,#22h
;Load second 16 bit value in R4 and R5
MOV R4,#11h
MOV R5,#22h
;Multiply R5 by R7
MOV A,R5 ;Move the R5 into the Accumulator
MOV B,R7 ;Move R7 into B
MUL AB ;Multiply the two values
MOV R2,B ;Move B (the high-byte) into R2
MOV R3,A ;Move A (the low-byte) into R3
;Multiply R5 by R6
MOV A,R5 ;Move R5 back into the Accumulator
MOV B,R6 ;Move R6 into B
MUL AB ;Multiply the two values
ADD A,R2 ;Add the low-byte into the value already in R2
MOV R2,A ;Move the resulting value back into R2
MOV A,B ;Move the high-byte into the accumulator
Page view 12
1 2 ... 8 9 10 11 12 13 14 15 16 17 18 ... 79 80

Comments to this Manuals

No comments