Change label and jump (now goto) syntax

This commit is contained in:
2025-04-25 23:12:36 +02:00
parent 2e0c958aa3
commit fee1781a5b
5 changed files with 1020 additions and 1377 deletions

View File

@ -22,31 +22,44 @@ def assemble_stage(output, compiler, source)
end
desc 'Final stage'
task default: ['build/stage2', 'boot/stage2.elna'] do |t|
assembler, exe = t.prerequisites.partition { |prerequisite| prerequisite.end_with? '.elna' }
task default: ['build/stage2b', 'build/stage2b.s', 'boot/stage2.elna'] do |t|
exe, previous_output, source = t.prerequisites
File.open File::NULL, 'w' do |output|
assemble_stage output, exe, assembler
end
cat_arguments = ['cat', source]
compiler_arguments = [QEMU, '-L', SYSROOT, exe]
diff_arguments = ['diff', '-Nur', previous_output, '-']
Open3.pipeline(cat_arguments, compiler_arguments, diff_arguments)
end
directory 'build'
desc 'Initial stage'
file 'build/stage1' => ['boot/echo-boot.s', 'boot/common-boot.s', 'build'] do |t|
assembler = t.prerequisites.filter { |prerequisite| prerequisite.end_with? '.s' }
file 'build/stage1' => ['boot/stage1.s', 'boot/common-boot.s', 'build'] do |t|
source = t.prerequisites.filter { |prerequisite| prerequisite.end_with? '.s' }
sh CROSS_GCC, '-nostdlib', '-o', t.name, *assembler
sh CROSS_GCC, '-nostdlib', '-o', t.name, *source
end
file 'build/stage2.s' => ['build/stage1', 'boot/stage2.elna'] do |t|
assembler, exe = t.prerequisites.partition { |prerequisite| prerequisite.end_with? '.elna' }
file 'build/stage2a.s' => ['build/stage1', 'boot/stage2.elna'] do |t|
source, exe = t.prerequisites.partition { |prerequisite| prerequisite.end_with? '.elna' }
File.open t.name, 'w' do |output|
assemble_stage output, exe, assembler
assemble_stage output, exe, source
end
end
file 'build/stage2' => ['build/stage2.s', 'boot/common-boot.s'] do |t|
file 'build/stage2a' => ['build/stage2a.s', 'boot/common-boot.s'] do |t|
sh CROSS_GCC, '-nostdlib', '-o', t.name, *t.prerequisites
end
file 'build/stage2b.s' => ['build/stage2a', 'boot/stage2.elna'] do |t|
source, exe = t.prerequisites.partition { |prerequisite| prerequisite.end_with? '.elna' }
File.open t.name, 'w' do |output|
assemble_stage output, exe, source
end
end
file 'build/stage2b' => ['build/stage2b.s', 'boot/common-boot.s'] do |t|
sh CROSS_GCC, '-nostdlib', '-o', t.name, *t.prerequisites
end