Discussion in "8051 Discussion Forum" started by    sks    Sep 19, 2008.
Wed Sep 24 2008, 06:55 pm
#21
Hello sahooji,


Good to see that you are putting efforts in writing your own code !

the above code has many errors, i think you are trying two or three things at a time, if you want to display count in hex then you can display it on only one port but you are thinking of displaying the count like on two 7-seg displays.

you can display upto 255 (FFh) on one 8 bit port.

if it is a up counter then you should increment the register/variable, but you are incrementing r1 and decrementing r2.

ajmp end
tc_end:
ret
end:
end 


the above, is a common newbie mistake. instruction "end" does not belong to 8051's
instruction set but it is an assembler directive, it tells/indicates the assembler the "finish" of code. its the job of the programmer to " loop back " other wise the micro fetches and executes the code till the end of ROM memory and resets it self .

in my earlier post i had suggested you to go thru a good micro book (kenneth ayala) but seems that you have not spend enough time with the book.

i / we can understand your enthusiasm to learn micros but keep in mind "good foundation is a must for becoming successful designer"

you can read the topic "PAL" (Practice Assemble Language ) in ayala's book.


Arun


[ Edited Wed Sep 24 2008, 06:56 pm ]
 sks like this.
Wed Sep 24 2008, 07:05 pm
#22
end is a keyword in keil (if you are using keil) so replace it with any other label say "routine_end" or something.
 sks like this.
Wed Sep 24 2008, 10:02 pm
#23
hello Mr Arun,
thank u for ur comments and advice. as per ur advice believe me i m reading the said book. as mr pdi33 had suggested to read from the numeric system, i m following his advice. i know there must be errors in my code as i hv told b4 i m new to ur world of uc. so pl bear with me, i promise u i will try to obey ur advice and follow ur said path. pl try to point out the errors. i wrote the code for two 7seg displays, it will count 0 to 99 and stop when counter reaches 99. of course i hv not written delay for above code.
thanks again
sks
Wed Sep 24 2008, 10:04 pm
#24
hello Mr Ajay,
thanks for ur suggestion, i am using 8051 IDE not KEIL. pl suggest
sks
Thu Sep 25 2008, 11:19 am
#25
hello Mr Arun,
first allow me to call/address at least u as "SIR" among all of ur Moderators.
last night i hv gone through the chapter PAL of the book, and felt sorry for my mistakes. it was not a structured one, no algorithm has been followed etc.
ok i will try to improve myself. pl reply. thanks again
sks
Fri Sep 26 2008, 08:15 am
#26

Hello sahooji,

you don't have to call me or our friends as SIR, on the contrary we have to call you as SIR, because of your age, we are like your kids - so no formalities !

regarding PAL, pl. go thru that chapter carefully, the author has explained the concept very beautifully and this is the first step to be learned before actual 8051 assembly.

did you know that 8051 which is a 8 bit micro, actually has a instruction set of 255 instructions/commands (FFh) - thats how amazing our 8051 is !


Arun
 sks like this.
Fri Sep 26 2008, 09:04 pm
#27
Hello Mr Arun,
Thank u all, i extremely happy after reading ur reply. god bless u all. i didn't know there is 255 instructions before, i didn't notice that op code part of instructions in the book. right now i noticed it , it is 255 (ffh) nos. thanks for teaching me. i have followed some of ur replies in other threads, it is amazing. i mean ur teaching style. thank u all again
sks
Sat Sep 27 2008, 11:44 am
#28
Hello Mr Arun,
i hv some doubts in PAL Practice Chapter. It has been written PAL has only NINE Instructions where as we hv 255 instructions to use. pl clear my doubt.
one more question, i have notice in Instruction set there r 8 AJMPs 7 ACALLs having different OP CODES, why it is like that. pl clarify my doubts.
thanking u
sks
Sat Sep 27 2008, 01:01 pm
#29

hello Sahooji,

please don't get confused with the PAL instruction set and 8051 instruction set, the author introduces the concept of Assembly language by taking example of a "similar" micro controller like 8051 and names it as PAL micro controller just like we have 8051 Micro.

now PAL micro has RAM, Registers, ROM, PC etc just like any 8 bit micro, it also has separate instruction set, opcodes ( just like 8051).

now this typical PAL micro has only 9 instructions or opcodes,and the author wants us to understand the concept with the help of a small micro rather than straight away starting with bigger 8051.

regarding the different no:of opcodes for AJMP and ACALL, each opcode is a result of possible short address 3 bit combination(upper bits).

at this stage you don't have to worry about this.



Arun

 sks like this.
Sat Sep 27 2008, 08:51 pm
#30
Hello Mr Arun,
i hv written two simple up counter code, one can count up to 255 and another can count up to 1000. the later one was little difficult to write. is this one of the ways to count up to 1000 or more. i am pasting the codes here. pl comment, how can i know my faults, unless i see the correct one.
thanks all
sks

; 0 TO 255 DEC COUNTER

ORG 00H
MOV A,#0

MAIN:
INC A
CJNE A,#255,MAIN
END

; 0 TO 1000 DEC COUNTER

ORG 00H
MOV A,#0
MOV R0,#0
MOV R6,#0

MAIN:

INC DPTR
MOV A,DPL

CJNE A,#250,MAIN

MAIN_1:
INC R6
MOV DPTR,#0000H
INC DPTR
MOV A,#DPL
MOV R0,A
CJNE R0,#4,MAIN

END

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Michailqfh
Fri Mar 29 2024, 01:53 am
Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm