FOR THOSE OF WHO ARE NOT CODE WIZARDS

I know that may of you like @Dave Hein and @msrobots and others who are wizards in coding know this stuff in a fenominal to us who just simply code.
Would it be possible that you could give us links to better understand operating systems, loaders, and compilers so that we can better understand the basics of
what you are working with.
I and many others would be most interested so we can better understand what we are working with.
I wrote some mini tutorials from a teacher standpoint for my self and put them on the forums. I think if you could supply some links, that I would be able to better understand and
later impart that to the wizards in making.

thanks.
More of how it works so I can translate it to myself and others. So we do not get so dizzy and pass out.

Thanks again
Martin
“Light thinks it travels faster than anything but it is wrong. No matter how fast light travels, it finds the darkness has always got there first, and is waiting for it.”
“You only live twice:
Once when you are born
And once when you look death in the face”

Comments

  • Well I am not a Wizard at all, I just program for a long time and was bound to switch languages and systems often. So I can adapt quite easy, normally. Except that one little town with a Druid able to make men strong by brewing some mystical stuff. I fail to adapt to FORTH.

    I could not afford the FPGA boards and jumped in with the ES. But I am following the P2 since its beginning 8-10 years ago almost religiously, and barely miss any posts.

    So I have basic understanding why things are done like there are done. That helps to understand the two Google docs better. Else I just use try and error and lots of post in the very helpful forum.

    As of what I am using - Windows 10 and fastspin. That uses p2load as loader.

    My P1 projects and playground was the PropTool and since I play with the P2 my P1s are in a box. But I will try fastspin on the P1 soon.

    As of tutorials, hmm - not really my world. I read other persons code and try to document mine heavily to avoid the following



    Enjoy!

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • Learning compiler and language building knowledge is full on Comp Science university level. It's something I have no knowledge of either. There are specific hardcore tools for the job but even with the knowledge and tools on hand, it's still a lot of tedious work I suspect.

    OS design/build is a very open ended matter. There is no end to how big it can go. Or it can be contained in the language and a bunch of libraries that you compile into your target binary.

    The loaders/programmers aren't anything huge usually. Just getting the hardware/OS to play ball is the challenge there. Compatibility issues tend to show up a lot.

    "... peers into the actual workings of a quantum jump for the first time. The results
    reveal a surprising finding that contradicts Danish physicist Niels Bohr's established view
    —the jumps are neither abrupt nor as random as previously thought."
  • Love the cat. Thank you both @msrobots and @evanh
    “Light thinks it travels faster than anything but it is wrong. No matter how fast light travels, it finds the darkness has always got there first, and is waiting for it.”
    “You only live twice:
    Once when you are born
    And once when you look death in the face”
  • We all have those "moments of clarity" when it comes to writing code, and there are many times I have looked at my own code and thought who wrote this, this is brilliant or this is absolutely hideous. The video is spot on, but over the years I have found that designing with a flow chart in combination with the code helps immensely when returning back to your code. The structure of the flowchart is somewhat important so that it easily translates into code, but for the most part I structure the flowchart as a state machine where each node in the flowchart is assigned a number. The number essentially becomes a label in code. In some circumstances it is necessary to implement index branching where each node returns to a common node (branch distributor) where the next node is then called based on an index value set by a previous node. In other circumstances one node simply calls the next node. The former is efficient for handling multi threaded programming where you can have multiple index counters or in an interrupt situation where conditional state machine branching can occur, while the latter works well for single threaded applications.

    Point is, is that for me anyway, a flow chart is a way to easily visualize critical points of a program in a rough draft sort of way. My mind can work through a flowchart much easier than line after line of code. Even when I go to bed at night, I can run through a flowchart in my head much more efficiently than I can with lines of code. In a way visually, that's sort of what "BlocklyProp" and other similar programing structures do, but it's no flowchart. I prefer to have more control over my programming.

    ...And to put a plug out there to one of our forum members. I owe a lot of my programming style and structure techniques to Jon Williams.


    Beau Schwabe -- Submicron Forensic Engineer
    www.Kit-Start.com - bschwabe@Kit-Start.com ෴෴ www.BScircuitDesigns.com - icbeau@bscircuitdesigns.com ෴෴

  • potatoheadpotatohead Posts: 9,736
    edited 2019-07-10 - 19:43:54
    Hi Pilot!

    I am an amateur. Have written some code on just about everything. Many people pick this stuff up by example, but that can be hard and time consuming. There is a method I was shown long ago that I want to share with you. It's useful. For me, it is what I always return to when faced with something new.

    What you can do is compartmentalize. It's best to focus on a thing at a time. Having a working example is also best. It can be anything. We've got some example code, and that's where you can start. Starting simple is better.

    So, get yourself ready. This is prep.

    First thing: (If you have a pre-built binary)

    Make it run.

    Second thing: (If you just have example code)

    Build it yourself, and then make it run.

    Third thing:

    Begin reading it.

    You want to make sure it runs, so you eventually can test what you know by changing it. And when you change it and it does not work, you can know it's what you did, not some silly thing that may have happened otherwise.

    If you want to go old school, print it out. Shorter programs are better. New school is to open a copy of the code in your favorite text editor / word processor. Does not matter which one you do.

    Here is where the magic begins:

    No matter what the kind of program is, BASIC, PASM, C, SPIN, you want to break it down into five rough categories. If you are working old school, get yourself a few highlighters. Colors.

    The categories are:

    Program flow and control: IF, THEN, BRANCH, FOR, NEXT, etc... Your loops, decision points, and all that get one color.

    Computation: Math, bit operations (XOR, AND, NOT), these get another color, and you get the idea here. Colors.

    Data operations: Indexes to arrays, fetches, writes, reads, and other things that get done with or to data

    Data: This is not code, but the stuff code works with. Yes, they can be one and the same, but baby steps here first. Strings, pictures, initial values, constants, all givens, essentially. This can include data the program generates too.

    Configuration: System level stuff, smart pin modes, pin directions, clocks, and all the spiffy hardware bits in the chip count.

    Start with the program flow and control. Look through the program to identify places where flow changes. Highlight those. Keep going, until you have a good idea of the overall flow. I really like looking at flow first because that tends to suggest where the parts of the program are. At the low level, like assembly language, it's a big deal. At the higher level, parts are more clear, but flow always helps me.

    As you run into the others, mark them too. You can be opportunistic, but critical. If you don't know, don't color it.

    If you don't know, skip it. You can return later when you understand better. Focus on what you do know.

    At some point, things will become obvious, or you get questions. Either is fine. They both are progress! Where you believe you understanding something, write a comment. If old school, use pencil for these. If you have a question, write that down too.

    For bonus points, where the same comment or question comes up, tag it with a marker. I use brackets and numbers / letters.

    eg:

    'why does this need to be here? [1]

    That way, you can consolidate some of what you are working with. And if you are not sure, don't do it. Again, focus on what you know, and that includes better understanding what you don't know! Both are high value.

    Continue writing comments. And continue coloring things too. This is all incremental. It takes many passes to really grok a new program. We often forget how intense that process is when we are comfortable, or have been doing it for ages. I personally will go some longer periods of time between programming. It's the nature of my work personally. I do return to this method when I have been away. Gets me back in the game fairly reasonably.

    Good comments come from pretending you are writing them to your good friend. Take that style. It's super helpful, and in a way, you are doing exactly that. Today you is helping future you, and you are great friends with you. See? :D Further, if you want to internalize what I am trying to get at here, today you is learning how to tell future you how to build a program.

    Over time, you will be familiar with a lot of the program. Future you will be super happy about that.

    Test what you know. Change a thing. Did it do what you expect? Change it again. Trace that thing back to other related things, make comments. Wash, rinse, repeat.

    For the questions, you can start asking things here, like all of us do. But, sometimes it's not enough, or it's hard for others to understand where you might be at. That's fine.

    This process should lead you to good questions. If anything, others can point you to stuff you can read, or watch and take it in at your own pace. Or maybe you can get answers.

    I would continue, until you are pretty sick of the program you are looking to understand. The end game is you can say something meaningful about every single line in it.

    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • potatoheadpotatohead Posts: 9,736
    edited 2019-07-10 - 19:49:12
    What should happen, as you do battle with your target program(s), is the little tangents, operating system, I/O, loaders, linkers, assemblers, etc... should come up in context.

    I really struggle with easy ways for others to pick up on all those things. Here's an example:

    This book on linkers and loaders is awesome: http://index-of.co.uk/Exploit/Linker&Loaders.pdf

    I consider it a very good reference. But, it's a full treatment too! If you plow through that one, I assure you your understanding of those things will improve, but so will the number of questions you have! Collecting references is worth it. Just don't get fully absorbed in them, unless you have lots and lots of time.

    And that is where compartmentalization gets you through. Getting a sense of priority, what you can ignore, accept today as magic, knowing tomorrow you may dig into it, matters. This all adds up, and soon you will be taking pretty big steps. However, in my experience, and I've done this a ton of times, there is no getting around just chugging through the basics.

    Truth is, what most of us need is a working compiler, assembler, loader. If you can open up sample code, hit the button and see your P2 do what that program intended, then you have a working setup.

    If you don't see that, then you need a working setup.

    Priority?

    Get a working setup.

    That setup can remain magic for a while. That leaves you free to focus on the program. Understand it, change it, then maybe write one of your own.

    That applies to this whole process in general. Keep your scope small. Take the magic for what it is, until you are ready to get after it.

    And that brings me to the last bit of advice:

    What are you wanting to do? Does not matter what it is, just that you have nailed it down some.

    It could be you have some goal, specific, control something, or whatever. That's fine. It could also be that you don't even know what is possible too. All good.

    Worst case, take your sample program, look at what it can do, and make a project for yourself that you think might be possible given the bits in your sample.

    Then do that.

    In general, it's possible to keep the scope of stuff you are struggling with small. The stuff you know is your base. Work from your base, even if some of it is monkey see, monkey do magic. The stuff you don't know needs priorities to keep it from overwhelming you and from getting confusing, discouraging.

    Hope this helps.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • Right now I am actually working this process with some Python code I have to get my head wrapped around.

    (Super excited to know we've got MicroPython running on P2. I like it so far.)

    And that brings me to one last bit:

    Libraries and dependencies.

    In the end, you can't ignore those. You will need to have some understanding. But, for early learning, take them at face value, just magic black boxes and focus on the program. At some point, and you will know when, you will realize full understanding of the main program just can't happen without digging into that library or dependent piece.

    On P2, for example, a video display is a dependent piece. Best move is to understand what it does and just accept that it does it for now. Whatever program is doing cool stuff on the display is likely what you are interested in. Compartmentalize. Same can be said for serial comms, or other things.

    What I will do fairly early on is write a small program to test my basic understanding. Maybe put a line on a display, or write out the numbers from 0 to 1000 over the serial, whatever. Just enough to know I get it, how it's used, but not so much that it takes over my focus on the main program at hand.

    Again, hope this helps.

    I think we all need to jump on IRC or setup a Discord for chatter. It would be kind of awesome to have some peeps to talk to in the moment.

    If nobody else does this, when I get free here soon, I will.

    Until then, the forum is best.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • PublisonPublison Posts: 10,849
    edited 2019-07-10 - 20:12:17
    THAT'S the Pothead we missed. Half of a browser page. He's still got it! :)
    Infernal Machine
  • potatoheadpotatohead Posts: 9,736
    edited 2019-07-10 - 21:16:52
    Ahem, POThead? LMAO

    Only on occasion, like camping, etc...

    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • ...And then he spoils it with a tiny reply B)
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • LOL, I can't win!

    Well, I suppose I could have teed up on Publison... good few paragraphs, but that's not nice. I kind of like nice.

    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • Peter JakackiPeter Jakacki Posts: 8,420
    edited 2019-07-11 - 00:20:57
    @potatohead - I read your post on my phone in portrait mode. Every time I scrolled up I thought I was at the end of it, but wait, there was more! :)

    While there are some good points in your post I don't agree about printing it out (do I use dot-matrix and fan-fold?) and highlighting it "old school" method. My code develops and changes way too rapidly but certainly a good code highlighter mode helps as does a hires screen to display a good section of your code that is clearly readable and then to have another pane side by side. That way you can follow the high level code across from one pane back into the other showing the lower levels. I also have a terminal screen where I try that stuff out a the same time.

    Comments? - yes, but well written code can be self-commenting so comments should clarify, rather than obscure and bury the code.

    Flowcharts and such? meh.
    Since I interact with my systems in Forth I can try out ideas and methods instantly. So the ideas themselves flow, rather than the chart :)

    Some of my stuff starts off as less than elegant, but it works. It's important to get the foundations solid before you build.
    From an ugly but working proof-of-concept "breadboard" I can then make it clean, simple, and elegant.

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    P2 +++++ TAQOZ INTRO & LINKS +++++ P2 SHORTFORM DATASHEET
    P1 +++++ Latest binary V5.4 includes EASYFILE +++++ Tachyon Forth News Blog
    Brisbane, Australia
  • potatoheadpotatohead Posts: 9,736
    edited 2019-07-11 - 01:21:03
    Peter, I agree with you. And I had to work. I had some thoughts related to how you work and FORTH that I wanted to drop in another thread so as to not clutter this one too much.

    Look for it. Let's have a chat. :D

    Or, start it. Either is fine.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • First of all thank you all. HAVING ENORMOUS FUNNNNNNNNNNNNN!!!!!!!!!!! at this game. I am good at good old fortran, and basic, spin code and propc. Assembly language and logic is self taught,MY FINAL FRONTIER per Mr. Spock, with some help from y'all and David Carrier, plus decoding the examples.

    @potatohead . When y'all refer to binaries "First thing: (If you have a pre-built binary)" I am thinking of zeros and ones. Please explain.

    I do try to follow a single track until I get it. Writing tutorials so that, because assm language is so different so I can refer back. Got fairly good at P1 asm and since I now have the p2 I am retooling and fleshing out the differeces.
    So again thanks for the help.
    Please expect more dumb questions from me.
    I teach aircraft mechanics and flying so I know there is no such thing as the dumb question.

    You guys rock.
    Martin and thanks for the support.
    “Light thinks it travels faster than anything but it is wrong. No matter how fast light travels, it finds the darkness has always got there first, and is waiting for it.”
    “You only live twice:
    Once when you are born
    And once when you look death in the face”
  • @potatohead

    I looke carefully at your post. You took some serious time in writing it.
    Thanks
    “Light thinks it travels faster than anything but it is wrong. No matter how fast light travels, it finds the darkness has always got there first, and is waiting for it.”
    “You only live twice:
    Once when you are born
    And once when you look death in the face”
  • A pre built binary is essentially a complete machine language program, ready to be loaded into and executed on the P2.

    Source code --> Assembler -->binary -->loader -->P2

    Could also be:

    Source code -->Compiler say FastSpin -->binary -->Loader --P2
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • Hope it helps. It looks like Peter and I are going to have a relevant discussion in a bit too. I'll mention you in it.

    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
  • Also gets called an executable, or app even.
    "... peers into the actual workings of a quantum jump for the first time. The results
    reveal a surprising finding that contradicts Danish physicist Niels Bohr's established view
    —the jumps are neither abrupt nor as random as previously thought."
  • @potatohead - I read your post on my phone in portrait mode. Every time I scrolled up I thought I was at the end of it, but wait, there was more! :)


    Uhm, Peter, were you implying that Parallax has their very own Mr. Popiel?
    (For those to young to be enlightned, https://en.wikipedia.org/wiki/Ron_Popeil)


    Ordnung ist das halbe Leben
    I gave up on that half long ago.........
  • ...And to put a plug out there to one of our forum members. I owe a lot of my programming style and structure techniques to Jon Williams.
    I 100% agree.
    Publison wrote: »
    THAT'S the Pothead we missed. Half of a browser page. He's still got it! :)
    I 100% agree.

    Enjoy!

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • When I did my electronics course the only programming taught was FORTRAN in Engineering. No commercial programming at all. There was a private programming course run by Control Data and it was very expensive.
    The few computers used commercially were banks and govt.

    Likewise, there were no microprocessors, and certainly no Micros. Minicomputers were just starting to appear.

    So, back then, almost all programmers were self-taught. A few years later, the computer companies offered fairly cheap programming courses on how to program their computers.

    How did I learn? I dumped the first 100 disk sectors and printed them out (like hex but the mini I learnt on was 6-bit ASCII) and decoded it. Learnt a lot!!!
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Control Data Institute, yeah. I paid for them somewhere around 1992, getting a degree to my self taught knowledge.

    No one ever wanted to see it,

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • potatohead wrote: »
    I think we all need to jump on IRC or setup a Discord for chatter. It would be kind of awesome to have some peeps to talk to in the moment.

    I internet-know some people who wrote some code to connect IRC channels and Discord channels together (so when you say something in either, it gets repeated in the other by a bot user). I could dig that up if there's interest.
  • @potatohead
    Thanks I now understand the binarie thing.
    I am writing a new pasm tutorial like the one I was working on for the P1 about passing parameters between spin and pasm. Will be posting the first draft soon.
    Would appreciate any critiques.

    Thanks
    “Light thinks it travels faster than anything but it is wrong. No matter how fast light travels, it finds the darkness has always got there first, and is waiting for it.”
    “You only live twice:
    Once when you are born
    And once when you look death in the face”
  • Hey, progress!

    Always good.

    As time permits, I will participate.
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: https://forums.parallax.com/discussion/123709/commented-graphics-demo-spin<br>
Sign In or Register to comment.