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 --bigend -o output.o -
  2. Enter your input. For example:
            AREA     ARMex, CODE, READONLY
                                    ; Name this block of code ARMex
    
    
            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      #0x123456      ; ARM semihosting (formerly SWI)
    
            END                     ; Mark end of file
  3. Terminate your input by entering:
    • Ctrl+Z then Return on Microsoft Windows systems.
    • Ctrl+D on Unix-based operating systems.
Non-ConfidentialPDF file icon PDF versionARM DUI0473M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.