Skip to content

Commit 510f67c

Browse files
[binutils] idk just start doing things
1 parent 4132b11 commit 510f67c

File tree

513 files changed

+7648
-6173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

513 files changed

+7648
-6173
lines changed

.github/workflows/branch.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
AUTOTESTER_ROM: ${{github.workspace}}/secrets/83pce_515_530.rom
1212
CEDEV: ${{github.workspace}}/CEdev
1313
CEDEV_BIN: ${{github.workspace}}/CEdev/bin
14+
CEDEV_BINUTILS_BIN: ${{github.workspace}}/CEdev/binutils/bin
1415
CEDEV_EXAMPLES: ${{github.workspace}}/CEdev/examples
1516
CEDEV_TEST: ${{github.workspace}}/toolchain/test
1617
CEMU_PATH: ${{github.workspace}}/CEmu
@@ -33,24 +34,30 @@ jobs:
3334
fasmg: /source/macos/x64/fasmg
3435
arch-suffix: "-intel"
3536
ez80-bins-suffix: macOS_intel
37+
binutils-suffix: macos_intel
3638
- runs-on: macos-14
3739
fasmg: /source/macos/x64/fasmg
3840
arch-suffix: "-arm"
3941
ez80-bins-suffix: macOS_arm
42+
binutils-suffix: macos_arm
4043
- runs-on: windows-latest
4144
fasmg: /fasmg.exe
4245
ez80-bins-suffix: windows
46+
binutils-suffix: windows
4347
env: "env:"
4448
exe: .exe
4549
nul: nul
4650
ldflags: LDFLAGS="-static-libgcc -static-libstdc++ -static"
4751
- runs-on: ubuntu-22.04
4852
ez80-bins-suffix: ubuntu
53+
binutils-suffix: ubuntu
4954
fasmg: /fasmg.x64
5055
runs-on: ${{matrix.runs-on}}
5156
steps:
5257
- name: Prepare Build Environment
53-
run: cmake -E echo >> $${{matrix.env}}GITHUB_PATH ${{env.CEDEV_BIN}}
58+
run: |
59+
cmake -E echo >> $${{matrix.env}}GITHUB_PATH ${{env.CEDEV_BIN}}
60+
cmake -E echo >> $${{matrix.env}}GITHUB_PATH ${{env.CEDEV_BINUTILS_BIN}}
5461
5562
- name: Download ez80-clang and ez80-link
5663
id: ez80-bins
@@ -63,6 +70,17 @@ jobs:
6370
pathSource: ${{steps.ez80-bins.outputs.file-path}}
6471
pathTarget: ${{env.CEDEV_BIN}}
6572

73+
- name: Download binutils
74+
id: binutils
75+
uses: carlosperate/download-file-action@v2.0.2
76+
with:
77+
file-url: https://github.com/CE-Programming/binutils-gdb/releases/download/nightly/binutils_${{matrix.binutils-suffix}}_nightly.zip
78+
- name: Extract binutils
79+
uses: DuckSoft/extract-7z-action@v1.0
80+
with:
81+
pathSource: ${{steps.binutils.outputs.file-path}}
82+
pathTarget: ${{env.CEDEV}}
83+
6684
- name: Add fasmg website to /etc/hosts since DNS seems to be broken
6785
if: runner.os == 'macOS'
6886
run: |
@@ -109,7 +127,9 @@ jobs:
109127

