; PROGRAM STARTS HERE
MOV R6, #07H ; EXTERNAL COUNTER
START : MOV R7, #07H ; INTERNAL COUNTER
MOV R0, #30H ; INTERNAL MEMORY ADDRESS
MOV A, #00H ; CLEAR ACCUMULATOR
; CY = 0 A>VAL
; CY = 1 A<VAL
BACK : MOV A, @R0 ;
INC R0 ;
CJNE A, @R0, CARRY ;
SJMP DECREMENTC ;
CARRY : JC DECREMENTC ;
MOV B, @R0 ;
MOV @R0, A ;
DEC R0 ;
MOV A, B ;
MOV @R0, A ;
DECREMENTC : INC R0 ;
DJNZ R7, BACK ;
DJNZ R6, START ;
END
its showing error in 12th line .. "illegal operand"
ReplyDeletethe space between ,and b shud nt come in that 12th line
DeletePlease Write the line your facing trouble, instead of the line number.
DeleteCJNE A, @R0, CARRY
ReplyDeletein this line a instruction error exists...
This comment has been removed by the author.
ReplyDeletethis is incorrect the instruction
ReplyDeletecjne a, @r0, carry
doesnot exist
try another one
Please have a look at the following link...
Deletehttp://www.8052.com/51cjne
A traditional 8051 has been used to execute this program..
If you are using a new one or some new compiler or simulator the equivalent command has to be replaced....
cjne should have A,B,carry in its syntax
Deletethis is incorrect the instruction
ReplyDeletecjne a, @r0, carry
doesnot exist
try another one
Please have a look at the following link...
Deletehttp://www.8052.com/51cjne
A traditional 8051 has been used to execute this program..
If you are using a new one or some new compiler or simulator the equivalent command has to be replaced....
That equivalent command i will redo and update soon.
Delete% PROGRAM FOR DESCENDING ORDER
DeleteMOV R0,#0FH
UP1:MOV R7,#0FH
MOV R1,#30H
UP:MOV A,@R1
INC R1
MOV B,@R1
CJNE A,B,NEXT
SJMP DOWN
NEXT:JNC DOWN
MOV @R1,A
DEC R1
MOV A,B
MOV @R1,A
INC R1
DOWN: DJNZ R7,UP
DJNZ R0,UP1
END
% program for ascending order
DeleteMOV R0,#04H ;external counter
UP1:MOV R7,#04H ;internal counter
MOV R1,#30H
UP:MOV A,@R1
INC R1
MOV B,@R1
CJNE A,B,NEXT
SJMP DOWN
NEXT:JC DOWN
MOV @R1,A
DEC R1
MOV A,B
MOV @R1,A
INC R1
DOWN: DJNZ R7,UP
DJNZ R0,UP1
END
good work charusheela patil ....
DeleteHow to write the code for arranging a block of binary numbers in ascending order ?
ReplyDeleteNeed information like how the binary numbers are stored?? Being a byte based memory system is stored as fixed sized array in memory as 1 or zero or some other way??
DeleteTHIS PROGRAM WILL CERTAINLY WORK. ITS MY EFFORT. TRY OUT THIS ONE, 100% WORKING....
ReplyDeleteORG 0000H
MOV R0,#40H
MOV R2,#10
RK:MOV R1,#40H
MOV R3,#10
KR:MOV A,@R0
MOV B,@R1
CJNE A,B,XY
XY:JC KABIR
MOV @R0,B
MOV @R1,A
KABIR:INC R1
DJNZ R3,KR
INC R0
DJNZ R2,RK
END
cjne a,00,carry
ReplyDeletetry this....
instead of @r0 ,register address is used in asm instruction
DECENDING ORDER :
ReplyDelete0000| MOV R4,#0AH
0002| AGAIN : MOV R3,#0AH
0004| MOV R0,#30H
0006| CLR C
0007| UP : MOV A,@R0
0008| MOV R1,A
0009| INC R0
000A| MOV A,@R0
000B| SUBB A,R1
000C| JC SKIP
000E| MOV A,@R0
000F| DEC R0
0010| MOV @R0,A
0011| MOV A,R1
0012| INC R0
0013| MOV @R0,A
0014| SKIP : DJNZ R3,UP
0016| DJNZ R4,AGAIN
END
ASENDING ORDER
0000| MOV R4,#0AH
0002| AGAIN : MOV R3,#0AH
0004| MOV R0,#30H
0006| CLR C
0007| UP : MOV A,@R0
0008| MOV R1,A
0009| INC R0
000A| MOV A,@R0
000B| SUBB A,R1
000C| JNC SKIP
000E| MOV A,@R0
000F| DEC R0
0010| MOV @R0,A
0011| MOV A,R1
0012| INC R0
0013| MOV @R0,A
0014| SKIP : DJNZ R3,UP
0016| DJNZ R4,AGAIN
END