'dual-mode' DefMod

Justin Fletcher justin.fletcher at ntlworld.com
Fri Apr 25 04:11:08 BST 2003


Hiya,

I've put together a version of DefMod which is capable of generating
'dual-mode' assembler source files. Basically, this means that rather
than being forced to create different files - one for apcs26 and one
for apcs32, it can now generate both as a single source.

This probably isn't useful for most people.

It's useful for me because the build environment I use requires that
both 32bit and 26bit libraries be present. As such, building the two
variants by invoking oslib twice with the same arguments would be... well,
painful to say the least. The fact that it's going to be a 4 hour build
really isn't so appealing anyhow, but having a single source file for
the build is an advantage.

Current tests show that it's working just about sanely, although I've got
to finish a few bits. In my environment, 32bit objects live in .o32, 26bit
objects live in .o; again, this may not be ideal, and it isn't suitable
for use (at this second) with the -viafile option.

Typical use now (for this test) :

*DefMod -26bit -32bit -s -byte_wide ^.ByteWide < def.OS > objasm_src

The objasm source comes out in the following form :

[just a couple of example routines - the complete file is large]

--8<--------
xosclaimscreenmemory_alloc ROUT
        MOV     IP, LR
        STMFD   SP!, {A2, A3}
        MOV     R1, A1
        MOV     R0, #&1
        SWI     &20041
        BVS     %99
        LDR     LR, [SP, #0]
        TEQ     LR, #0
        STRNE   R1, [LR]
        LDR     LR, [SP, #4]
        TEQ     LR, #0
        STRNE   R2, [LR]
   [ {CONFIG} = 26
   |
        RSB     R1, PC, PC
        MRS     R1, CPSR
   ]
        TEQ     A4, #0
   [ {CONFIG} = 26
        STRNE   PC, [A4]
   |
        STRNE   R1, [A4]
   ]
        MOV     R, #0
99      ADD     SP, SP, #8
   [ {CONFIG} = 26
        MOVS    PC, IP
   |
        MOV     PC, IP
   ]
--8<--------
xmousev ROUT
        MOV     IP, LR
        STMFD   SP!, {A1, A2, A3, A4, V6}
        MOV     R9, #&1A
        SWI     &20034
        BVS     %99
        LDR     LR, [SP, #0]
        TEQ     LR, #0
        STRNE   R0, [LR]
        LDR     LR, [SP, #4]
        TEQ     LR, #0
        STRNE   R1, [LR]
        LDR     LR, [SP, #8]
        TEQ     LR, #0
        STRNE   R2, [LR]
        LDR     LR, [SP, #12]
        TEQ     LR, #0
        STRNE   R3, [LR]
        MOV     R, #0
99      ADD     SP, SP, #16
        LDMFD   SP!, {V6}
   [ {CONFIG} = 26
        MOVS    PC, IP
   |
        MOV     PC, IP
   ]
--8<--------
os_validate_address ROUT
        SWI     &3A
   [ {CONFIG} = 26
        MOV     R, PC
   |
        RSB     R, PC, PC
        MRS     R, CPSR
   ]
   [ {CONFIG} = 26
        MOVS    PC, LR
   |
        MOV     PC, LR
   ]
;Registers available for scratch use: {R2, R3}
--8<--------

(just a couple of snippets of versions)

Obviously this is not hugely different code - and that's the point; it's
just a few conditionals around the code that's required. If the library
build is requested, two viafiles are necessary; I've yet to address this,
but it's not a big deal at the moment for me. A command such as :

*DefMod -26bit -32bit -l -o l.free -byte_wide ^.ByteWide < def.Free

Will construct both o32 and o files and (eventually) will create multiple
via files, one for the 26bit version and one for the 32bit version.

I don't know if this is of much interest to you, but I felt it worth
explaining to you.

The sources I have based my changes to defmod on are from around mid-march,
because those just happened to be the sources I had lying around. If much
has changed, integrating the changes should not be too difficult.

-- 
Gerph {djf0-.3w6e2w2.226,6q6w2q2,2.3,2m4}
URL: http://www.movspclr.co.uk/
... Eyes to the heavens, screaming at the sky;
    Trying to send you messages, but choking on goodbye.



More information about the oslib-user mailing list