#9 Modules, Recursion, ARM Application Procedure Call Standard (AAPCS)

Поділитися
Вставка
  • Опубліковано 31 гру 2024

КОМЕНТАРІ • 60

  • @sivaramarajusiv7826
    @sivaramarajusiv7826 4 роки тому +5

    I am feeling lucky for find such a resourceful teacher

  • @arjunmanoj3249
    @arjunmanoj3249 Рік тому +1

    Great explanation, wonderful clarity, i feel so happy to get such a teacher.

  • @50-2-50
    @50-2-50 11 років тому +4

    Kudos for providing such crisp, clear, and pertinent lessons on embedded programming. Pls don't stop producing these!! I've learned more in these moderately short lessons than anything else on UA-cam. (Covering communication protocols on the Stelaris would be immensely helpful.)

  • @tongl7380
    @tongl7380 5 років тому +1

    The day you published this video I was a junior undergraduate, now I'm a fifth-year Ph.D. student and start learning from these courses... Great lessons!

  • @StateMachineCOM
    @StateMachineCOM  11 років тому +6

    As I mentioned in my earlier comments, I plan to devote future lessons to object-oriented techniques in C. At this point, I only want to mention that the module-scope encapsulation typically encapsulates a single instance or a fixed number of pre-allocated instances of a class. To handle an open-ended number of instances you need a concept of a "class" in C, which I will introduce in the future.
    --MMS

  • @sandpaper-egg-2020
    @sandpaper-egg-2020 Рік тому +2

    I recently got hired by a company for a mixed programming position. I had NO experience in embedded systems programming whatsoever and was struggling to catch up. This course single-handedly brought me up to speed with quality and clarity unrivaled by any other UA-cam training course (and I have watched quite a few). If you have just found this course, keep going. You have come to the right place. The fact that Miro Samek has posted this course for free is the height of scholastic generosity. I have learned more from this course than any computer-science college class.

  • @SergejsNazarovs
    @SergejsNazarovs 11 років тому +1

    Thanks for one more valueable lesson! Splitting a program into files also enables use of object-oriented approach in C, as you can handle each class (described in respective header and source files) as an object, defining private (static) and public variables and functions.

  • @dongolahmed
    @dongolahmed 11 років тому +8

    A million thanks to you ... you're the man

  • @Ziv49ers
    @Ziv49ers 11 років тому +1

    Brilliantly delivered lessons! Thank you Dr. Samek. Looking forward to your next upload! Good luck ~

  • @feanarocyriatan
    @feanarocyriatan 6 років тому +1

    I like the way these videos are explained since they are short enough to watch again and recap stuff that were ot clear in a first watch. Thank you very much for your contribution Mr. Samek, I hope I can put into practice all that I am learning with you very soon.

  • @leohuang990
    @leohuang990 7 місяців тому +1

    A very informative lecture! I went through an unexpected review of the header file conventions and compiler vs. linker. The keyword AAPCS led me to the answers to some personal questions about real-world ARM assembly (e.g., about r12). Rumor has it that NASA forbids recursion and suggests applying a fixed upper bound to each loop.

    • @StateMachineCOM
      @StateMachineCOM  7 місяців тому +3

      The NASA rules you're mentioning are known as "The Power of 10: Rules for Developing Safety-Critical Code" (interested people should google this up). The rules restrict recursion and recommend explicit loop bounds. They also recommend using assertions, and not just using them but reaching the right assertion *density*. I talk about assertions in the later lessons #47 (ua-cam.com/video/cnEhFwo4u5g/v-deo.htmlsi=TQIG_igL9tZ8W9Yc ) and #48 (ua-cam.com/video/yHBmzQQVVas/v-deo.htmlsi=UP2V2PtKCoynyHxE ). --MMS

    • @leohuang990
      @leohuang990 7 місяців тому

      @@StateMachineCOM Wow, thanks for the information. I'll go check them out!

  • @04mfjoyce
    @04mfjoyce 3 роки тому +1

    Thank you for another great lesson!

  • @DarkEclipz
    @DarkEclipz 11 років тому +2

    Keep up this fantastic work, very clear lessons!
    After purchasing a Raspberry Pi but wanting to program in C & Assembly and since I cannot really get it working, the Launchpad seems much easier to setup and debug etc...
    Watched all your episoded and waiting for the lauchpad to arrive! :D
    Want to try it on the launchpad directly and not through simulation hehe..

  • @navinreddy88
    @navinreddy88 11 років тому +1

    Eagerly waiting for the next videos...Bought the board online and been practicing the concepts explained till now...Your videos give clear cut understanding of controller internals...Thank you so much

  • @mostafaparvin342
    @mostafaparvin342 11 років тому +2

    method of your teaching is very good good luck

  • @billynesirupy2932
    @billynesirupy2932 11 років тому

    New lesson! Hooray! Thanks for another great video.

  • @StateMachineCOM
    @StateMachineCOM  11 років тому +1

    Texas Instruments is offering the EK-LM4F120XL Stellaris Launchpad board for only $7.99 almost half the original price of $12.99. They are apparently trying to clean up the inventory of those boards. To get the board now, go to ti.com and search for EK-LM4F120XL.

  • @trapsoldiers
    @trapsoldiers 4 роки тому +1

    Dear Sir, Your course is amazing and i enjoy it..
    But until this point i really got hard to understand all these things.. I just wonder do you also suggest any other courses or books to make everything clear in my mind ?

  • @theemelex
    @theemelex 11 років тому

    Dr. Samek, thank you very much for this course. I was stumped when thinking about ARM / 32 bit uCs & didn't know where to start learning these. I think this is the best place to begin. In keeping with this decision I've decided to purchase the LM4F120 stellaris board but there seems to be a new Tiva C series (TM4C123G LaunchPad) available. Should I go for that one instead? Will this courseware work for the Tiva too?

  • @nikhilsp13
    @nikhilsp13 5 років тому

    Beautiful !

  • @anup619thapa
    @anup619thapa 6 років тому +1

    The part that I don't get is why is register R4 used instead of any other register? How does the compiler pick and choose which registers among R1-R12 should be used?

    • @StateMachineCOM
      @StateMachineCOM  6 років тому +2

      The function fact() is calling another function (itself), therefore by the AAPCS it must assume that the registers R0-R3,R12 could be clobbered. For that reason, fact() must use a register that is guaranteed to be preserved across the function call to keep the value of the 'n' parameter. The IAR compiler has chosen the first register in the "AAPCS-preserved" group R4-R11. The R4 is saved on the stack at the entry to the fact() function and restored upon the return. Therefore, the compiler can use R4 freely inside. This seems actually a very smart decision for a recursive function like fact(). --MMS

    • @anup619thapa
      @anup619thapa 6 років тому +1

      Thanks for a quick response. One other question, if the register R0 has the return value (0x78H) then why store this at the top of the stack. Then again at time 16:59 you can see that the value at the top of stack is 0x5 and not 0x78. Slightly confused here.

  • @nickthewinner2194
    @nickthewinner2194 5 років тому +1

    its good to have straight A's.

  • @jfernandmy
    @jfernandmy 11 років тому

    Thanks a lot Miro!

  • @adityakapoor8055
    @adityakapoor8055 9 років тому +2

    Why is the variable 'x' stored on the stack and not in a register? In the examples we had done in your earlier lessons (e.g. Lesson 1), the local variables of main( ) were stored inside registers. Perhaps, taking a step back, could you please elaborate on when a variable is stored in a register and when it is stored on the stack? This would be a huge help. Thank you!

    • @StateMachineCOM
      @StateMachineCOM  9 років тому +4

      +Aditya Kapoor The variable 'x' is declared as 'volatile' at the top of main(). This forces the compiler to place the variable somewhere in memory, so that it can be loaded and stored at every read/write access. The only option the compiler has for 'x' is to put it on the stack, because it is an "automatic" variable local to the main() function.
      But in general, the C language does not prescribe where automatic variables will be allocated, and compilers are specifically free to do whatever they consider optimal. Often, this means putting auto-variables in registers, but what if you use more auto-variables (and/or parameters) than the number of available registers? In this case, the compiler again must put some of the auto-variables on the stack.
      --MMS

    • @adityakapoor8055
      @adityakapoor8055 9 років тому

      +Quantum Leaps, LLC Thanks for your quick response! Are there any particular guidelines I should keep in mind then if I am programming directly in assembly? With regards to where I should store the variables I use or is it rather arbitrary?

    • @StateMachineCOM
      @StateMachineCOM  9 років тому +5

      +Aditya Kapoor This is actually the subject of this lesson. If you program in assembly, and if you wish to interface your code with C, you should comply with the AAPCS. So, for example, your assembly functions should not clobber registers that AAPCS did not designate as such. Also, you should pass parameters and return values according to AAPCS.

  • @rishi.gupta90
    @rishi.gupta90 7 років тому

    you seemed to have not added the delay.h file in the project directory is that not an issue or would it work seamlessly? appologies if its a stupid question:)

    • @StateMachineCOM
      @StateMachineCOM  7 років тому

      The "delay.h" header file is not part of the IAR project, but is provided in the downloads and the project builds error-free. It is probably a good idea to add the "delay.h" header file to the project, so that it can be conveniently viewed and edited in the IAR IDE. To add a file to a project, click on the menu Project | Add Files and choose delay.h from the list. --MMS

  • @mahalinga2006
    @mahalinga2006 3 роки тому

    Hi Team QP, For recursive function, return type as well as in "lm4f120h5qr.h" all variables and functions were defined as unsigned type why can't be in signed ?, I think the answer for my question is answered somewhere on your previous modules but I couldn't catch it clearly...Thanks in advance

    • @StateMachineCOM
      @StateMachineCOM  3 роки тому

      The register definitions in the MCU header file are often bitmasks, meaning that they don't contain numerical values but rather groups of bits. For such uses unsigned type is most appropriate. You could try to make them signed, but then any values where the most-significant bit is set would be shown (e.g., in the debugger) as negative numbers. Typically you don't want this. Please also see one of the first lessons about counting and the 2-s complement representation. --MMS

    • @mahalinga2006
      @mahalinga2006 3 роки тому

      @@StateMachineCOM Thanks for prompt reply, Got that now :)

  • @StateMachineCOM
    @StateMachineCOM  11 років тому

    The projects created for Stellaris/Tiva Launchpad won't run directly on DK-TM4C123G, but they should be very easy to adapt. For example the single LED on this board is connected to a different GPIO pin.
    Regarding the investment, DK-TM4C123G , if you are interested in the motion sensor, the accelerometer, and the CAN bus, this might be a board just for you. But to me the board seems a little bit pricey for what it does.

  • @StateMachineCOM
    @StateMachineCOM  11 років тому

    The project files for this course work on both the EK-LM4F120XL (Stellaris LaunchPad) and the Tiva EK-TM4C123GXL (Tiva LaunchPad). As far as I can tell, the difference between the two boards is only in the name of the MCU, as Texas Instruments pushes the new name "Tiva".
    Moving forward, I will start referring to the board as "Tiva LaunchPad", but anybody with the Stellaris LaunchPad can just keep using their board. In the next lesson, I will also upgrade the IAR EWARM to version 6.60.
    --MMS

  • @josephzhang1797
    @josephzhang1797 4 роки тому

    In the 'disassembly window', for example "0xe6 0xbd10 POP {R4,PC}", so 0xe6 is the address of the register for ??fact_1 during the execution, and " POP {R4,PC}" is the corresponding disassembly language. But what is 0xbd? And basically I can translate this register information "0xbd10 POP {R4,PC}", which stored in 0xe6 into hex code. And such hex content can be found also in the "GoTo Address" window.

    • @StateMachineCOM
      @StateMachineCOM  4 роки тому

      The format of disassembly window has been explained in Lesson-1, so please re-watch. But here again, the disassembly line "0xe6 0xbd10 POP {R4,PC}" has the following elements: 0xe6 is the address of the instruction in memory (address in ROM). 0xbd10 is the 16-bit instruction opcode. This is how the instruction is stored in memory (at the address 0xe6). Finally, "POP {R4,PC}" is the human-readable instruction mnemonic, which is added by the disassembler based on the opcode. The CPU does not "see" the mnemonic--all CPU sees is the opcode. The mnemonic is only for the human eyes to make the code readable.
      Now, you seem also confused about "??fact_1:". This is a label added by the disassembler for human eyes only. This label represents the address (0xe6 in this case). Labels are generated by disassembly when there is a branch instruction going to a given address. For example, a bit earlier in the disassembly you have such a branch instruction "0xda: 0xe004 B.N ??fact_1". So, again, this instruction is at address 0xda. It's opcode is 0xe004, and its mnemonic is "B.N ??fact_1", which means that this is a "near" branch instruction to the label "??fact_1". All this branch does is to increment the PC (program counter register) by a specified amount (004*2 in this case). This works out to be the address 0xe6, labeled as "??fact_1". Please note that 0xda+4*2==0xe2, which is not quite 0xe6. But due to the effects of the instruction pipelining, by the time the PC is modified, it already is incremented to the next instruction at address 0xde. So, really the address calculation is 0xde+4*2, which indeed works out to 0xe6.
      --MMS

  • @salamka7128
    @salamka7128 11 років тому

    Great !

  • @arunkollam85
    @arunkollam85 11 років тому

    thanks a lot ....

  • @dongolahmed
    @dongolahmed 11 років тому

    Sir, have u stopped recording any further videos ?

  • @HeliosFire9ll
    @HeliosFire9ll 9 років тому

    Hey QP, I made the delay file into header and did a #include "delay.h", is there any difference from adding delay.c?

    • @HeliosFire9ll
      @HeliosFire9ll 9 років тому +1

      +Helios Fire
      Nevermind, you've included delay.h with delay.c before you added it to main.c. I understand

  • @theemelex
    @theemelex 11 років тому

    Dear Dr. Samek,
    Will this course also run successfully on the TI development board DK-TM4C123G? If one is serious about learning ARM would this kit kit be worth the investment?
    (ti.com/tool/dk-tm4c123g?DCMP=tivac-tm4c123g&HQS=tivac-tm4c123g-b).
    Eagerly awaiting Lesson 10.

  • @StateMachineCOM
    @StateMachineCOM  11 років тому +1

    The next lesson 10 should be ready tomorrow :-)
    --MMS

  • @ShawnGerber
    @ShawnGerber 11 років тому

    Great Lesson! Here is a question: I've noticed that when you declare the variable x inside of the main function, you can't view the value in the variable window. But if I declare it outside of main, I can then view the value of x. Why is this?

    • @asarfraaz
      @asarfraaz 10 років тому +1

      Just guessing here. May be its because x becomes global when you move it out of main. And may be variable window shows only global variables? The local variables on the other hand are present on the stack. Would be interesting to know the correct answer though.

    • @sieg1970
      @sieg1970 9 років тому +1

      Sarfraaz Ahmed the variable inside main or function is auto-variable (or some people call local variable), you can see its value in the variable window when its lifetime is up.

  • @KananDethin
    @KananDethin 8 років тому +2

    Thank you.

  • @keithevans6450
    @keithevans6450 7 років тому

    I'm using IAR Embedded Workbench IDE - ARM 8.11.2 (size limited eval) and have a couple of questions for anybody. There are two differences that I'm seeing versus the video that Miro posted. (1) I don't get symbolic labels for everything. e.g. instead of things like ??fact_0 I get hex values. Any idea how to enable it? It's not obvious to me. (2) When I use step-into in mixed mode debugging (so that the C statements are visible) it sometimes wants to step by one C statement instead of one ARM instruction. Is there an obvious way to toggle this behavior in case it doesn't do what I want?

    • @StateMachineCOM
      @StateMachineCOM  7 років тому

      For the symbolic information in the debugger, please make sure that you check "Generate debug information" in Project Options, C/C++ Compiler Category, Output tab. As to single-stepping machine instructions, first click inside the disassebmly view and then single-steps will be in machine instructions. --MMS

    • @keithevans6450
      @keithevans6450 7 років тому

      Unfortunately I already enabled debug information for the compiler, assembler, and linker. It's not a big deal, but your view looks much easier to follow. I wanted to try IAR/uVision/CCS just to get a little experience with the various tools. The single stepping in IAR is now completely obvious so thanks for that.

  • @saiganesh891
    @saiganesh891 9 років тому

    Why have you created another file for delay instead of that can we directly call the prototype above the main ?

  • @alexcipriani6003
    @alexcipriani6003 3 роки тому

    great course but this is definitely not for completely beginners...if you are a beginner check out the arm call standard procedure first; the caller, callee theorethical concepts than come see this explination. This assumes you already knows the theorethical knowledge but great course otherwise

    • @StateMachineCOM
      @StateMachineCOM  3 роки тому +1

      That's true. This course progresses quickly, often at a pace too fast for complete beginners. But it was never meant to be the *only* course you study. So, by all means, please do your own research of material that was presented too fast for you. At least you will *know* what to study. On the other hand, the risk of going too slow is greater, because you lose more experienced viewers, for whom the early 20 or so lessons of this course should be more of a "refresher" than a completely new material.
      --MMS

    • @alexcipriani6003
      @alexcipriani6003 3 роки тому

      @@StateMachineCOM yes, I was somewhat familiar with MIPS procedure call from college which is a bit different but I had to study the AAPCS first to keep up with your explanation
      Thank you for making this content available. 🙏🏼