GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    mcc (mcc@mastodon.social)'s status on Wednesday, 22-Jan-2025 10:40:42 JST mcc mcc

    #BabelOfCode 2024
    Week 3
    Language: x86_64 assembly [AMD64] (macroassembler: GNU as/gas)

    PREV WEEK: https://mastodon.social/@mcc/113783248514095140
    RULES: https://mastodon.social/@mcc/113676228091546556

    I planned ASM for today and when I saw the challenge *almost* bounced to TCL, because I *don't* wanna write a parser in ASM. But the language here is exceedingly regular, so probs a state machine is enough.

    Successfully ran this hello world https://cs.lmu.edu/~ray/notes/gasexamples/ which I think should be all I need to start.

    In conversation Wednesday, 22-Jan-2025 10:40:42 JST from mastodon.social permalink

    Attachments

    1. No result found on File_thumbnail lookup.
      mcc (@mcc@mastodon.social)
      from mcc
      #BabelOfCode 2024 Week 2 Language: Forth Confidence level: Low PREV WEEK: https://mastodon.social/@mcc/113743302074837530 NEXT WEEK: https://mastodon.social/@mcc/113867584791780280 RULES: https://mastodon.social/@mcc/113676228091546556 So today's challenge looks *absurdly* easy, to the point I'm mostly just suspicious that part 2 will get hard. I figure this is an okay time to burn Forth. I'm wanting to save Fortran for a week I can use the matrix ops. This puzzle looks suspiciously like part 2 will turn into a 2-dimensional array problem.
    2. No result found on File_thumbnail lookup.
      mcc (@mcc@mastodon.social)
      from mcc
      I have been too busy to do AOC this year and will be all month So I'm thinking I'm going to do AOC 2024, *in 2025*, under the following rules: - One challenge per week. - I don't have to perform a challenge every week. The goal is to finish by the start of December. - I have to do a different programming language every time. - C, C++ and Objective-C are not eligible languages. - If I make an honest attempt at a language and fail, I may retry in Go (but only Go) (I need to learn Go)
    3. No result found on File_thumbnail lookup.
      gasexamples
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 22-Jan-2025 10:40:42 JST mcc mcc
      in reply to

      My language "confidence level" for this week is high, but down to medium-high for step 2 (because obvs I don't know WHAT they'll throw at me at step 2). I'm kinda unenthused about the gas macro language. The macro language documentation ( https://sourceware.org/binutils/docs/as/Macro.html + https://sourceware.org/binutils/docs/as/Altmacro.html , I think that's literally all they wrote ) is sketchy and unclear. Can macros take a macro name as argument and invoke the passed-in macro? I literally can't tell. I'm going to uncover syntax by trial and error

      In conversation Wednesday, 22-Jan-2025 10:40:42 JST permalink

      Attachments



    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 22-Jan-2025 10:41:09 JST mcc mcc
      in reply to

      I've decided to add a new rule to my challenge, which is in addition to doing a different language every week I'm going to try to use exclusively *languages I haven't programmed in before*.

      If that's the rule, x86_64 is a stretch as I've *written* x86_64— but I count it as valid, because I've never written a whole AMD64 *program*, only snippets embedded in a C file or OllyDbg-injected into an exe at runtime. Only ASMs I've written whole programs in are MIPS and LLVM in-memory representation.

      In conversation Wednesday, 22-Jan-2025 10:41:09 JST permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 22-Jan-2025 10:41:09 JST mcc mcc
      in reply to

      Finding many things that are just sort of It's Assumed You Know This but may or may not be written anywhere. Like, there's a "movb" instruction which is not in the instruction reference I'm using and is not recognized by my syntax highlighter, but gas accepts it.

      Question. I do

      mov %al, %esi

      It says operand type mismatch. OK. I think I can simulate this with

      mov $0, %rax
      mov $eax, $esi

      BC non-al bits of rax get cleared in instruction 1.

      …But what's the "widening"/truncating version of mov?

      In conversation Wednesday, 22-Jan-2025 10:41:09 JST permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 22-Jan-2025 10:41:09 JST mcc mcc
      in reply to

      Ah… well… that did not take long

      In conversation Wednesday, 22-Jan-2025 10:41:09 JST permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/113/868/044/817/384/061/original/290fa8a2b670efc4.png
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 22-Jan-2025 10:41:09 JST mcc mcc
      in reply to

      I'm sorry the x86_64 multiply instruction works fucking *how*. What fucking century is it

      In conversation Wednesday, 22-Jan-2025 10:41:09 JST permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 22-Jan-2025 10:41:09 JST mcc mcc
      in reply to

      So it took longer than I'd hoped, but I now have a working first-pass AMD64 ASM program that can decode an ASCII number in the .data segment and print it out again.

      https://github.com/mcclure/aoc2024/blob/ad0a3f670a4ed6d403f81863977175315284d220/03-01-multiply/src/number-echo.s

      Build instructions in adjacent run.txt.

      I have some questions.

      (1 of 2). I think I don't like GNU/AT&T assembly format and would like to switch to Intel assembly format. Is Intel format… documented… somewhere? This is the closest I found. https://sourceware.org/binutils/docs/as/i386_002dVariations.html

      In conversation Wednesday, 22-Jan-2025 10:41:09 JST permalink

      Attachments


    • Embed this notice
      I Can't Believe It's Not Zero! (steve@discuss.systems)'s status on Thursday, 23-Jan-2025 01:15:52 JST I Can't Believe It's Not Zero! I Can't Believe It's Not Zero!
      in reply to
      • William D. Jones
      • disregard Joe Groff
      • Paul Khuong

      @joe @cr1901 @pkhuong (They did it for 8->16, 16->32, and SSE->AVX/AVX512. And each time they managed to find a way to make it worse.)

      In conversation Thursday, 23-Jan-2025 01:15:52 JST permalink
    • Embed this notice
      I Can't Believe It's Not Zero! (steve@discuss.systems)'s status on Thursday, 23-Jan-2025 01:15:53 JST I Can't Believe It's Not Zero! I Can't Believe It's Not Zero!
      in reply to
      • William D. Jones
      • disregard Joe Groff
      • Paul Khuong

      @joe @cr1901 @pkhuong Intel's dedication to making that particular mistake _over and over again_ will never cease to amaze me.

      In conversation Thursday, 23-Jan-2025 01:15:53 JST permalink
      Rich Felker repeated this.
    • Embed this notice
      disregard Joe Groff (joe@f.duriansoftware.com)'s status on Thursday, 23-Jan-2025 01:15:54 JST disregard Joe Groff disregard Joe Groff
      in reply to
      • I Can't Believe It's Not Zero!
      • William D. Jones
      • Paul Khuong

      @steve @cr1901 @pkhuong nonetheless it is absolutely the right thing for a contemporary ISA to not have unnecessary partial register updates in the first place, to cr1901’s point about risc-v. luckily AMD at least figured that out by the time they designed x86-64

      In conversation Thursday, 23-Jan-2025 01:15:54 JST permalink
    • Embed this notice
      I Can't Believe It's Not Zero! (steve@discuss.systems)'s status on Thursday, 23-Jan-2025 01:15:55 JST I Can't Believe It's Not Zero! I Can't Believe It's Not Zero!
      in reply to
      • William D. Jones
      • disregard Joe Groff
      • Paul Khuong

      @cr1901 @joe @pkhuong dependency-breaking xor/movzx are "free" (they have to be decoded, but they don't need to execute).

      In conversation Thursday, 23-Jan-2025 01:15:55 JST permalink
    • Embed this notice
      William D. Jones (cr1901@mastodon.social)'s status on Thursday, 23-Jan-2025 01:15:56 JST William D. Jones William D. Jones
      in reply to
      • I Can't Believe It's Not Zero!
      • disregard Joe Groff
      • Paul Khuong

      @joe @steve @pkhuong Ya know, if an extra xor/movsx/movsxd is less performance penalty than eating a partial load, I'm beginning to realize why RISC-V zero/sign-extends even byte loads...

      In conversation Thursday, 23-Jan-2025 01:15:56 JST permalink
    • Embed this notice
      disregard Joe Groff (joe@f.duriansoftware.com)'s status on Thursday, 23-Jan-2025 01:15:57 JST disregard Joe Groff disregard Joe Groff
      in reply to
      • I Can't Believe It's Not Zero!
      • William D. Jones
      • Paul Khuong

      @steve @cr1901 @pkhuong and even with that, compilers will often sever the dependency explicitly by doing an xor or movsx/xx to the destination at the start of an operation chain

      the other thing that makes 16 bit operations slow on some uarches iirc is a penalty for the operand size prefix byte

      In conversation Thursday, 23-Jan-2025 01:15:57 JST permalink
    • Embed this notice
      William D. Jones (cr1901@mastodon.social)'s status on Thursday, 23-Jan-2025 01:15:58 JST William D. Jones William D. Jones
      in reply to
      • Paul Khuong

      @pkhuong @mcc What makes 8 bit ops faster, even tho both will have partial deps?

      In conversation Thursday, 23-Jan-2025 01:15:58 JST permalink
    • Embed this notice
      I Can't Believe It's Not Zero! (steve@discuss.systems)'s status on Thursday, 23-Jan-2025 01:15:58 JST I Can't Believe It's Not Zero! I Can't Believe It's Not Zero!
      in reply to
      • William D. Jones
      • Paul Khuong

      @cr1901 @pkhuong @mcc there’s just a special fast-path for them

      In conversation Thursday, 23-Jan-2025 01:15:58 JST permalink
    • Embed this notice
      Paul Khuong (pkhuong@discuss.systems)'s status on Thursday, 23-Jan-2025 01:15:59 JST Paul Khuong Paul Khuong
      in reply to
      • William D. Jones

      @cr1901 @mcc 16 bit ops are extra slow nowadays (no one uses them).

      In conversation Thursday, 23-Jan-2025 01:15:59 JST permalink
    • Embed this notice
      William D. Jones (cr1901@mastodon.social)'s status on Thursday, 23-Jan-2025 01:16:00 JST William D. Jones William D. Jones
      in reply to
      • Paul Khuong

      @pkhuong @mcc What's special about 16-bit partial deps that doesn't apply to 8-bit ones?

      In conversation Thursday, 23-Jan-2025 01:16:00 JST permalink
    • Embed this notice
      Paul Khuong (pkhuong@discuss.systems)'s status on Thursday, 23-Jan-2025 01:16:01 JST Paul Khuong Paul Khuong
      in reply to

      @mcc movzx/sx for widening. regular mov for narrowing, but be mindful of partial dependencies on 8 and 16 bit destinations (16b in particular).

      The size suffix is an at&t special and not part of the ISA (which also has movd/movq…)

      In conversation Thursday, 23-Jan-2025 01:16:01 JST permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.