Keil Logo

Using stdin to input source code to the assembler

6.3 Using stdin to input source code to the assembler

You can use stdin to pipe output from another program into armasm or to input source code directly on the command line. This is useful if you want to test a short piece of code without having to create a file for it.

To use stdin to pipe output from another program into armasm, invoke the program and the assembler using the pipe character (|). Use the minus character (-) as the source filename to instruct the assembler to take input from stdin. You must specify the output filename using the -o option. You can specify the command-line options you want to use. For example to pipe output from fromelf:
fromelf --disassemble input.o | armasm -o output.o -

Note

The source code from stdin is stored in an internal cache that can hold up to 8 MB. You can increase this cache size using the --maxcache command-line option.
To use stdin to input source code directly on the command line:

Procedure

  1. Invoke the assembler with the command-line options you want to use. Use the minus character (-) as the source filename to instruct the assembler to take input from stdin. You must specify the output filename using the -o option. For example:
    armasm --cpu=7-M --bigend -o output.o -
  2. Enter your input. For example:
            AREA     THUMBex, CODE, READONLY
                                    ; Name this block of code THUMBex
    
            ENTRY                   ; Mark first instruction to execute
    start
            MOV      r0, #10        ; Set up parameters
            MOV      r1, #3
            ADD      r0, r0, r1     ; r0 = r0 + r1
    stop
            MOV      r0, #0x18      ; angel_SWIreason_ReportException
            LDR      r1, =0x20026   ; ADP_Stopped_ApplicationExit
    
            SVC      #0xFF          ; ARM semihosting (formerly SWI)
            END                     ; Mark end of file
  3. Terminate your input by entering:
    • Ctrl+Z then Return on Microsoft Windows systems.
Related reference
Non-ConfidentialPDF file icon PDF versionARM DUI0379H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.