Align assembly operands

This commit is contained in:
Pierre Pronchery 2018-06-07 11:53:39 -04:00
parent 5b900d2c7c
commit 6d171d207d
9 changed files with 116 additions and 116 deletions

View File

@ -11,8 +11,8 @@
.global _init
.type _init, @function
_init:
push %rbp
mov %rsp, %rbp
push %rbp
mov %rsp, %rbp
/* fini */
@ -20,5 +20,5 @@ _init:
.global _fini
.type _fini, @function
_fini:
push %rbp
mov %rsp, %rbp
push %rbp
mov %rsp, %rbp

View File

@ -12,17 +12,17 @@
.type __arch_setgdt, @function
__arch_setgdt:
#if 0
lea gdt_descriptor, %rcx
lea gdt_descriptor, %rcx
#else
mov (gdt_descriptor), %rcx
mov (gdt_descriptor), %rcx
#endif
/* set the offset of the GDT */
mov %rsi, 0x2(%rcx)
mov %rsi, 0x2(%rcx)
/* set the size of the GDT */
dec %rdi
mov %di, (%rcx)
dec %rdi
mov %di, (%rcx)
/* load the GDT */
lgdt (%rcx)
lgdt (%rcx)
ret

View File

@ -27,7 +27,7 @@ _exit:
/* infinite loop */
cli
1: hlt
jmp 1b
jmp 1b
/* start */
@ -38,28 +38,28 @@ _start:
cli
/* initialize the stack */
mov $stack_top, %rsp
xor %rbp, %rbp
mov $stack_top, %rsp
xor %rbp, %rbp
#if defined(__SSP__)
/* initialize SSP */
call __stack_chk_setup
call __stack_chk_setup
#endif
/* call the global constructors */
call _init
call _init
/* set the interrupt descriptor */
call __arch_setidt
call __arch_setidt
/* FIXME setup paging */
/* start the kernel */
xor %rdi, %rdi
call main
xor %rdi, %rdi
call main
/* exit the kernel */
mov %rax, %rdi
call exit
mov %rax, %rdi
call exit
hlt

View File

@ -11,8 +11,8 @@
.global _init
.type _init, @function
_init:
push %ebp
mov %esp, %ebp
push %ebp
mov %esp, %ebp
/* fini */
@ -20,5 +20,5 @@ _init:
.global _fini
.type _fini, @function
_fini:
push %ebp
mov %esp, %ebp
push %ebp
mov %esp, %ebp

View File

@ -12,19 +12,19 @@
.type __arch_setgdt, @function
__arch_setgdt:
#if 0
lea gdt_descriptor, %ecx
lea gdt_descriptor, %ecx
#else
mov (gdt_descriptor), %ecx
mov (gdt_descriptor), %ecx
#endif
/* set the offset of the GDT */
mov 0x4(%esp), %eax
mov %eax, 0x2(%ecx)
mov 0x4(%esp), %eax
mov %eax, 0x2(%ecx)
/* set the size of the GDT */
mov 0x8(%esp), %eax
dec %eax
mov %ax, (%ecx)
mov 0x8(%esp), %eax
dec %eax
mov %ax, (%ecx)
/* load the GDT */
lgdt (%ecx)
lgdt (%ecx)
ret

View File

@ -25,7 +25,7 @@ _exit:
/* infinite loop */
cli
1: hlt
jmp 1b
jmp 1b
/* start */
@ -36,45 +36,45 @@ _start:
cli
/* initialize the stack */
mov $stack_top, %esp
xor %ebp, %ebp
mov $stack_top, %esp
xor %ebp, %ebp
push %eax
push %eax
/* reset EFLAGS */
pushl $0x0
pushl $0x0
popf
#if defined(__SSP__)
/* initialize SSP */
call __stack_chk_setup
call __stack_chk_setup
#endif
/* call the global constructors */
call _init
call _init
/* detect multiboot */
pop %eax
cmp $BOOT_MULTIBOOT_LOADER_MAGIC, %eax
jne 1f
push %ebx
call multiboot
add $0x4, %esp
pop %eax
cmp $BOOT_MULTIBOOT_LOADER_MAGIC, %eax
jne 1f
push %ebx
call multiboot
add $0x4, %esp
1:
/* set the interrupt descriptor */
call __arch_setidt
call __arch_setidt
/* FIXME setup paging */
/* start the kernel */
push $0x0
call main
add $0x4, %esp
push $0x0
call main
add $0x4, %esp
/* exit the kernel */
push %eax
call exit
add $0x4, %esp
push %eax
call exit
add $0x4, %esp
hlt

