Skip to content

Commit cc96f39

Browse files
[binutils] idk just start doing things
1 parent 8ff9937 commit cc96f39

File tree

426 files changed

+7370
-5823
lines changed

Some content is hidden

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

426 files changed

+7370
-5823
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/[email protected]
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/[email protected]
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

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

src/ce/atomic_load_increasing_32.src

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

6-
section .text
7-
public _atomic_load_increasing_32
810
_atomic_load_increasing_32:
911
; CC: 202 + 9 * read_1_invalid + 3 * ie
1012
; Timing assumes fetching from RAM (4cc) and reading from non-RAM (3cc).
1113

1214
; Read the argument.
1315
pop hl
14-
ex (sp),iy ; iy = p
16+
ex (sp), iy ; iy = p
1517
push hl
1618
; ^ 48 cc
1719
; Temporarily disable interrupts.
18-
ld a,i
20+
ld a, i
1921
di
2022
; ^ 12 cc
2123
; Read from the pointer twice: first into cude, second into auhl.
2224
; Time between first and last byte read:
23-
ld de,(iy) ; 2R
25+
ld de, (iy) ; 2R
2426
; ^ 21 cc
2527
; 48 + 12 + 21 - 6 = 75 cc until first value captured if valid
26-
ld c,(iy+3) ; + 3F + 1R
27-
ld hl,(iy) ; + 3F + 3R
28+
ld c, (iy+3) ; + 3F + 1R
29+
ld hl, (iy) ; + 3F + 3R
2830
; ^ 36 cc
2931
; 48 + 12 + 21 + 36 - 5 = 112 cc until second value captured if valid
30-
ld a,(iy+3) ; + 3F + 1R
32+
ld a, (iy+3) ; + 3F + 1R
3133
; == 9F + 7R
3234
; == 57 cc
3335
; + 9 * 19 cc = 171 cc (worst-case DMA)
3436
; = 228 cc
3537
; ^ 15 cc
3638
; Re-enable interrupts if they were previously enabled.
37-
jp po,no_ei
39+
jp po, .L.no_ei
3840
ei
39-
no_ei:
41+
.L.no_ei:
4042
; ^ 17 + 3 * ie cc
4143
; Compare and return the lesser of the two values read.
4244
;
@@ -81,24 +83,24 @@ no_ei:
8183
;
8284
; Combining all of these cases and assumptions, the lesser of the two values
8385
; read will always be valid.
84-
or a,a
85-
sbc hl,de
86-
sbc a,c ; auhl = second value read
86+
or a, a
87+
sbc hl, de
88+
sbc a, c ; auhl = second value read
8789
; - first value read
8890
; ^ 16 cc
89-
jr c,no_swap
91+
jr c, .L.no_swap
9092
; second value read >= first value read
9193
; ==> first value read is valid
92-
ex de,hl
93-
ld e,c ; euhl = first value read
94+
ex de, hl
95+
ld e, c ; euhl = first value read
9496
ret
9597
; ^ 37 cc
9698

97-
no_swap:
99+
.L.no_swap:
98100
; second value read < first value read
99101
; ==> second value read is valid
100-
add hl,de
101-
adc a,c
102-
ld e,a ; euhl = second value read
102+
add hl, de
103+
adc a, c
104+
ld e, a ; euhl = second value read
103105
ret
104-
; ^ 46 cc (including conditional jr into)
106+
; ^ 46 cc (including conditional jr into)

0 commit comments

Comments
 (0)