Skip to content

Commit

Permalink
LibC: Port setjmp syntax to avoid nasm dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
rburchell authored and awesomekling committed May 23, 2019
1 parent 7afc0fb commit a04a58b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 42 deletions.
5 changes: 1 addition & 4 deletions LibC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ LIBC_OBJS = \
netdb.o \
sched.o

ASM_OBJS = setjmp.no crti.ao crtn.ao
ASM_OBJS = setjmp.ao crti.ao crtn.ao

CPP_OBJS = $(AK_OBJS) $(WIDGETS_OBJS) $(LIBC_OBJS)

Expand All @@ -68,9 +68,6 @@ $(LIBRARY): $(CPP_OBJS) $(ASM_OBJS)
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<

%.no: %.asm
@echo "NASM $@"; nasm -f elf -o $@ $<

%.ao: %.S
@echo "AS $@"; $(AS) -o $@ $<

Expand Down
31 changes: 31 additions & 0 deletions LibC/setjmp.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.global setjmp
setjmp:
mov 4(%esp), %eax
mov %ebx, 0(%eax)
mov %esi, 4(%eax)
mov %edi, 8(%eax)
mov %ebp, 12(%eax)
lea 4(%esp), %ecx
mov %ecx, 16(%eax)
mov (%esp), %ecx
mov %ecx, 20(%eax)
xor %eax, %eax
ret

.global longjmp
longjmp:
mov 4(%esp), %edx
mov 8(%esp), %eax
mov 0(%edx), %ebx
mov 4(%edx), %esi
mov 8(%edx), %edi
mov 12(%edx), %ebp
mov 16(%edx), %ecx
mov %ecx, %esp
mov 20(%edx), %ecx
test %eax, %eax
jnz .nonzero
mov 1, %eax
.nonzero:
jmp *%ecx

33 changes: 0 additions & 33 deletions LibC/setjmp.asm

This file was deleted.

3 changes: 0 additions & 3 deletions LibM/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ $(LIBRARY): $(OBJS)
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<

%.no: %.asm
@echo "NASM $@"; nasm -f elf -o $@ $<

-include $(OBJS:%.o=%.d)

clean:
Expand Down
4 changes: 2 additions & 2 deletions Meta/BuildInstructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ First off, GCC needs MPFR, MPC and GMP. On Ubuntu, this is as simple as:

sudo apt install libmpfr-dev libmpc-dev libgmp-dev

For Serenity, we will need nasm, e2fsprogs and QEMU:
For Serenity, we will need e2fsprogs and QEMU:

sudo apt install nasm e2fsprogs qemu-system-i386
sudo apt install e2fsprogs qemu-system-i386

## Binutils:

Expand Down

0 comments on commit a04a58b

Please sign in to comment.