armasm | ARM inline assembler for Python

 by   stephanh42 Python Version: Current License: MIT

kandi X-RAY | armasm Summary

kandi X-RAY | armasm Summary

armasm is a Python library typically used in Internet of Things (IoT), Raspberry Pi applications. armasm has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can download it from GitHub.

ARM inline assembler for Python. This module allows creation of new functions in ARM assembler (machine language) which can be directly called from Python.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              armasm has a low active ecosystem.
              It has 4 star(s) with 2 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              armasm has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of armasm is current.

            kandi-Quality Quality

              armasm has 0 bugs and 0 code smells.

            kandi-Security Security

              armasm has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              armasm code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              armasm is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              armasm releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              It has 721 lines of code, 46 functions and 3 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed armasm and discovered the below as its top functions. This is intended to give you an instant insight into armasm implemented functionality, and help decide if they suit your requirements.
            • Parse a load store
            • Encode the given fields
            • Parse a register
            • Raise an error
            • Parse DPI instruction
            • Parse a signed register
            • Parse instruction operand
            • Parse a shift field
            • Wrap a LDR instruction
            • Get the address of a constant pool
            • Encodes an immediate value into an integer
            • Parse an immediate value
            • Parse a move instruction
            • Parse a DPI instruction
            • Parse a status register
            • Parse a status register
            • Parse a condition
            • Parse the LSA condition
            • Parse a branch condition
            • Parse push pop
            • Parse the multiplication operator
            • Parse a SWI condition
            • Encode a long offset
            • Parse a CLZ condition
            • Parse MRS condition
            • Parse bx
            Get all kandi verified functions for this library.

            armasm Key Features

            No Key Features are available at this moment for armasm.

            armasm Examples and Code Snippets

            No Code Snippets are available at this moment for armasm.

            Community Discussions

            QUESTION

            how arm-thumb instruction set's blx instruction support 4MB range
            Asked 2022-Jan-18 at 16:04

            Read from https://www.keil.com/support/man/docs/armasm/armasm_dom1361289866046.htm that arm-thumb instruction's blx instruction can support maximum 4MB of jump range.

            But as far as I know, arm-thumb instruction is only 16 bits long, so how can 16 bits contain offset of 4MB?

            ...

            ANSWER

            Answered 2022-Jan-18 at 16:04

            In the original Thumb instruction set, the BL instruction comprised two 16 bit instructions encoded such:

            Source https://stackoverflow.com/questions/70749497

            QUESTION

            Unable to blink LED on TM4C123G?
            Asked 2021-Dec-30 at 16:18

            My TI Tiva ARM program is not working on TM4C123G. Using board EK TM4C123GXL. Program doesn't blink on board RGB LEDs. I am able to run other example program to check the LEDs, this program is from textbook TI TIVA ARM PROGRAMMING FOR EMBEDDED SYSTEMS. Need help to debug this program. Thanks

            Code:

            ...

            ANSWER

            Answered 2021-Dec-30 at 16:18

            If you must use a counting-loop delay, you must at least declare the control variables volatile to be sure they will not be optimised away:

            Source https://stackoverflow.com/questions/70514774

            QUESTION

            Avoiding hard-number shift of flexible second operand in ASM
            Asked 2021-Dec-17 at 17:29

            This question pertains to the ARM assembly language.

            My question is whether it is possible to use a macro to replace the immediate value in the ASM code to shift a register value so that I don't have to hard-code the number.

            I'm not sure whether the above question makes sense, so I will provide an example with some asm codes:

            So there exist few instructions such as ror instruction in the ARM (https://developer.arm.com/documentation/dui0473/m/arm-and-thumb-instructions/ror), where it is possible to use a register value to rotate the value as we wish:

            ...

            ANSWER

            Answered 2021-Dec-16 at 19:08

            The ARM64 orr immediate instruction takes a bitmask immediate, see Range of immediate values in ARMv8 A64 assembly for an explanation. And GCC has a constraint for an operand of this type: L.

            So I would write:

            Source https://stackoverflow.com/questions/70383795

            QUESTION

            Why does gcc, with -O3, unnecessarily clear a local ARM NEON array?
            Asked 2021-Oct-11 at 13:55

            Consider the following code (Compiler Explorer link), compiled under gcc and clang with -O3 optimization:

            ...

            ANSWER

            Answered 2021-Oct-11 at 10:32

            Short answer: welcome to GCC. Do not bother optimizing anything while you are using it. And Clang isn't better either.

            Secret tip: Add ARM and ARM64 components to Visual Studio, and you'd be surprised how well it works. The problem is however, it generates COFF binary, not ELF, and I haven't been able to find a converter.

            You can use Ida Pro or dumpbin and generate a disassembly file and it look. like:

            Source https://stackoverflow.com/questions/69488537

            QUESTION

            Loading 16-bit (or bigger) immediate with a Arm inline GCC assembly
            Asked 2021-May-30 at 13:42

            Note: Just here for the brevity the examples are simplified, so they do not justify my intentions. If I would be just writing to a memory location exactly like as in the example, then the C would be the best approach. However, I'm doing stuff where I can't use C so please do not downvote just because this specific example would be best to keep in C.

            I'm trying to load registers with values, but I'm stuck to using 8-bit immediates.

            My code:

            https://godbolt.org/z/8EE45Gerd

            ...

            ANSWER

            Answered 2021-May-30 at 13:42

            @Jester in the comments recommended either to use i constrain to pass larger immediates or use real C variable, initialize it with desired value and let the inline assembly take it. This sounds like the best solution, the least time spent in the inline assembly the better, people wanting better performance often underestimate how powerful the C/C++ toolchain can be at optimizing when given correct code and for many rewriting the C/C++ code is the answer instead of redoing everything in assembly. @Peter Cordes mentioned to not use inline assembly and I concur. However in this case the exact timing of some instructions was critical and I couldn't risk the toolchain slightly differently optimize the timing of some instructions.

            Bit-banging protocols is not ideal, and in most cases the answer is to avoid bit-banging, however in my case it's not that simple and other approaches didn't work:

            • SPI couldn't be used to stream the data as I needed to push more signals, and have arbitrary lengths, while my HW supported only 8-bit/16-bit.
            • Tried to use DMA2GPIO and had issues with jitter.
            • Tried IRQ handler, which is too much overhead and my performance dropped (as you see below there are only 2 nops, so not much space to do in the free time).
            • Tried pre-baking stream of bits (including the timing), however for 1 byte of real data I had ended up saving 64bytes of stream data and overall reading from memory so much was much slower.
            • Pre-backing functions for each write value (and having a lookup table of functions, for each value write) worked very well, actually too fast because now the toolchain had compile-time known values and was able to optimize it very well, my TCK was above 40MHz. The problem was that I had to add a lot of delays to slow it down to desired speed (8MHz) and it had to be done for each input value, when the length was 8-bits or less it was fine, but for 32-bit length it was not possible to fit into the flash memory (2^32 => 4294967296) and splicing single 32-bit access into four 8-bit accesses introduced a lot of jitter on the TCK signal.
            • Implementing this peripheral in FPGA fabric, would allow me to be in control of everything and typically this is the correct answer, but wanted to try to implement this on a device that has no fabric.

            Long story short, bit-banging is bad and mostly there are better ways around it and unecesary using inline assembly might actually produce worse results without knowing, but in my case I needed it. And in my previous code was trying to focus on a simple question about the immediates and not go into tangents or X-Y problem discussion.

            So now back to the topic of 'passing bigger immediates to the assembly', here is the implementation of a much more real-world example:

            https://godbolt.org/z/5vbb7PPP5

            Source https://stackoverflow.com/questions/67756608

            QUESTION

            How to count number of bytes between instructions
            Asked 2020-Jul-30 at 14:40

            There's this piece of Keil assembly code in Valvano's book (3.3.3 Memory Access Instruction):

            ...

            ANSWER

            Answered 2020-Jul-30 at 14:40

            I don't have Kiel handy but doesn't really matter, you didn't provide enough information (what is your target architecture/core) and not all of this is well documented by arm.

            So generic thumb

            Source https://stackoverflow.com/questions/63085422

            QUESTION

            ARM Thumb BL instruction loops to itself
            Asked 2020-Jun-06 at 16:30

            I'm trying to assemble this code using Keystone and execute it with the Unicorn engine:

            ...

            ANSWER

            Answered 2020-Jun-06 at 16:30

            All tool "chain" linkers have to deal with function calls or other to external resources, you will see instructions like bl encoded as a branch to self or branch to zero or some such incomplete instruction (certainly for external labels). The tangent here is that some versions of clang appear to sometimes encode for a local address and sometimes not (at the assembler level). But when linked the offset/address is patched up (as in this case).

            A generic clang (all targets, default x86 host) 3.7 at the object level gives the right instruction. 3.8 doesn't. That appears to be the time this change happened. Clang 10 generic doesn't but a hand built clang 10.0.0 specific to one target, does give the right answer at assemble time.

            All of this is a tangent because that is at assembly time not final output. When linked you get the right answer (thus far, the OP may have other cases where it didn't).

            Source https://stackoverflow.com/questions/62105226

            QUESTION

            GCC arm instruction mode when compiling in thumb mode
            Asked 2020-Mar-11 at 08:07

            I'm wondering how GCC configured using --with-mode=thumb handles compiling/assembling code that makes use of ARM mode sections if the -marm flag is not specified. That is:

            • GCC is compiled with --with-mode=thumb
            • A program is compiled without -marm (defaults to thumb mode)
            • An assembly section of that program uses ARM mode

            I tried compiling a small test program on Raspberry Pi 4 with Ubuntu 18.04.4 kernel 5.3.0-1018-raspi2 and noticed that the .arm section is being executed in 16-bit thumb instruction mode which prompted me to investigate this. This naturally causes a segmentation fault as the program counter is increment by 2 bytes instead of 4.

            Here's what gdb in layout asm mode says when my program branches into the .arm assembly code and after I perform a single stepi command:

            ...

            ANSWER

            Answered 2020-Mar-10 at 13:57

            The linker should take care of that automatically. If you objdump -dr the object file, you should see a bl with an R_ARM_THM_CALL relocation, such as:

            Source https://stackoverflow.com/questions/60618779

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install armasm

            You can download it from GitHub.
            You can use armasm like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/stephanh42/armasm.git

          • CLI

            gh repo clone stephanh42/armasm

          • sshUrl

            git@github.com:stephanh42/armasm.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link