;    s.ATestPrLib
;
;******************************************************************************
;
;    This file, when corrected, assembles to form a hello world program run
;    from the command line with no arguments.
;
;    Points demonstrated here include:
;       - Use of utility procedures print_string, print_hex and print_double
;         from the example linkable library PrintLib
;       - Calling procedures obeying the Arm Procedure Call Standard
;       - Using floating point instructions in assembler
;

        AREA    |C$$code|, CODE, READONLY

; IMPORT external labels used here

        IMPORT  |print_string|
        IMPORT  |print_hex|
        IMPORT  |print_double|

; Use the GET directive to include a list of SWI names as if typed here

        GET     ^.AsmHdrs.h.SWINames

; Now for the actual program code

        ENTRY                           ; ObjAsm entry point directive

        SWI     OS_GetEnv
        MOV     r13, r1                 ; set up stack pointer

        MOV     r0, #&00070000          ; initialise floating point system
        WFS     r0

        ADR     r0, hello_world         ; print string
        BL      |print_string|

        LDR     r0, =&9abcdef           ; print hex value
        BL      |print_hex|

        SWI     OS_WriteS               ; newline
        = 13, 10, 0
        ALIGN

        LDFD    f0, =-0.0123456         ; load pc relative example fp value
        STFD    f0, [sp, #-8]!
        LDMIA   sp!, {r0, r1}           ; into r0, r1 for APCS
        BL      |print_double|

        SWI     OS_WriteS               ; newline
        = 13, 10, 0
        ALIGN

        SWI     OS_Exit

hello_world
        = "Hello World", 13, 0
        ALIGN

        END
