I switched from ASSEMBLY to C and it made my code better...

Поделиться
HTML-код
  • Опубликовано: 27 янв 2025
  • НаукаНаука

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

  • @l4ppland
    @l4ppland 3 дня назад +117

    Welcome to yet another recreation of programming session with uh mistuh zozin

  • @5ilkyYT
    @5ilkyYT 3 дня назад +49

    I like the "chat in subtitles" popup now, much better than finding it yourself

    • @artemiasalina1860
      @artemiasalina1860 3 дня назад +6

      I wonder how many people know that they can grab the subtitles and drag them to a different position.

    • @doodocina
      @doodocina 3 дня назад

      @@artemiasalina1860doesn't work on phones btw

    • @Crimera137
      @Crimera137 2 дня назад +1

      sunny working low wage

  • @the_worst_coconut
    @the_worst_coconut 3 дня назад +20

    "even though it's not supposed to segfault in my opinion"

  • @paxdriver
    @paxdriver 2 дня назад +4

    The guy who made the "hide your kids, hide your wife" remix simply MUST make an album from your video beat boxes and ballads. I vote for "let's fucking go" for the single.

  • @sil3nt810
    @sil3nt810 3 дня назад +10

    10:22 these are the callee saved registers. It's part of the System V ABI calling convention that these registers retain their value after a function call.

  • @bbq1423
    @bbq1423 2 дня назад +3

    8:44 Reason for the pie errors is most likely since you were using instructions which operate on absolute addresses (any time you use addresses of static values), this is because of ASLR, which makes it so that the binary really can’t know what the label address will really be. Static labels are usually addressed relative to the instruction pointer instead (RIP relative addressing), so instead of using load label instructions, you’d use the LEA instruction (load effective address) first to get the actual address of the label and then do the load. With this, I think the pie errors would disappear.

  • @CacdayBirthdus
    @CacdayBirthdus 2 дня назад +6

    Title goes hard

  • @desertfish74
    @desertfish74 3 дня назад +16

    The Commodore Amiga had one of the first preemptive multitasking operating systems running on home computers. On the original Amiga 1000, it was running on a 8 mhz M68000 CPU with 256Kb RAM. Can your C do that!? Huh!? Huh!?

    • @MythiPlayz
      @MythiPlayz 3 дня назад +1

      I studied that processor in the microprocessors course I took at university. That little Motorola demon was ahead of its time

    • @TheCommunistRabbit
      @TheCommunistRabbit 3 дня назад +1

      Well yes

    • @ezbody
      @ezbody 3 дня назад +1

      And so was Atari ST, it was surreal to watch everyone typing away in DOS while you had this graphic OS to play with.

    • @desertfish74
      @desertfish74 3 дня назад

      @ The Atari ST didn't have preemptive multitasking, it was cooperative multitasking (as far as I am aware of how the ST worked.)

    • @georgerogers1166
      @georgerogers1166 2 дня назад +1

      Yes. Unix was on even more crude hardware. PDP11 only had 64K of Ram.

  • @AeroSW
    @AeroSW 2 дня назад +1

    @Tsoding Daily, just swap the dead context onto the end of the stack, then pop it off the stack. That is a way to release the data without corrupting the stack.

  • @bastardferret869
    @bastardferret869 22 часа назад

    Digging this channel. You're a true 'c'had.

  • @gsestream
    @gsestream 3 дня назад +1

    how about switching function call pointers in c. then the stack stuff would automatically switch internally by the compiler. then each thread function call only does small part of the thread work at a time. switching. then you only deal with stuff in memory, not in registers, those will be handled automatically, after the function call switches. in pure c. well, thread switching vs fully pipelined in single core. pipeline flow vs switch. function pointer call switching assumes each threading function has their own internal data in their own memory addresses. no manual thread management required. just c code. opencl c does not have malloc. static array allocations only. if you use c only, you only get to push and pop, not have to worry about the internals of the stack. c is for abstraction reasons. c is designed to avoid very low level stuff in asm. you are trying to do what a c compiler does with the environment switch code in asm. no function pointers in opencl c also. no assembler in opencl c c99. great, the program only can yield, back to os. partitioned workload would yield the better c-only definition and operation. so why did you make da_append as a macro, not a normal function. also why re-implement what is already native in c, the function call mechanism. pointless pointers. instead of yield function call in the partial functions, just make partial data processing in the functions. no need to mess with the stack. just use c function calls. so why not just code single core threads instead. then its not manually flow controlled but automatically by the single core threads. threads if you can specify that they dont run on a separate core specifically. on single core you are guaranteed to have sequential exec of instructions. in multi-core you are not. not cursed. *entrely.

  • @bruterasta
    @bruterasta 3 дня назад +1

    Having chat messages as a subtitles is great idea.

  • @berndeckenfels
    @berndeckenfels День назад

    Quite suprising that you can just allocate stacks, with all the modern non-execution, rop prevention, frame pointer and control flow protections. But I guess they are mostly opt-in.

  • @__gadonk__
    @__gadonk__ 3 дня назад +15

    Amista Azozin

  • @rasulseidagul
    @rasulseidagul 3 дня назад +2

    1:11:47 Do paging instead of malloc and the stack would be aligned to 16 bytes automatically.

    • @mbarrio
      @mbarrio 3 дня назад

      posix_memalign seems simpler than paging right?

  • @berndeckenfels
    @berndeckenfels 3 дня назад +1

    40:28 I think more reasons for malloc returning null nowadays are cgroup or ulimit or Container limits

  • @chaitanyadubakula
    @chaitanyadubakula 2 дня назад +1

    Would it be possible to write the entire coroutines library in C3 only instead of depending on a dynamic C library? I saw that C3 also some inline ASM features, so I think yes.

  • @naranyala_dev
    @naranyala_dev 2 дня назад

    the stream is getting more interesting, awesome

  • @caffidev
    @caffidev 2 дня назад +2

    New thumbnail 👍

  • @yglyglya
    @yglyglya 3 дня назад +3

    1:19:00 let it leak, let it leak

    • @l4ppland
      @l4ppland 2 дня назад

      @@yglyglya govnos in haskell when

  • @berndeckenfels
    @berndeckenfels 3 дня назад

    1:20:27 no need to swap, just copy (if not last)

  • @sinom
    @sinom 3 дня назад +1

    "a language where you could += but also mod"
    That would be a ternary assignment operator which would be kinda weird. Like would it be written as
    "a +%= b, c"
    Or something like that?
    I think in c you can technically just do that with
    (a += b) %= c
    But that is definitely cursed

    • @colonthree
      @colonthree 3 дня назад

      Signed modulo (I use this for rotations from -360 to 360): x - x / y * y

    • @tylovset
      @tylovset 2 дня назад

      For `a = (a + 1) % b`, it's much faster to do `a += 1; if (a == b) a = 0;` because a == b is unlikely and therefore near free.
      Btw, (a += b) returns an r-value, so it can't be assigned.

    • @rogo7330
      @rogo7330 2 дня назад

      Just make it a function. Or drop the mathematics way of writing expressions and go back to stack monke: "operator arg arg arg", where each individual "arg" can be (or, in fact, is, if you treat each name access as "read-from-name" operation) another expression. If you really incist on a mathematical expressions with priorities and other crap (instead of just grouping things by parenthesies and position on the stack or by assigning to a new names), then just introduce a special syntax, like double-parenthesies-enclosed expressions in bash "((x + y/2))".

  • @shrddr
    @shrddr 3 дня назад +2

    >makes lagrange-uxn video unlisted
    >references it in every subsequent video

    • @TEHNOTRAHER
      @TEHNOTRAHER 3 дня назад

      why did he unlisted it lol?

  • @nevokrien95
    @nevokrien95 3 дня назад +2

    There is some stuff that the refrence code missed in long jump. Specifcly it forgot that simd registers exist

  • @kiosmallwood576
    @kiosmallwood576 3 дня назад

    This one is very satisfying. So glad I caught it live.

  • @Sitris-h7q
    @Sitris-h7q 3 дня назад +4

    Why not program in an IR instead? It can be similar to architecture agnostic assembly.

    • @alvinmiranda7574
      @alvinmiranda7574 3 дня назад +3

      Do you mean like llvm ir?.Then the problem will be that your code can only be compiled by a single compiler.Also yes gcc also has a ir but an ir is not necessary to make a compiler to begin with I think tcc does not have a ir.

    • @ratchet1freak
      @ratchet1freak 3 дня назад +1

      because this kind of thing will not be abstracted away by an IR, the set of registers to save is very specific to the architecture and OS calling convention

    • @xravenx24fe
      @xravenx24fe День назад

      @@ratchet1freak Yeah and if it's as trivial as a single pair of save/load, I'm definitely on the side that's saying it's easier just to hard code stuff sometimes too lol

  • @felipedilho
    @felipedilho 2 дня назад

    I don't know if it would be quite so simple, but couldn't he use fasmg to code in a "high-level" assembly and just put the respective processor instructions file to make his code portable? I would like to learn more about this, could be a nice recreational programming live subject, ... just saying.

    • @Tezla0
      @Tezla0 2 дня назад

      "High-level" assembly is called C

    • @rogo7330
      @rogo7330 2 дня назад

      @@Tezla0 you're very wrong about C and its "close to assembly" features, my friend. C is just about working on things that can have addresses, "memory-oriented" design if you will. It does a lot of things that you would hope to just turn off but it's impossible by design, unless you make a compiler treat your C code way out of spec.

    • @felipedilho
      @felipedilho День назад

      @@Tezla0 actually no, there are several examples where C compilers are unable to generate the machine code with the least amount of CPU cycles even with the -O3 flag (here is an example: ruclips.net/video/B2BFbs0DJzw/видео.html). One could have a program written in a x64 assembly style, but with a ARM or even RISC-V instruction headers that translated each given CISC instruction of x64 to an equivalent minimal number of instructions of a ARM or RISC-V CPU (like a simple dictionary). Thus guaranteeing that the code is the most efficient translation of your x64 assembly code into any other architecture for which you have this instruction header dictionary (modulo some strange way in which you could compress the translated instructions of a group of x64 instructions into a smaller set of instructions than a direct replacement, but I am not sure how this would be done and I doubt any C compiler to be able to do this anyway).

  • @berndeckenfels
    @berndeckenfels 3 дня назад

    Hm Not sure if you can interrupt, but you can wrap io with a yield block

  • @thartanian
    @thartanian 2 дня назад

    good stuff

  • @berndeckenfels
    @berndeckenfels 3 дня назад

    1:45:10 coroutine id moves around when you get swapped into a freed Slot (ah you talked about it later)

  • @uniers
    @uniers 3 дня назад +1

    What about LLVM IR ?

  • @hubstrangers3450
    @hubstrangers3450 День назад

    Thank you....

  • @user1lyy
    @user1lyy 2 дня назад

    Off topic but what's the name of the font hes using?

  • @namiflowers00
    @namiflowers00 3 дня назад

    this is truly epic, meine freunde

  • @atxorsatti
    @atxorsatti 2 дня назад +1

    WAITT
    how are you making money? I thought you stream _for_ money

  • @AlguienMas555
    @AlguienMas555 2 дня назад

    🤙

  • @kselnaag2482
    @kselnaag2482 3 дня назад

    Expecting to rewrite everything on C3 not only C, waiting C3 and preemptive concurrency =D

  • @meryplays8952
    @meryplays8952 3 дня назад

    c-- is an interesting idea, currently it is unmaintained

  • @artemiasalina1860
    @artemiasalina1860 3 дня назад

    With all the legalese in GCC documentation I guess they really believe that code is law.

  • @heavymetalmixer91
    @heavymetalmixer91 3 дня назад

    That's why C was created in the first place :v

  • @crino_enjoyer
    @crino_enjoyer 3 дня назад

    Mr zozin mr zozin
    I think the lagrange video got deleted .

  • @ryzh6544
    @ryzh6544 3 дня назад +1

    da_like

  • @thanatosor
    @thanatosor 2 дня назад

    ASM is like Meta of C 😂

  • @seventhtenth
    @seventhtenth 2 дня назад

    THUMBNAIL

  • @ahmadumar9387
    @ahmadumar9387 3 дня назад

    bro, your YT-avatar looks more satisfied than you... something goes wrong😅

  • @RickeyBowers
    @RickeyBowers День назад

    It says more about the programmer than the language, lol.

  • @RicardoValero95
    @RicardoValero95 3 дня назад

    next time coroutines in wasm :p

  • @lolcat69
    @lolcat69 3 дня назад

    hallo mista zozin!

  • @theboomerperspective2478
    @theboomerperspective2478 3 дня назад +2

    The intro is stupid, I have no reason to watch the video now since I know how it ends

    • @RustIsWinning
      @RustIsWinning 3 дня назад +4

      It's about the journey, not the destination.

    • @theboomerperspective2478
      @theboomerperspective2478 3 дня назад

      @@RustIsWinning Good for you. That's wildly subjective, it ruins it for me.

    • @MrMeltdown
      @MrMeltdown 3 дня назад

      @@theboomerperspective2478
      You sure you are actually a boomer?

    • @Leonhart_93
      @Leonhart_93 3 дня назад +2

      What do you think this is, TV entertainment so you don't want spoilers? 😂
      Knowing bits of knowledge beforehand helps with easier understanding later.

    • @theboomerperspective2478
      @theboomerperspective2478 3 дня назад

      @ If you are THAT slow then yes, maybe you shouldn't comment then

  • @matthartley6537
    @matthartley6537 3 дня назад

    Hello memory_leaker69!