speed-highlight / core

A lightweight syntax highlighter written in JavaScript
https://speed-highlight.github.io/core/examples/
Creative Commons Zero v1.0 Universal
268 stars 15 forks source link

[BUG] Assembly instructions with numbers in them are not correctly highlighted. #39

Closed mcourteaux closed 9 months ago

mcourteaux commented 1 year ago

See the picture. image

Also, comments (starting with # at the end of a line, common for the GNU Assembler) are not properly matched. It seems that only ; is considered a comment: https://github.com/speed-highlight/core/blob/ee66dcff18babeb835b5b624e982cd18e81b74a5/src/languages/asm.js#L4

mcourteaux commented 1 year ago

Here is a block of assembly that you could add to the test.asm:

    vmovddup    2536(%rbx,%rax), %xmm1          # xmm1 = mem[0,0]
    vmovaps 2528(%rbx,%rax), %xmm3
    vmovaps 2544(%rbx,%rax), %xmm2
    vmovaps 2560(%rbx,%rax), %xmm0
    vmaxps  %xmm1, %xmm3, %xmm1
    vmovshdup   %xmm1, %xmm4            # xmm4 = xmm1[1,1,3,3]
    vmaxss  %xmm4, %xmm1, %xmm1
    vmaxps  %xmm0, %xmm2, %xmm4
    vpermilpd   $1, %xmm4, %xmm5        # xmm5 = xmm4[1,0]
    vmaxps  %xmm5, %xmm4, %xmm4
    vmovshdup   %xmm4, %xmm5            # xmm5 = xmm4[1,1,3,3]
    vmaxss  %xmm5, %xmm4, %xmm4
    vmaxss  %xmm1, %xmm4, %xmm1
    vbroadcastss    %xmm1, %xmm1
    vsubps  %xmm1, %xmm3, %xmm3
    vmulps  %xmm3, %xmm8, %xmm4
    vroundps    $1, %xmm4, %xmm4
    vfnmadd231ps    %xmm9, %xmm4, %xmm3     # xmm3 = -(xmm4 * xmm9) + xmm3
    vmulps  %xmm3, %xmm3, %xmm5
    vmovaps %xmm10, %xmm6
    vfmadd213ps %xmm11, %xmm5, %xmm6    # xmm6 = (xmm5 * xmm6) + xmm11
    vmulps  %xmm6, %xmm5, %xmm6
    vfmadd213ps %xmm3, %xmm3, %xmm6     # xmm6 = (xmm3 * xmm6) + xmm3
    vmovaps %xmm12, %xmm3
    vfmadd213ps %xmm13, %xmm5, %xmm3    # xmm3 = (xmm5 * xmm3) + xmm13
    vfmadd213ps %xmm6, %xmm5, %xmm3     # xmm3 = (xmm5 * xmm3) + xmm6
    vcvttps2dq  %xmm4, %xmm4
    vpminsd %xmm14, %xmm4, %xmm4
    vpmaxsd %xmm15, %xmm4, %xmm4
    vpslld  $23, %xmm4, %xmm4
    vpaddd  %xmm7, %xmm4, %xmm4

Note how Github also incorrectly highlights these.

github-actions[bot] commented 9 months ago

:tada: This issue has been resolved in version 1.2.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: