From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ifiber.tv (mail.ifiber.tv [208.84.220.140]) by sourceware.org (Postfix) with ESMTP id D873B3858D28 for ; Tue, 20 Sep 2022 04:47:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D873B3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=smwireless.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=smwireless.net Received: (qmail 2715212 invoked from network); 20 Sep 2022 04:47:18 -0000 Received: from 216.215.25.238.ifibertv.com (HELO [192.168.1.118]) (gmbgmb@smwireless.net@216.215.25.238) by mail.ifiber.tv with (TLS_AES_128_GCM_SHA256 encrypted) SMTP (4e2e9dba-389f-11ed-97c6-14feb5db6923); Mon, 19 Sep 2022 21:47:18 -0700 To: gcc-help@gcc.gnu.org Cc: mike From: mike Subject: gcc inline asm unknown mnemonics problems Message-ID: <17e1dc3f-cca4-1563-fb91-e3ab45d46cc4@smwireless.net> Date: Mon, 19 Sep 2022 21:47:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-MagicMail-OS: Linux 2.2.x-3.x X-MagicMail-UUID: 4e2e9dba-389f-11ed-97c6-14feb5db6923 X-MagicMail-Authenticated: gmbgmb@smwireless.net X-MagicMail-SourceIP: 216.215.25.238 X-MagicMail-RegexMatch: 2 X-MagicMail-EnvelopeFrom: X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_00,BODY_8BITS,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: // gcc_inline_asm_unknown_mnemonics_problems.txt To:        gcc-help@gcc.gnu.org From:    Mike Bennett             gmbgmb@smwireless.net Before I forget;  Thanks for all your good work.  I seldom get good info that has not originated from our efforts. I am having a problem using ldrexb and strexb using inline assembler.  The code is running on a RPi4 on ubuntu 20.04LTS. I get an error message "Error: unknown mnemonic `ldrexb' -- `ldrexb x0,[[sp,8]]'" I upgraded from gcc 9.4 to gcc 10.3 .  It made no difference. I found a bug report with the following title that may be the cause.     "Bug# 1017961: mozjs102: Fails to build on armel" The latest versions of gcc are prior to the date on the bug report. My questions are:     1. Is this bug the cause of my problem?     2. If this is the problem, is there a work around?     3. If the problem is something else please identify the problem? If you can, please send me an email at the address above.     Thanks Mike. The test program that illustrates the problem is shown below along with the make file output. //*************** //  test_ie.h //*************** #ifndef MACHINE_TYPE_ARM_PI   /* take out WINAPI in "static FORCEINLINE long WINAPI" line below */   static inline long InterlockedExchange( long volatile *dest, long val )   {     long ret;     __asm__ __volatile__( "lock; xchgl %k0,(%1)"                           : "=r" (ret) :"r" (dest), "0" (val) : "memory" );     return ret;    } #else     /*  %1  is output = __ret,         %3= *dest is the mutex location,         %2= val the value to put in the mutex             when locked or unlocked,             locked=1, 0=unlocked      */     static inline volatile long InterlockedExchange( long volatile *dest, long val )       {         long __ret;        /* return value, is the value of lockflag loaded by ldrex */                           /* success/fail result of strex, 0 = success */         if (val != 0)           {                 long reg_val;                 __asm__ __volatile__                         (                             "mov     %0, %2            \n\t"    /* put lock value in reg */                             "ldrexb %1, [%3]           \n\t"    /* load mutex lock word */                             "cmp    %1, #0               \n\t" /* see if mutex is free, ie lock = 0 */ /****** this cmp is required to set the condition                                                              that allows strexb to write.  ********/                              "strexb %1, %0, [%3]       \n\t" /* store lock value in %0 at mem addr %3, */                               "                       \n\t"   /* put result status in r1 */                               "cmp    %1, #0            \n\t" /* if strex was successful %1 will be                             "                        \n\t"   /* a zero */                             "beq    ok                \n\t"    /* if success, set return value */                             :[reg_val] "=r" (reg_val), [__ret] "=r" (__ret)                             :[val] "m" (val), [dest] "m" (dest)                             : "cc","memory"                          );                    __ret = 1;    /* failed to get control of mutex */                 goto n_ok;                 ok: __ret = 0;            }           else              {                 *dest = val;                 __ret = val;               }     n_ok:     return __ret;     } #endif //******************* // gcc_pi_asm_test.c //******************* #include #include #include #include #include #include #include #include #include #define MACHINE_TYPE_ARM_PI TRUE #include struct timespec delay_0___1_sec = {0,   1000000 };       //delay 0.001 sec int nanosleep(const struct timespec *, struct timespec *); long lock_flag; //********************************** //  int main() //********************************** int main() {   long ret_val;     while (  (ret_val = InterlockedExchange( &lock_flag, 1) ) != 0)     {         ret_val = nanosleep( &delay_0___1_sec, NULL);   // 1 msec      }     return 0;  } //********************* //    make output //********************* mike@pi44:/media/mike/F512_5/Mike/Software/0_Pi4_builds/gcc_pi_asm_test/source$ make gcc -g -c -std=iso9899:1999 -o obj/gcc_pi_asm_test.o gcc_pi_asm_test.c -I../include /tmp/ccVbuJ1z.s: Assembler messages: /tmp/ccVbuJ1z.s:26: Error: unknown mnemonic `ldrexb' -- `ldrexb x0,[[sp,8]]' /tmp/ccVbuJ1z.s:28: Error: unknown mnemonic `strexb' -- `strexb x0,x1,[[sp,8]]' /tmp/ccVbuJ1z.s:25: Error: undefined symbol sp used as an immediate value make: *** [makefile:37: obj/gcc_pi_asm_test.o] Error 1 mike@pi44:/media/mike/F512_5/Mike/Software/0_Pi4_builds/gcc_pi_asm_test/source$