Skip to content
Snippets Groups Projects
Commit 968259f5 authored by Jakob Kirsch's avatar Jakob Kirsch
Browse files

add symbols map

parent e84bb355
No related branches found
No related tags found
No related merge requests found
...@@ -85,5 +85,8 @@ Section 2: ...@@ -85,5 +85,8 @@ Section 2:
2.4 The breakpoint 2.4 The breakpoint
If you want your code to run every loop before the "int int_input_line", you can replace the If you want your code to run every loop before the "int int_input_line", you can replace the
interrupt 0x27 with your code. This is used in the clock as you can see. interrupt 0x27 with your code. This is used in the clock as you can see.
2.5 sysmap.inc
sysmap.inc can be generated with "make symbols" and can be used to link your program
to the running system. You just have to add "%include sysmap.inc" to use the labels.
will be expanded... will be expanded...
...@@ -14,6 +14,7 @@ help: ...@@ -14,6 +14,7 @@ help:
@echo installer: make installer @echo installer: make installer
@echo cdimg: make cd image @echo cdimg: make cd image
@echo strip: strip image @echo strip: strip image
@echo symbols: create sysmap.inc
@echo ================ @echo ================
.PHONY: all .PHONY: all
...@@ -26,6 +27,7 @@ clean: ...@@ -26,6 +27,7 @@ clean:
$(RM) *.img $(RM) *.img
$(RM) *.lst $(RM) *.lst
$(RM) lst/*.lst $(RM) lst/*.lst
$(RM) *.inc
.PHONY: run .PHONY: run
run: os.img run: os.img
...@@ -78,3 +80,5 @@ strip: os.img ...@@ -78,3 +80,5 @@ strip: os.img
.PHONY: runkvm .PHONY: runkvm
runkvm: os.img runkvm: os.img
qemu-system-x86_64 -drive file=$<,format=raw --enable-kvm -serial stdio qemu-system-x86_64 -drive file=$<,format=raw --enable-kvm -serial stdio
.PHONY: symbols
python3 symbols.py
import os
content = ""
with open("os.asm", "r") as file:
for line in file.readlines():
if line.startswith("%"):
continue
if ":" in line:
ln = line
line = line.split(";")[0]
if line == "":
content += ln
continue
line = line.split(":")[0] + "\n"
content += ln + "%assign __" + line.replace("\n", "") + " $ - $$\n%warning _" + line.replace("\n", "") + " __" + line
else:
content += line
with open("sysmap.asm", "w") as file:
file.write(content)
os.system("nasm -f bin -o tmp.img sysmap.asm 2> sysmap.txt")
os.system("rm sysmap.asm tmp.img")
content = ""
with open("sysmap.txt", "r") as file:
for line in file.readlines():
ln = line
line = ("_".join(line.split("_")[1:])).split(" ")[:2]
try:
content += "%define " + line[0][1:] + " " + hex(0x7a00 + int(line[1])) + "\n"
except:
pass
with open("sysmap.inc", "w") as file:
file.write(content)
os.system("rm sysmap.txt")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment