Assignement Controller
Assignement Controller
:3CE7H+3B8DH=7874 When first bye is added(E7+8D=74,Cy=1) the carry is propagated to the higher byte,which results in 3C+3B+1=78(all in hex).
No of Ones:
mov dptr,#9000h ;Load dptr with 9000h movx a,@dptr ;move data from external memory location to a mov r0,#0h ;load r0 with 0 mov r1,#8h ;load r1 with 8 clr c ;clear carry bit up:rlc a ;rotate a left through carry jnc next ;if no carry, jump to label next inc r0 ;increment r0 next:djnz r1,up ;decrement r1, and jump to label next, if r10 inc dptr ;increment dptr mov a,r0 ;move data from r0 to a movx @dptr,a ;move data from a to external memory location here:sjmp here end
Accending Order:
Org 000h Temp EQU 40h N Equ 04H
MOV R4.#N-1 Loops:Mov DPTR,#2000H MOV r5,r4 Loop1:MOVX A,@DPTR MOV r1,a INC DPTR MOVX A,@ DPTR MOV TEMP,A MOV A,r1 CJNE A,Temp,Loop2 SJMP LOOP3 Loop2:JC Loop3 MOVX @DPTR,A MOV A,TEMP DEC DPL MOVX @DPTR,A INC DPL Loop 3: DJNZ r5,Loop1 DJNZ r4,Loops End
Fibonacci :
mov r1,#0ah ;Load r1 with immediate data 0ah
mov dptr,#9000h ;load 9000h into dptr register movx a,@dptr ; move data from external memory location to a inc dptr ;increment dptr mov r0,a ;move data from a to r0 movx a,@dptr ; move data from external memory location to a back:mov r2,a ;move data from a to r2 add a,r0 ;add a and r0 inc dptr ;increment dptr movx @dptr,a ;move data from a to external memory location mov r3,a ;move data from a to r3 mov a,r2 ; move data from r2 to a mov r0,a ; move data from a to r0 mov a,r3 ; move data from r3 to a djnz r1,back ;decrement r1, if not 0, jump to label back here:sjmp here end