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 .global _init
.type _init, @function .type _init, @function
_init: _init:
push %rbp push %rbp
mov %rsp, %rbp mov %rsp, %rbp
/* fini */ /* fini */
@ -20,5 +20,5 @@ _init:
.global _fini .global _fini
.type _fini, @function .type _fini, @function
_fini: _fini:
push %rbp push %rbp
mov %rsp, %rbp mov %rsp, %rbp

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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