View File

@ -25,7 +25,7 @@ _exit:
/* infinite loop */
cli
1: hlt
jmp 1b
jmp 1b
/* start */
@ -36,55 +36,55 @@ _start:
cli
/* initialize the stack */
mov $stack_top, %esp
xor %ebp, %ebp
mov $stack_top, %esp
xor %ebp, %ebp
push %eax
push %eax
/* reset EFLAGS */
pushl $0x0
pushl $0x0
popf
#if defined(__SSP__)
/* initialize SSP */
call __stack_chk_setup
call __stack_chk_setup
#endif
/* call the global constructors */
call _init
call _init
/* detect multiboot */
pop %eax
cmp $BOOT_MULTIBOOT_LOADER_MAGIC, %eax
jne 1f
push %ebx
call multiboot
add $0x4, %esp
pop %eax
cmp $BOOT_MULTIBOOT_LOADER_MAGIC, %eax
jne 1f
push %ebx
call multiboot
add $0x4, %esp
/* start the loader */
push $0x0
push $0x0
push $0x0
mov %ebx, %eax
add $0x10, %eax
push %eax
push $0x1
call main
add $0x14, %esp
jmp 2f
push $0x0
push $0x0
push $0x0
mov %ebx, %eax
add $0x10, %eax
push %eax
push $0x1
call main
add $0x14, %esp
jmp 2f
1:
/* start the loader */
push $0x0
push $0x0
push $0x0
push $0x0
call main
add $0x10, %esp
push $0x0
push $0x0
push $0x0
push $0x0
call main
add $0x10, %esp
2:
/* exit the kernel */
call _exit
call _exit
hlt

View File

@ -22,18 +22,18 @@ k_ptr:
multiboot_boot_kernel32:
/* jump into the 32-bit kernel */
#if 0
mov 0x4(%esp), %ebx
mov 0x8(%esp), %eax
call *%eax
mov 0x4(%esp), %ebx
mov 0x8(%esp), %eax
call *%eax
ret
#else
push %ebp
mov %esp, %ebp
push %ebp
mov %esp, %ebp
mov 0x8(%ebp), %ebx
mov 0xc(%ebp), %ecx
mov $BOOT_MULTIBOOT_LOADER_MAGIC, %eax
jmp *%ecx
mov 0x8(%ebp), %ebx
mov 0xc(%ebp), %ecx
mov $BOOT_MULTIBOOT_LOADER_MAGIC, %eax
jmp *%ecx
#endif
@ -42,41 +42,41 @@ multiboot_boot_kernel32:
multiboot_boot_kernel64:
/* check for 64-bit capability */
pushf
pop %eax
mov %eax, %ecx
xor $0x00200000, %eax
push %eax
pop %eax
mov %eax, %ecx
xor $0x00200000, %eax
push %eax
popf
pushf
pop %eax
cmp %ecx, %eax
jz 1f /* CPUID is not supported */
push %ebx
mov $0x80000001, %eax
pop %eax
cmp %ecx, %eax
jz 1f /* CPUID is not supported */
push %ebx
mov $0x80000001, %eax
cpuid
pop %ebx
cmp $0x80000000, %eax
jl 1f /* 64-bit mode is not supported */
pop %ebx
cmp $0x80000000, %eax
jl 1f /* 64-bit mode is not supported */
/* jump into the 64-bit kernel */
mov 0x8(%esp), %esi
mov %esi, (k_ptr)
mov 0x8(%esp), %esi
mov %esi, (k_ptr)
#if 0
lgdt (_gdt64)
lgdt (_gdt64)
mov _gdt64_data, %ax
mov %ax, %ss
mov %ax, %ds
mov %ax, %es
jmp _gdt64_code
mov _gdt64_data, %ax
mov %ax, %ss
mov %ax, %ds
mov %ax, %es
jmp _gdt64_code
.jmp_k:
mov 0x4(%esp), %edi
mov k_ptr, %eax
mov 0x4(%esp), %edi
mov k_ptr, %eax
.long 0x0
jmp *%eax
jmp *%eax
#endif
1:
mov $-1, %eax
mov $-1, %eax
ret

View File

@ -34,7 +34,7 @@ _read:
.global _start
.type _start, @function
_start:
/* reset the stack */
/* initialize the stack */
xor %ebp, %ebp
/* setup the environment */