110128
- name: Make Binaries Executable
111129
if: runner.os != 'Windows'
112-
run: chmod +x ${{env.CEDEV_BIN}}/*
130+
run: |
131+
chmod +x ${{env.CEDEV_BIN}}/*
132+
chmod +x ${{env.CEDEV_BINUTILS_BIN}}/*
113133
- name: Test Build Dependencies
114134
run: |
115135
ez80-clang --version
@@ -137,7 +157,9 @@ jobs:
137157

138158
- name: Make Binaries Executable
139159
if: runner.os != 'Windows'
140-
run: chmod +x ${{env.CEDEV_BIN}}/*
160+
run: |
161+
chmod +x ${{env.CEDEV_BIN}}/*
162+
chmod +x ${{env.CEDEV_BINUTILS_BIN}}/*
141163
142164
- name: Build Test Graphics
143165
run: make -j4 -C ${{env.CEDEV_TEST}} COMPRESSED=${{matrix.compressed}} V=1 gfx

docs/headers/ti/sprintf.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ The truncating behavior of C99 `snprintf` can be replicated with `boot_asprintf`
7272
7373
printf and fprintf
7474
------------------
75-
`printf` and `fprintf` can be replicated by using `fputs`
75+
76+
`printf` and `fprintf` can be replicated by using `puts` or `fputs`.
7677

7778
.. code-block:: c
7879

docs/static/makefile-options.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,35 @@ These flags are passed directly to the fasmg linker.
115115
116116
EXTRA_LDFLAGS =
117117
118-
.. rubric:: PREFER_OS_CRT
118+
.. rubric:: PREFER_CE_CRT
119119

120-
Prefer the builtin OS CRT (Compiler-Run-Time) functions if they exist.
120+
Prefer the calculator's builtin CRT (Compiler-Run-Time) functions if they exist.
121121
This can help to decrease the output size in some circumstances, as a select number of CRT functions will execute from flash.
122122
Default: :code:`NO`.
123123

124+
.. code-block:: makefile
125+
126+
HAS_MATH_ERRNO = NO
127+
128+
.. rubric:: HAS_MATH_ERRNO
129+
130+
By default, the compiler flag :code:`-fno-math-errno` is added to improve performance.
131+
However, this may lead to discrepencies on the value of :code:`errno` when running math operations in some cases.
132+
To avoid this, set this option to :code:`YES`.
133+
124134
.. code-block:: makefile
125135
126136
PREFER_OS_CRT = NO
127137
128-
.. rubric:: PREFER_OS_LIBC
138+
.. rubric:: PREFER_CE_LIBC
129139

130-
Prefer the builtin OS LIBC functions if they exist.
140+
Prefer the calculator's builtin LIBC functions if they exist.
131141
This can help to decrease the output size in some circumstances, as a select number of LIBC functions will execute from flash.
132142
Default: :code:`YES`.
133143

134144
.. code-block:: makefile
135145
136-
PREFER_OS_LIBC = YES
146+
PREFER_CE_LIBC = YES
137147
138148
.. rubric:: LIBLOAD_OPTIONAL
139149

@@ -233,4 +243,3 @@ Define rules for the files after including the main CEdev makefile.
233243
$(BINDIR)/levelpack.bin:
234244
$(call MKDIR,$(@D))
235245
echo "levelpack" > $(BINDIR)/levelpack.bin
236-

makefile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ include $(CURDIR)/src/common.mk
2121

2222
LIBS := libload graphx fontlibc keypadc fileioc usbdrvce srldrvce msddrvce fatdrvce lcddrvce
2323
SRCS := ce crt libc libcxx softfloat
24-
TOOLS := fasmg convbin convimg convfont cedev-config
24+
TOOLS := fasmg convbin convimg convfont cedev-config cedev-obj
25+
2526

2627
ifeq ($(OS),Windows_NT)
2728
WINDOWS_COPY := $(call COPY,resources\windows\make.exe,$(INSTALL_BIN)) && $(call COPY,resources\windows\cedev.bat,$(INSTALL_DIR))
@@ -44,7 +45,6 @@ $(LIBS): fasmg
4445
$(Q)$(MAKE) -C $(call SRCDIR,$@)
4546

4647
install: all $(addprefix install-,$(SRCS)) $(addprefix install-,$(LIBS))
47-
$(Q)$(MAKE) -f linker.mk -C src -B
4848
$(Q)$(call MKDIR,$(INSTALL_DIR))
4949
$(Q)$(call MKDIR,$(INSTALL_BIN))
5050
$(Q)$(call MKDIR,$(INSTALL_H))
@@ -55,14 +55,12 @@ install: all $(addprefix install-,$(SRCS)) $(addprefix install-,$(LIBS))
5555
$(Q)$(call MKDIR,$(INSTALL_EXAMPLES))
5656
$(Q)$(call COPYDIR,$(call NATIVEPATH,examples/*),$(INSTALL_EXAMPLES))
5757
$(Q)$(call COPY,$(call NATIVEPATH,src/makefile.mk),$(INSTALL_META))
58-
$(Q)$(call COPY,$(call NATIVEPATH,src/linker_script),$(INSTALL_META))
59-
$(Q)$(call COPY,$(call NATIVEPATH,tools/fasmg/fasmg-ez80/commands.alm),$(INSTALL_META))
60-
$(Q)$(call COPY,$(call NATIVEPATH,tools/fasmg/fasmg-ez80/ez80.alm),$(INSTALL_META))
61-
$(Q)$(call COPY,$(call NATIVEPATH,tools/fasmg/fasmg-ez80/ld.alm),$(INSTALL_META))
58+
$(Q)$(call COPY,$(call NATIVEPATH,src/linker_script.ld),$(INSTALL_META))
6259
$(Q)$(call COPY,$(call NATIVEEXE,tools/convfont/convfont),$(INSTALL_BIN))
6360
$(Q)$(call COPY,$(call NATIVEEXE,tools/convimg/bin/convimg),$(INSTALL_BIN))
6461
$(Q)$(call COPY,$(call NATIVEEXE,tools/convbin/bin/convbin),$(INSTALL_BIN))
6562
$(Q)$(call COPY,$(call NATIVEEXE,tools/cedev-config/bin/cedev-config),$(INSTALL_BIN))
63+
$(Q)$(call COPY,$(call NATIVEEXE,tools/cedev-obj/bin/cedev-obj),$(INSTALL_BIN))
6664
$(Q)$(WINDOWS_COPY)
6765

6866
$(addprefix install-,$(SRCS)): $(TOOLS)
@@ -73,14 +71,13 @@ $(addprefix install-,$(LIBS)): $(TOOLS)
7371

7472
libs: $(LIBS) $(TOOLS)
7573
$(Q)$(call NATIVEEXE,tools/convbin/bin/convbin) --oformat 8xg-auto-extract \
76-
$(foreach library,$(LIBS),$(addprefix --input ,$(call SRCDIR,$(library))/$(library).8xv)) --output $(call NATIVEPATH,clibs.8xg)
74+
$(foreach library,$(LIBS),$(addprefix --input ,$(call SRCDIR,$(library))/$(library).8xv)) --output clibs.8xg
7775

7876
libs-zip:
7977
$(Q)$(call MKDIR,clibs)
8078
$(Q)$(foreach library,$(LIBS),$(call COPY,$(call NATIVEPATH,$(call SRCDIR,$(library))/$(library).8xv),clibs) &&) $(call NATIVEEXE,7z) a clibs_separately_in_zip.zip clibs
8179

8280
clean: $(addprefix clean-,$(TOOLS)) $(addprefix clean-,$(SRCS)) $(addprefix clean-,$(LIBS))
83-
$(Q)$(call REMOVE,src/linker_script)
8481
$(Q)$(call REMOVE,clibs.8xg)
8582
$(Q)$(call RMDIR,docs/build)
8683
$(Q)$(call RMDIR,docs/doxygen)

src/ce/atomic_load_32.src

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
; ---
22
; uint32_t atomic_load_32(volatile uint32_t *p)
33
; ---
4-
assume adl=1
4+
.assume adl=1
5+
6+
.section .text
7+
.global _atomic_load_32
8+
.type _atomic_load_32, @function
59

6-
section .text
7-
public _atomic_load_32
810
_atomic_load_32:
911
pop hl
10-
ex (sp),iy
12+
ex (sp), iy
1113
push hl
12-
ld c,0
13-
retry:
14+
ld c, 0
15+
.L.retry:
1416
; Wait for a different (increasing) amount of time before each retry to prevent
1517
; getting caught in an endless loop of the value changing between reads with a
1618
; fixed period equal to the amount of time it takes for each retry
1719
inc c
1820
ld b,c
19-
wait:
20-
djnz wait
21+
.L.wait:
22+
djnz .L.wait
2123
; Read the value twice.
22-
lea hl,iy+3
24+
lea hl, iy+3
2325
; Time between first and last byte read:
24-
ld de,(iy) ; 2R
25-
ld a,(hl) ; + 1F+1R
26-
cp a,(hl) ; + 1F+1R
27-
ld hl,(iy) ; + 3F+3R
26+
ld de, (iy) ; 2R
27+
ld a, (hl) ; + 1F+1R
28+
cp a, (hl) ; + 1F+1R
29+
ld hl, (iy) ; + 3F+3R
2830
; = 5F+7R
2931
; = 48cc (assuming F = R = 3)
3032
; = 1us (assuming 48MHz clock speed)
@@ -52,10 +54,10 @@ wait:
5254
;
5355
; (Furthermore, if a change occurs in the middle of both 32-bit reads and the
5456
; bytes already read change in both, then both values read become invalid.)
55-
jr nz,retry
56-
sbc hl,de
57-
jr nz,retry
57+
jr nz, .L.retry
58+
sbc hl, de
59+
jr nz, .L.retry
5860
; Values don't differ, good to go.
59-
add hl,de
60-
ld e,a ; euhl = value read
61+
add hl, de
62+
ld e, a ; euhl = value read
6163
ret

src/ce/atomic_load_decreasing_32.src

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
; ---
22
; uint32_t atomic_load_decreasing_32(volatile uint32_t *p)
33
; ---
4-
assume adl=1
4+
.assume adl=1
5+
6+
.section .text
7+
.global _atomic_load_decreasing_32
8+
.type _atomic_load_decreasing_32, @function
59

6-
section .text
7-
public _atomic_load_decreasing_32
810
_atomic_load_decreasing_32:
911
pop hl
10-
ex (sp),iy
12+
ex (sp), iy
1113
push hl
1214
; Temporarily disable interrupts.
13-
ld a,i
15+
ld a, i
1416
di
1517
; Read the value twice.
1618
; first value read = cude, second value read = auhl
1719
; Time between first and last byte read:
18-
ld de,(iy) ; 2R
19-
ld c,(iy+3) ; + 3F+1R
20-
ld hl,(iy) ; + 3F+3R
21-
ld a,(iy+3) ; + 3F+1R
20+
ld de, (iy) ; 2R
21+
ld c, (iy+3) ; + 3F+1R
22+
ld hl, (iy) ; + 3F+3R
23+
ld a, (iy+3) ; + 3F+1R
2224
; = 9F+7R
2325
; = 56cc (assuming F = R = 3)
2426
; ~ 1.17us (assuming 48MHz clock speed)
2527
; + approximate worst-case LCD + USB DMA
2628
; ~ 5us
2729
; Re-enable interrupts if they were previously enabled.
28-
jp po,no_ei
30+
jp po, .L.no_ei
2931
ei
30-
no_ei:
32+
.L.no_ei:
3133
; Compare and return the greater of the two values read.
3234
;
3335
; If the values differ, then the underlying value changed between reading the
@@ -69,21 +71,21 @@ no_ei:
6971
;
7072
; Combining all of these cases and assumptions, the greater of the two values
7173
; read will always be valid.
72-
or a,a
73-
sbc hl,de
74-
sbc a,c ; auhl = second value read
74+
or a, a
75+
sbc hl, de
76+
sbc a, c ; auhl = second value read
7577
; - first value read
76-
jr c,swap
78+
jr c, .L.swap
7779
; second value read >= first value read
7880
; ==> second value read is valid
79-
add hl,de
80-
adc a,c
81-
ld e,a ; euhl = second value read
81+
add hl, de
82+
adc a, c
83+
ld e, a ; euhl = second value read
8284
ret
8385

84-
swap:
86+
.L.swap:
8587
; second value read < first value read
8688
; ==> first value read is valid
87-
ex de,hl
88-
ld e,c ; euhl = first value read
89+
ex de, hl
90+
ld e, c ; euhl = first value read
8991
ret

0 commit comments

Comments
 (0)