Stationeers: Learning the powerful Stack to improve your IC programming abilities significantly.

Поделиться
HTML-код
  • Опубликовано: 6 сен 2024
  • In this episode I finally got into the very confusing stack programming. I spent hours figuring out how it works and used it to quadruple my LARrE program. I can now use 1 LARre to control up to 30 hydroponics devices. What a massive improvement.

Комментарии • 18

  • @cowsareevil7514
    @cowsareevil7514 Месяц назад +2

    Nice use of the stack, and you are not the only one who regularly get mixed up with the stack pointer.
    A quick tip. The hash command can help for transcribing the name hash values. HASH("415") will generate the number for you.

    • @NavyOldsaltGamer
      @NavyOldsaltGamer  Месяц назад

      Wow, cool to see your name in my video comments. I have learned a lot of great info from your videos. I watch every one.

    • @ajfairchild30
      @ajfairchild30 Месяц назад

      I came here to say exactly this. It will save you from need to grab the tablet, read the long randomized number and type it back into the code. Instead just use the HASH("insert tray name") and boom saved you a ton of time setting it up

  • @ajfairchild30
    @ajfairchild30 Месяц назад +2

    A tip that i use when setting up a stack is i put a "push 0" at the end so that i can use a "beqz" to reset the sp when it reaches the end makes loopijg the stack very easy. It looks like this:
    Setstack
    move sp 0
    push something
    push something
    push 0
    Reset:
    move sp 0
    Loop
    add sp sp 1
    peek r0
    beqz r0 Reset
    *Insert code here*
    j Loop
    This allows the code to check each stack item before resetting itself. You never need to change the line that was "beq sp 25 Start" part as it does it by itself.

  • @ajfairchild30
    @ajfairchild30 Месяц назад +1

    You also do not need the j Harvest when the Harvest jump location is two lines down, you can just let the code flow to it.
    Not sure if you were using it for debugging or what but that line never gets read anyways with the j Loop right infront of it.

  • @charlesheath7571
    @charlesheath7571 Месяц назад +1

    Chief I think “peek” Is better than “pop” , if memory serves me right, peek does what it says, it looks at the sp and not remove. Thus to move the so all u need is add 1, just remember, when you get it the end of the stack you have to reset back to start

    • @NavyOldsaltGamer
      @NavyOldsaltGamer  Месяц назад

      humm should switch that!

    • @NavyOldsaltGamer
      @NavyOldsaltGamer  Месяц назад

      Switched it to peek thanks!

    • @charlesheath7571
      @charlesheath7571 Месяц назад +1

      @@NavyOldsaltGamer another debug tool that might be helpful. You can with a different chip or basic logic chips, read the line number of a housing and send it to a display. In case your code is getting stuck in a subroutine. You will find out where it’s stopping, jumping branching etc at

    • @NavyOldsaltGamer
      @NavyOldsaltGamer  Месяц назад

      @@charlesheath7571 Oh that's a cool tip!

  • @DeltaV3328
    @DeltaV3328 Месяц назад +1

    I think the stack lives in the housing, so you can code a chip with the stack info take it out and recode the chip with your running program and the stack will remain

    • @ajfairchild30
      @ajfairchild30 Месяц назад

      This is correct. Although, if you have the space on your chip, it makes it waaayyy easier to add more trays or edit something if need be. Only time I set the stack in a separate code is when I'm writing massive codes that take 100+ lines just to save space.

    • @ajfairchild30
      @ajfairchild30 Месяц назад

      You can always do something like this if you don't want it at the top
      jal SETSTACK
      Loop:
      Insert code here
      j Loop
      SETSTACK:
      move sp 0 (use this to make sure you always overwrite the stack instead of adding to the end)
      push something
      push something
      j ra

  • @catzual
    @catzual Месяц назад +1

    Line 56 and 60..are the same is 60 needed? Good job on everything!!!

    • @greybeardsastro3477
      @greybeardsastro3477 Месяц назад

      Line 56 and 60 are the same and need to be to activate LARrE at two different locations. In the video I explained line 60 was for debugging and not needed.

    • @catzual
      @catzual Месяц назад

      @@greybeardsastro3477 i remember you saying about debugging might have been distracted..