تبلیغات
سایت تاکستان رباتیک - دستورات حلقه و پرش به زبان C در میکروکنترلرهای ARM
 
سایت تاکستان رباتیک
بزرگترین و جامع ترین سایت رباتیک ایران
                                                        
درباره سایت


مدیر سایت : فرهاد رحمانی
نویسندگان
نظرسنجی
از کدامیک از مطالب سایت بیشتر استفاده می نمایید؟








آمار سایت
  • کل بازدید :
  • بازدید امروز :
  • بازدید دیروز :
  • بازدید این ماه :
  • بازدید ماه قبل :
  • تعداد نویسندگان :
  • تعداد کل پست ها :
  • آخرین بازدید :
  • آخرین بروز رسانی :

دستورات حلقه و پرش به زبان C در میکروکنترلرهای ARM


گاهی مواقع برنامه باید چندین بار تکرار شود برای این کار از دستورات حلقه و پرش استفاده می شود در زیر به بررسی انواع حلقه های موجود در Keil پرداخته می شود.


دستورات حلقه و پرش به زبان C در میکروکنترلرهای ARM

:: حلقه های while

این حلقه به فرم زیر می باشد

While (x) {

برنامه

}

این حلقه که خود در حلقه ی اصلی قرار می گیرد یک حلقه ی بی نهایت است. هنگامی که برنامه به آکولاد دوم رسید به While پرش می کند. شما می توانید به جای x عدد دلخواه خود را بگذارید و از تعداد بیش تری حلقه در برنامه خود استفاده کنید.

:: حلقه ی for

این حلقه یک حلقه شرطی است و تا زمانی که شرط آن درست باشد ادامه می یابد این حلقه به فرم کلی زیر است:

For (مقدار اولیه حلقه، شرط پایان، گام حلقه) {

برنامه

}

در این نوع حلقه می توان تعداد تکرار را مشخص کرد مقدار اولیه حلقه می تواند یک عدد باشد. شرط پایان حلقه نیز یک عدد یا متغیر است هنگامی که مقدار اولیه در شرطی که در این قسمت نوشته می شود صدق کند حلقه به پایان می رسد.

گام حلقه نیز مشخص می کند که مقدار اولیه چگونه تغییر کند:

For (j = 1 ;j<10 ;j++){

برنامه

{

در مثال بالا مقدار اولیه متغیر j مقدار 1 می باشد تا وقتی که j از 10 کوچک تر باشد حلقه ادامه می یابد همچنین با هر بار تکرار حلقه یک واحد به j افزوده می شود.

:: حلقه ی do – while

Do

{

برنامه

} while (شرط) ;

در این حلقه بر خلاف دیگر حلقه ها شرط در انتهای حلقه چک می شود.

این حلقه حداقل یک بار اجرا می شود، در صورتی که در قسمت شرط دستور مبنی بر تکرار حلقه وجود داشته باشد، حلقه دوباره تکرار خواهد شد.

:: دستور goto

توسط این دستور می توان به یک بر چسب پرش کرد، بازگشت از بر چسب با دستور Return انجام می شود:

Goto lable;

Lable:

برنامه

Return;






نوع مطلب : الكترونیك، 
برچسب ها :
لینک های مرتبط :




یکشنبه 29 مهر 1397 01:49 ب.ظ
Howdy sᥙperb blog! Does running a bⅼog suϲh
as thiѕ take a large amoint of work? I have no understanding of computer pгogramming however I had been hoрing to
start mmү оown blog soon. Anyways, shoulpd you have any recommendations or tips for
new blog owners please share. I know thiѕ is off subject nevertheless I just needed to
ask. Kudos!
سه شنبه 30 مرداد 1397 12:09 ق.ظ
Every weekend i used to pay a visit this site,
for the reason that i wish for enjoyment, for the reason that this this
site conations actually pleasant funny information too.
دوشنبه 29 مرداد 1397 01:58 ب.ظ
Wow that was unusual. I just wrote an really long comment but after I clicked submit my
comment didn't show up. Grrrr... well I'm not writing all that over again. Anyway, just wanted to say superb blog!
دوشنبه 29 مرداد 1397 02:25 ق.ظ
I know this if off topic but I'm looking into starting my own blog and
was wondering what all is required to get setup?
I'm assuming having a blog like yours would cost a pretty penny?
I'm not very web smart so I'm not 100% positive. Any suggestions or advice would be
greatly appreciated. Thanks
یکشنبه 28 مرداد 1397 06:53 ب.ظ
Hello, Neat post. There is an issue together with your site in web explorer,
would test this? IE still is the market leader and a big component to
folks will omit your great writing due to this problem.
یکشنبه 28 مرداد 1397 01:19 ب.ظ
Awesome post.
یکشنبه 28 مرداد 1397 11:16 ق.ظ
Fastidious answers in return of this difficulty with firm
arguments and telling everything concerning that.
یکشنبه 28 مرداد 1397 04:35 ق.ظ
Ahaa, its fastidious conversation on the topic of this piece of writing at this place at this web site,
I have read all that, so now me also commenting at this place.
یکشنبه 28 مرداد 1397 01:11 ق.ظ
Hey there just wanted to give you a quick heads up.
The text in your article seem to be running off the screen in Opera.

I'm not sure if this is a formatting issue or something
to do with web browser compatibility but I figured I'd post to let you know.
The style and design look great though! Hope you get the problem resolved
soon. Thanks
یکشنبه 28 مرداد 1397 12:57 ق.ظ
I blog frequently and I genuinely thank you for your content.
The article has really peaked my interest.

I'm going to take a note of your website and keep checking for
new details about once per week. I opted in for your RSS feed as well.
شنبه 27 مرداد 1397 10:55 ب.ظ
I all the time emailed this web site post page to all my contacts, as if
like to read it afterward my links will too.
شنبه 27 مرداد 1397 10:01 ق.ظ
I do not even know how I ended up here, but I thought this
post was good. I do not know who you are but definitely you're going to a
famous blogger if you aren't already ;) Cheers!
شنبه 27 مرداد 1397 04:35 ق.ظ
Hello! I know this is kinda off topic but I was wondering
if you knew where I could get a captcha plugin for my comment form?
I'm using the same blog platform as yours and I'm having problems finding one?

Thanks a lot!
شنبه 27 مرداد 1397 02:15 ق.ظ
My relatives all the time say that I am killing my time
here at net, but I know I am getting know-how everyday by reading thes nice articles or reviews.
شنبه 27 مرداد 1397 01:06 ق.ظ
Hi! Would you mind if I share your blog with my twitter group?

There's a lot of folks that I think would really enjoy your content.
Please let me know. Thanks
جمعه 26 مرداد 1397 01:52 ب.ظ
What's up to all, the contents present at this web site are actually remarkable for people knowledge, well,
keep up the good work fellows.
جمعه 26 مرداد 1397 01:41 ب.ظ
I've been browsing online more than three hours today, yet I
never found any interesting article like yours.
It's pretty worth enough for me. Personally, if all webmasters and bloggers made good content as you did,
the internet will be much more useful than ever
before.
جمعه 26 مرداد 1397 02:01 ق.ظ
Oh my goodness! Awesome article dude! Many thanks, However I am encountering troubles with your RSS.
I don't know why I am unable to subscribe to it. Is there anyone else getting
identical RSS problems? Anyone that knows the solution can you kindly
respond? Thanx!!
جمعه 26 مرداد 1397 01:54 ق.ظ
This post is really a fastidious one it helps new the web users,
who are wishing in favor of blogging.
جمعه 26 مرداد 1397 01:20 ق.ظ
We stumbled over here coming from a different website and thought I should check things
out. I like what I see so now i am following you. Look forward to looking
into your web page for a second time.
پنجشنبه 25 مرداد 1397 12:08 ب.ظ
This is very attention-grabbing, You are a very professional blogger.
I've joined your rss feed and sit up for in quest of extra of your
excellent post. Also, I've shared your website in my social networks
پنجشنبه 25 مرداد 1397 03:14 ق.ظ
I truly love your website.. Very nice colors & theme. Did you create this web site
yourself? Please reply back as I'm hoping to create my own personal
website and would love to know where you got this
from or exactly what the theme is named. Thank you!
چهارشنبه 24 مرداد 1397 11:05 ب.ظ
همیشه دوست دارم کارهای خوب رو معرفی کنم .خرید عطر آنلاین از فروشگاه شیک فام بهترین انتخاب
چهارشنبه 24 مرداد 1397 10:59 ب.ظ
Hi to all, how is the whole thing, I think every one
is getting more from this website, and your views are nice in support of new
viewers.
چهارشنبه 24 مرداد 1397 08:32 ب.ظ
Spot on with this write-up, I absolutely think this website
needs a lot more attention. I'll probably be back again to read
through more, thanks for the info!
چهارشنبه 24 مرداد 1397 04:56 ب.ظ
I always spent my half an hour to read this blog's content every day along with a cup of coffee.
چهارشنبه 24 مرداد 1397 12:19 ب.ظ
Paragraph writing is also a excitement, if you be familiar
with afterward you can write if not it is complex to write.
چهارشنبه 24 مرداد 1397 08:26 ق.ظ
Hi there, You've done a great job. I will certainly digg it and
personally recommend to my friends. I'm confident they'll be benefited from
this web site.
چهارشنبه 24 مرداد 1397 07:06 ق.ظ
Hello, i feel that i noticed you visited my web site so i came to return the prefer?.I'm trying to in finding issues to improve
my site!I assume its good enough to make use of a
few of your ideas!!
چهارشنبه 24 مرداد 1397 02:00 ق.ظ
I constantly spent my half an hour to read
this blog's posts everyday along with a mug of coffee.
 
لبخندناراحتچشمک
نیشخندبغلسوال
قلبخجالتزبان
ماچتعجبعصبانی
عینکشیطانگریه
خندهقهقههخداحافظ
سبزقهرهورا
دستگلتفکر


نمایش نظرات 1 تا 30