Hi
I’m using Intel mcs-51 platform and need to build an assembly code. The platform uses sdcc compiler which includes an assembler AS="sdas8051"
and linker LD="sdld"
.
Building the assembly code using the built in assembler and linker to generate the hex file will be for instance:
sdas8051 -los blink.s
sdld -i blink
Based on my experiments: when the source file is assembly (.s
or .S
), the building process will trigger first “ASPPCOM” and then “LINKCOM”
I’ve added an extra script to replace
ASFLAGS= ["-los"]
ASPPCOM = '$AS $ASPPFLAGS -o $TARGET $SOURCES',
LINKCOM = '$LD -o -i $SOURCES '
but the weird thing that env.BuildProgram()
function override “AS” to “CC” where AS should be sdas8051 but it forced to be sdcc.
Could you please advise how this could be fixed ?
In addition, How to keep the original “LINKCOM” for C sources and change it to LINKCOM = '$LD -o -i $SOURCES '
for assembly sources ?
Regards,
You are right, currently because of the code
it is not possible to assemble and link pure assembly programs under Windows (the only OS with case-insensitive filesystem) because it gets remapped to the C compiler.
To be fair, pretty much all (GNU) C compilers can handle .s
assembly files too and that may have been a correct fix there, but not here with SDCC. We just get
Building in release mode
sdcc -DF_CPU=11059200 -DHEAP_SIZE=64 -DPLATFORMIO=50200 -Iinclude -Isrc -c -o .pio\build\stc15f204ea\src\blinky.rel src\blinky.s
at 1: error 119: don't know what to do with file 'src\blinky.s'. file extension unsupported
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ez80_z80/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.8.4 #10766 (MINGW64)
I will file a bug in the core.
1 Like
FYI linking with SDCC is possible but I needed to give a few more aera definitions. Using the assembler code from Blink with SDAS | Details | Hackaday.io as src/blinky.s
with the additions of
.area HOME (CODE)
.area XSEG (DATA)
.area PSEG (DATA)
under .module blink
, and using the platformio.ini
with
[env:stc15f204ea]
platform = intel_mcs51
board = stc15f204ea
extra_scripts = pre:fix_asm.py
whereas fix_asm.py
in the root folder is
Import("env")
env.Append(ASFLAGS=["-l", "-s"])
I was able to compile
Processing stc15f204ea (platform: intel_mcs51; board: stc15f204ea; extra_scripts: pre:fix_asm.py)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/intel_mcs51/stc15f204ea.html
PLATFORM: Intel MCS-51 (8051) (1.2.3) > Generic STC15F204EA
HARDWARE: STC15F204EA 11MHz, 256B RAM, 4KB Flash
PACKAGES:
- tool-stcgal 1.104.0 (1.4)
- toolchain-sdcc 1.30804.10766 (3.8.4)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
sdas8051 -l -s -o .pio/build/stc15f204ea/src/blinky.rel src/blinky.s
sdcc -o .pio/build/stc15f204ea/firmware.hex -mmcs51 --iram-size 256 --xram-size 0 --code-size 4096 --out-fmt-ihx .pio/build/stc15f204ea/src/blinky.rel -L.pio/build/stc15f204ea
MethodWrapper(["checkprogsize"], [".pio/build/stc15f204ea/firmware.hex"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
Flash: [ ] 0.8% (used 31 bytes from 4096 bytes)
Internal RAM layout:
0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00:|A|A|A| | | | | | | | | | | | | |
0x10:| | | | | | | | | | | | | | | | |
0x20:| | | | | | | | | | | | | | | | |
0x30:| | | | | | | | | | | | | | | | |
0x40:| | | | | | | | | | | | | | | | |
0x50:| | | | | | | | | | | | | | | | |
0x60:| | | | | | | | | | | | | | | | |
0x70:| | | | | | | | | | | | | | | | |
0x80:| | | | | | | | | | | | | | | | |
0x90:| | | | | | | | | | | | | | | | |
0xa0:| | | | | | | | | | | | | | | | |
0xb0:| | | | | | | | | | | | | | | | |
0xc0:| | | | | | | | | | | | | | | | |
0xd0:| | | | | | | | | | | | | | | | |
0xe0:| | | | | | | | | | | | | | | | |
0xf0:| | | | | | | | | | | | | | | | |
0-3:Reg Banks, T:Bit regs, a-z:Data, B:Bits, Q:Overlay, I:iData, S:Stack, A:Absolute
No clue at where the stack begins and ends!
The largest spare internal RAM space starts at 0x3 with 253 bytes available.
Other memory:
Name Start End Size Max
---------------- -------- -------- -------- --------
PAGED EXT. RAM 0 0
EXTERNAL RAM 0 0
ROM/EPROM/FLASH 0x0000 0x001e 31 4096
=============== [SUCCESS] Took 0.63 seconds ===============
but not sure if it runs yet.
That was done on Linux of course because for Windows it redirects the assembler to SDCC.