I want to add some assembly code asm to the project. I modified Makefile.am and added source+=xx.asm did not take effect. Do I need to modify configure.ac or other files?

246 views
Skip to first unread message

Dongbo Liu

unread,
May 25, 2023, 11:42:05 PM5/25/23
to WebP Discussion
I want to add some assembly code asm to the project. I modified Makefile.am and added source+=xx.asm did not take effect. Do I need to modify configure.ac or other files?

James Zern

unread,
May 26, 2023, 3:30:15 PM5/26/23
to webp-d...@webmproject.org
Hi,

On Thu, May 25, 2023 at 8:42 PM 'Dongbo Liu' via WebP Discussion <webp-d...@webmproject.org> wrote:
I want to add some assembly code asm to the project. I modified Makefile.am and added source+=xx.asm did not take effect. Do I need to modify configure.ac or other files?

In general for this project we prefer using compiler intrinsics, for local testing you can add AM_PROG_AS to configure.ac and rerun ./autogen.sh. You may need to use .s as the file extension to satisfy the default suffix rules.

Dongbo Liu

unread,
May 28, 2023, 10:59:27 PM5/28/23
to WebP Discussion, James Zern
I add AM_PROG_AS to configure.ac and rerun ./autogen.sh. but it dosen't work,  can you show me full code for this? i use nasm to compile .s,like nasm -f elf64 scan.s

Dongbo Liu

unread,
May 28, 2023, 11:01:46 PM5/28/23
to WebP Discussion, Dongbo Liu, James Zern
some error
scanLast.s: Assembler messages:
scanLast.s:1: Error: no such instruction: `uint16_t scanLast(uint16_t* coeffs)'
scanLast.s:2: Error: no such instruction: `global scanLast_test'
scanLast.s:3: Error: no such instruction: `global bswap'
scanLast.s:4: Error: no such instruction: `global scanLast'
scanLast.s:6: Error: invalid char '[' beginning operand 2 `[rdi]'
scanLast.s:7: Error: too many memory references for `vpxord'
scanLast.s:8: Error: too many memory references for `vpabsw'
scanLast.s:9: Error: too many memory references for `vpcmpw'
scanLast.s:10: Error: too many memory references for `kmovw'
scanLast.s:11: Error: no instruction mnemonic suffix given and no register operands; can't size instruction
scanLast.s:14: Error: too many memory references for `mov'
scanLast.s:15: Error: operand size mismatch for `bswap'

Dongbo Liu

unread,
May 28, 2023, 11:02:20 PM5/28/23
to WebP Discussion, Dongbo Liu, James Zern
my .s code

;uint16_t scanLast(uint16_t* coeffs);//return cmp with 0 mask
global scanLast_test
global bswap
global scanLast
scanLast:
vmovdqu ymm0, [rdi]
vpxord ymm1, ymm1
vpabsw ymm3, ymm0
vpcmpw k1, ymm1, ymm3, 01b
kmovw eax, k1
;not eax
ret
bswap:
mov rax, rdi
bswap rax
ret

James Zern

unread,
May 31, 2023, 6:49:28 PM5/31/23
to Dongbo Liu, WebP Discussion
.s usually means assembly in GAS syntax. nasm or yasm will require more work in Makefile.am. mozjpeg had some rules for .asm files before switching to CMake:
https://github.com/mozilla/mozjpeg/blob/f34f2f5bc63633d385b22bb33388d55d5b1b8c37/simd/Makefile.am#L117
Reply all
Reply to author
Forward
0 new messages