From bc2eccdd11c27029096fb3e891073503eb269e27 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sun, 18 Oct 2009 12:35:07 +0200 Subject: We can now load ELF binaries !!! --- Source/Applications/ASMApps/Makefile | 20 ---------------- Source/Applications/ASMApps/syscalls.asm | 18 -------------- Source/Applications/ASMApps/test | Bin 92 -> 0 bytes Source/Applications/ASMApps/test.asm | 30 ------------------------ Source/Applications/SampleApps/Makefile | 29 +++++++++++++++++++++++ Source/Applications/SampleApps/asmdemo | Bin 0 -> 4725 bytes Source/Applications/SampleApps/asmdemo.asm | 30 ++++++++++++++++++++++++ Source/Applications/SampleApps/lib-melonasm.asm | 24 +++++++++++++++++++ 8 files changed, 83 insertions(+), 68 deletions(-) delete mode 100644 Source/Applications/ASMApps/Makefile delete mode 100644 Source/Applications/ASMApps/syscalls.asm delete mode 100644 Source/Applications/ASMApps/test delete mode 100644 Source/Applications/ASMApps/test.asm create mode 100644 Source/Applications/SampleApps/Makefile create mode 100755 Source/Applications/SampleApps/asmdemo create mode 100644 Source/Applications/SampleApps/asmdemo.asm create mode 100644 Source/Applications/SampleApps/lib-melonasm.asm (limited to 'Source/Applications') diff --git a/Source/Applications/ASMApps/Makefile b/Source/Applications/ASMApps/Makefile deleted file mode 100644 index 8cc8bfd..0000000 --- a/Source/Applications/ASMApps/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -.PHONY: clean, mrproper - -ASM = nasm - -Applications = test - -all: $(Applications) - echo "* Done with ASM applications : $(Applications)" - -rebuild: mrproper all - -%: %.asm - echo "* Compiling $<..." - $(ASM) -o $@ $< - -clean: - echo "* Removing files..." - rm -rf $(Applications) - -mrproper: clean diff --git a/Source/Applications/ASMApps/syscalls.asm b/Source/Applications/ASMApps/syscalls.asm deleted file mode 100644 index 1a634d7..0000000 --- a/Source/Applications/ASMApps/syscalls.asm +++ /dev/null @@ -1,18 +0,0 @@ -[bits 32] - -%ifidn __OUTPUT_FORMAT__, bin - -%define MEM_ORIGIN 0x10000000 - -dd 0xFEEDBEEF ; magic number ^^ -dd end - start -dd MEM_ORIGIN - -; the ($-$$) permits not taking into account the header above -[org MEM_ORIGIN - ($-$$)] - -%endif - -%define SC_PUTCH 0xFFFFFF01 -%define SC_SLEEP 0xFFFFFF02 -%define SC_WHEX 0xFFFFFF03 diff --git a/Source/Applications/ASMApps/test b/Source/Applications/ASMApps/test deleted file mode 100644 index 781a4b6..0000000 Binary files a/Source/Applications/ASMApps/test and /dev/null differ diff --git a/Source/Applications/ASMApps/test.asm b/Source/Applications/ASMApps/test.asm deleted file mode 100644 index a79d4a3..0000000 --- a/Source/Applications/ASMApps/test.asm +++ /dev/null @@ -1,30 +0,0 @@ -%include "syscalls.asm" - -start: ; label used for calculating app size - mov ecx, [data] - mov ebx, ecx - mov eax, SC_WHEX - int 64 - mov eax, SC_PUTCH - mov ebx, 10 - int 64 - loop: - inc ecx - mov eax, SC_PUTCH ;temporarily defined for writing one char to screen - mov ebx, ecx - int 64 - mov eax, SC_SLEEP ;temporary syscall for sleeping - mov ebx, 30 ;20ms - int 64 - cmp ecx, 127 - jnz loop - mov eax, 0 - mov eax, SC_PUTCH - mov ebx, 10 ;newline - int 64 - int 66 ;finish task - -data: -dd 0x00000020 - -end: ; label used for calculating app size diff --git a/Source/Applications/SampleApps/Makefile b/Source/Applications/SampleApps/Makefile new file mode 100644 index 0000000..28dad49 --- /dev/null +++ b/Source/Applications/SampleApps/Makefile @@ -0,0 +1,29 @@ +.PHONY: clean, mrproper + +ASM = nasm +ASMFLAGS = -f elf +LD = ld +LDFLAGS = --entry=start -Ttext=40000000 + +Applications = asmdemo + +all: $(Applications) + echo "* Done with applications : $(Applications)" + +rebuild: mrproper all + +%: %.o + echo "* Linking $<..." + $(LD) $(LDFLAGS) $< -o $@ + +%.o: %.asm + echo "* Compiling $<..." + $(ASM) $(ASMFLAGS) -o $@ $< + +clean: + echo "* Removing object files..." + rm -rf *.o + +mrproper: clean + echo "* Removing applications..." + rm -rf $(Applications) diff --git a/Source/Applications/SampleApps/asmdemo b/Source/Applications/SampleApps/asmdemo new file mode 100755 index 0000000..9e6822d Binary files /dev/null and b/Source/Applications/SampleApps/asmdemo differ diff --git a/Source/Applications/SampleApps/asmdemo.asm b/Source/Applications/SampleApps/asmdemo.asm new file mode 100644 index 0000000..3037897 --- /dev/null +++ b/Source/Applications/SampleApps/asmdemo.asm @@ -0,0 +1,30 @@ +%include "lib-melonasm.asm" + +start: ; label used for calculating app size + mov ecx, [data] + mov ebx, ecx + mov eax, SC_WHEX + int 64 + mov eax, SC_PUTCH + mov ebx, 10 + int 64 + loop: + inc ecx + mov eax, SC_PUTCH ;temporarily defined for writing one char to screen + mov ebx, ecx + int 64 + mov eax, SC_SLEEP ;temporary syscall for sleeping + mov ebx, 30 ;20ms + int 64 + cmp ecx, 127 + jnz loop + mov eax, 0 + mov eax, SC_PUTCH + mov ebx, 10 ;newline + int 64 + int 66 ;finish task + +data: +dd 0x00000020 + +end: ; label used for calculating app size diff --git a/Source/Applications/SampleApps/lib-melonasm.asm b/Source/Applications/SampleApps/lib-melonasm.asm new file mode 100644 index 0000000..0845770 --- /dev/null +++ b/Source/Applications/SampleApps/lib-melonasm.asm @@ -0,0 +1,24 @@ +[bits 32] + +%ifidn __OUTPUT_FORMAT__, bin +; create a MelonBinary output + +%define MEM_ORIGIN 0x10000000 + +dd 0xFEEDBEEF ; magic number ^^ +dd end - start +dd MEM_ORIGIN + +; the ($-$$) permits not taking into account the header above +[org MEM_ORIGIN - ($-$$)] + +%elifidn __OUTPUT_FORMAT__, elf +; create an elf object + +[global start] + +%endif + +%define SC_PUTCH 0xFFFFFF01 +%define SC_SLEEP 0xFFFFFF02 +%define SC_WHEX 0xFFFFFF03 -- cgit v1.2.3