Merge pull request #5 from os-k-team/kaleid

Kaleid
This commit is contained in:
Julian B 2019-01-02 16:20:42 +00:00 committed by GitHub
commit 9f9bab81a8
26 changed files with 1997 additions and 34 deletions

View File

114
obj/kaleid/common/arith.S Normal file
View File

@ -0,0 +1,114 @@
.file "arith.c"
.text
.p2align 4,,15
.globl _osk_abs
.type _osk_abs, @function
_osk_abs:
.LFB2:
.cfi_startproc
movl %edi, %edx
movl %edi, %eax
sarl $31, %edx
xorl %edx, %eax
subl %edx, %eax
ret
.cfi_endproc
.LFE2:
.size _osk_abs, .-_osk_abs
.p2align 4,,15
.globl _osk_labs
.type _osk_labs, @function
_osk_labs:
.LFB3:
.cfi_startproc
movq %rdi, %rdx
movq %rdi, %rax
sarq $63, %rdx
xorq %rdx, %rax
subq %rdx, %rax
ret
.cfi_endproc
.LFE3:
.size _osk_labs, .-_osk_labs
.p2align 4,,15
.globl _osk_min
.type _osk_min, @function
_osk_min:
.LFB4:
.cfi_startproc
cmpl %edi, %esi
movl %edi, %eax
cmovle %esi, %eax
ret
.cfi_endproc
.LFE4:
.size _osk_min, .-_osk_min
.p2align 4,,15
.globl _osk_lmin
.type _osk_lmin, @function
_osk_lmin:
.LFB5:
.cfi_startproc
cmpq %rdi, %rsi
movq %rdi, %rax
cmovle %rsi, %rax
ret
.cfi_endproc
.LFE5:
.size _osk_lmin, .-_osk_lmin
.p2align 4,,15
.globl _osk_max
.type _osk_max, @function
_osk_max:
.LFB11:
.cfi_startproc
cmpl %esi, %edi
movl %esi, %eax
cmovle %edi, %eax
ret
.cfi_endproc
.LFE11:
.size _osk_max, .-_osk_max
.p2align 4,,15
.globl _osk_lmax
.type _osk_lmax, @function
_osk_lmax:
.LFB13:
.cfi_startproc
cmpq %rsi, %rdi
movq %rsi, %rax
cmovle %rdi, %rax
ret
.cfi_endproc
.LFE13:
.size _osk_lmax, .-_osk_lmax
.p2align 4,,15
.globl _osk_div
.type _osk_div, @function
_osk_div:
.LFB8:
.cfi_startproc
movl %edi, %eax
cltd
idivl %esi
salq $32, %rdx
movl %eax, %eax
orq %rdx, %rax
ret
.cfi_endproc
.LFE8:
.size _osk_div, .-_osk_div
.p2align 4,,15
.globl _osk_ldiv
.type _osk_ldiv, @function
_osk_ldiv:
.LFB9:
.cfi_startproc
movq %rdi, %rax
cqto
idivq %rsi
ret
.cfi_endproc
.LFE9:
.size _osk_ldiv, .-_osk_ldiv
.ident "GCC: (GNU) 7.3.0"

77
obj/kaleid/common/itoa.S Normal file
View File

@ -0,0 +1,77 @@
.file "convert.c"
.text
.p2align 4,,15
.globl itoa
.type itoa, @function
itoa:
.LFB2:
.cfi_startproc
movl %edx, %r9d
leal -2(%rdx), %edx
movl %edi, %eax
cmpl $34, %edx
ja .L2
testl %edi, %edi
js .L11
jne .L7
leaq 1(%rsi), %r8
movb $48, (%rsi)
.L5:
movb $0, (%r8)
movq %rsi, %rdi
movabsq $reverse, %rax
jmp *%rax
.p2align 4,,10
.p2align 3
.L11:
negl %eax
movl $1, %edi
.L4:
movq %rsi, %r8
movabsq $digits, %r10
jmp .L6
.p2align 4,,10
.p2align 3
.L8:
movq %rcx, %r8
.L6:
cltd
leaq 1(%r8), %rcx
idivl %r9d
movslq %edx, %rdx
testl %eax, %eax
movzbl (%r10,%rdx), %edx
movb %dl, -1(%rcx)
jne .L8
testl %edi, %edi
je .L9
addq $2, %r8
movb $45, (%rcx)
jmp .L5
.p2align 4,,10
.p2align 3
.L7:
xorl %edi, %edi
jmp .L4
.p2align 4,,10
.p2align 3
.L2:
xorl %eax, %eax
ret
.p2align 4,,10
.p2align 3
.L9:
movq %rcx, %r8
jmp .L5
.cfi_endproc
.LFE2:
.size itoa, .-itoa
.section .rodata
.align 32
.type digits, @object
.size digits, 36
digits:
.byte 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43
.byte 0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50
.byte 0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a
.ident "GCC: (GNU) 7.3.0"

View File

76
obj/kaleid/common/ltoa.S Normal file
View File

@ -0,0 +1,76 @@
.file "convert.c"
.text
.p2align 4,,15
.globl ltoa
.type ltoa, @function
ltoa:
.LFB2:
.cfi_startproc
leal -2(%rdx), %ecx
movq %rdi, %rax
cmpl $34, %ecx
ja .L2
testq %rdi, %rdi
js .L11
jne .L7
leaq 1(%rsi), %r9
movb $48, (%rsi)
.L5:
movb $0, (%r9)
movq %rsi, %rdi
movabsq $reverse, %rax
jmp *%rax
.p2align 4,,10
.p2align 3
.L11:
negq %rax
movl $1, %edi
.L4:
movslq %edx, %r8
movq %rsi, %r9
movabsq $digits, %r10
jmp .L6
.p2align 4,,10
.p2align 3
.L8:
movq %rcx, %r9
.L6:
cqto
leaq 1(%r9), %rcx
idivq %r8
movzbl (%r10,%rdx), %edx
testq %rax, %rax
movb %dl, -1(%rcx)
jne .L8
testl %edi, %edi
je .L9
addq $2, %r9
movb $45, (%rcx)
jmp .L5
.p2align 4,,10
.p2align 3
.L7:
xorl %edi, %edi
jmp .L4
.p2align 4,,10
.p2align 3
.L2:
xorl %eax, %eax
ret
.p2align 4,,10
.p2align 3
.L9:
movq %rcx, %r9
jmp .L5
.cfi_endproc
.LFE2:
.size ltoa, .-ltoa
.section .rodata
.align 32
.type digits, @object
.size digits, 36
digits:
.byte 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43
.byte 0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50
.byte 0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a
.ident "GCC: (GNU) 7.3.0"

309
obj/kaleid/common/memory.S Normal file
View File

@ -0,0 +1,309 @@
.file "memory.c"
.text
.p2align 4,,15
.globl memsetb
.type memsetb, @function
memsetb:
.LFB2:
.cfi_startproc
movq %rdi, %rax
testb $7, %al
je .L10
testq %rdx, %rdx
leaq -1(%rdx), %r8
je .L3
movl %esi, %edx
movq %rdi, %rcx
jmp .L4
.p2align 4,,10
.p2align 3
.L21:
subq $1, %r8
cmpq $-1, %r8
je .L3
.L4:
addq $1, %rcx
movb %dl, -1(%rcx)
testb $7, %cl
jne .L21
.L2:
cmpq $8, %r8
ja .L5
testq %r8, %r8
je .L22
.L6:
addq %rcx, %r8
.p2align 4,,10
.p2align 3
.L9:
addq $1, %rcx
movb %sil, -1(%rcx)
cmpq %rcx, %r8
jne .L9
rep ret
.p2align 4,,10
.p2align 3
.L3:
movq $-1, %r8
.L5:
movslq %esi, %rcx
movq %rcx, %rdx
movq %rcx, %rdi
salq $48, %rdi
salq $56, %rdx
orq %rdi, %rdx
movq %rcx, %rdi
orq %rcx, %rdx
salq $40, %rdi
orq %rdi, %rdx
movq %rcx, %rdi
salq $32, %rdi
orq %rdi, %rdx
movq %rcx, %rdi
salq $24, %rdi
orq %rdi, %rdx
movq %rcx, %rdi
salq $8, %rcx
salq $16, %rdi
orq %rdi, %rdx
orq %rcx, %rdx
movq %rax, %rcx
.p2align 4,,10
.p2align 3
.L8:
subq $8, %r8
addq $8, %rcx
movq %rdx, -8(%rcx)
cmpq $8, %r8
ja .L8
jmp .L6
.p2align 4,,10
.p2align 3
.L22:
rep ret
.p2align 4,,10
.p2align 3
.L10:
movq %rdi, %rcx
movq %rdx, %r8
jmp .L2
.cfi_endproc
.LFE2:
.size memsetb, .-memsetb
.p2align 4,,15
.globl memsetw
.type memsetw, @function
memsetw:
.LFB3:
.cfi_startproc
testb $1, %dil
jne .L24
testb $7, %dil
je .L35
testq %rdx, %rdx
leaq -1(%rdx), %r8
movl %esi, %eax
movq %rdi, %rcx
jne .L31
jmp .L47
.p2align 4,,10
.p2align 3
.L48:
subq $1, %r8
cmpq $-1, %r8
je .L27
.L31:
addq $2, %rcx
movw %ax, -2(%rcx)
testb $7, %cl
jne .L48
.L25:
cmpq $4, %r8
ja .L27
testq %r8, %r8
je .L28
.L32:
xorl %edx, %edx
.p2align 4,,10
.p2align 3
.L34:
movw %si, (%rcx,%rdx,2)
addq $1, %rdx
cmpq %r8, %rdx
jne .L34
.L28:
movq %rdi, %rax
ret
.p2align 4,,10
.p2align 3
.L47:
movq $-1, %r8
.p2align 4,,10
.p2align 3
.L27:
movslq %esi, %rdx
movq %rdx, %rax
movq %rdx, %r9
salq $48, %rax
salq $32, %r9
orq %r9, %rax
orq %rdx, %rax
salq $16, %rdx
orq %rdx, %rax
.p2align 4,,10
.p2align 3
.L33:
subq $4, %r8
addq $8, %rcx
movq %rax, -8(%rcx)
cmpq $4, %r8
ja .L33
jmp .L32
.p2align 4,,10
.p2align 3
.L24:
testq %rdx, %rdx
je .L28
xorl %eax, %eax
.p2align 4,,10
.p2align 3
.L29:
movw %si, (%rdi,%rax,2)
addq $1, %rax
cmpq %rax, %rdx
jne .L29
leaq (%rdi,%rdx,2), %rax
ret
.p2align 4,,10
.p2align 3
.L35:
movq %rdi, %rcx
movq %rdx, %r8
jmp .L25
.cfi_endproc
.LFE3:
.size memsetw, .-memsetw
.p2align 4,,15
.globl memsetd
.type memsetd, @function
memsetd:
.LFB4:
.cfi_startproc
movq %rdi, %rax
ret
.cfi_endproc
.LFE4:
.size memsetd, .-memsetd
.p2align 4,,15
.globl memsetq
.type memsetq, @function
memsetq:
.LFB5:
.cfi_startproc
testq %rdx, %rdx
movq %rdi, %rax
je .L51
xorl %ecx, %ecx
.p2align 4,,10
.p2align 3
.L52:
movq %rsi, (%rax,%rcx,8)
addq $1, %rcx
cmpq %rdx, %rcx
jne .L52
.L51:
rep ret
.cfi_endproc
.LFE5:
.size memsetq, .-memsetq
.p2align 4,,15
.globl memzero
.type memzero, @function
memzero:
.LFB6:
.cfi_startproc
movq %rsi, %rdx
movabsq $memsetb, %rax
xorl %esi, %esi
jmp *%rax
.cfi_endproc
.LFE6:
.size memzero, .-memzero
.p2align 4,,15
.globl memcpy
.type memcpy, @function
memcpy:
.LFB7:
.cfi_startproc
testq %rdx, %rdx
movq %rdi, %rax
je .L59
testb $1, %sil
movq %rsi, %rcx
jne .L91
.L60:
testb $7, %al
je .L61
andl $7, %ecx
jne .L89
jmp .L61
.p2align 4,,10
.p2align 3
.L62:
movsw
subq $2, %rdx
.L89:
cmpq $2, %rdx
ja .L62
.L61:
cmpq $8, %rdx
jbe .L63
leaq -9(%rdx), %r10
xorl %ecx, %ecx
shrq $3, %r10
leaq 8(,%r10,8), %r9
.p2align 4,,10
.p2align 3
.L64:
movq (%rsi,%rcx), %r8
movq %r8, (%rdi,%rcx)
addq $8, %rcx
cmpq %rcx, %r9
jne .L64
negq %r10
addq %r9, %rsi
addq %r9, %rdi
leaq -8(%rdx,%r10,8), %rdx
.L65:
xorl %ecx, %ecx
.p2align 4,,10
.p2align 3
.L66:
movzbl (%rsi,%rcx), %r8d
movw %r8w, (%rdi,%rcx,2)
addq $1, %rcx
cmpq %rdx, %rcx
jne .L66
.L59:
rep ret
.p2align 4,,10
.p2align 3
.L63:
testq %rdx, %rdx
jne .L65
rep ret
.p2align 4,,10
.p2align 3
.L91:
testb $1, %al
je .L60
movzbl (%rsi), %r8d
leaq 1(%rdi), %rdi
subq $1, %rdx
addq $1, %rsi
movb %r8b, (%rax)
jmp .L60
.cfi_endproc
.LFE7:
.size memcpy, .-memcpy
.ident "GCC: (GNU) 7.3.0"

52
obj/kaleid/common/rand.S Normal file
View File

@ -0,0 +1,52 @@
.file "rand.c"
.text
.p2align 4,,15
.globl rand
.type rand, @function
rand:
.LFB2:
.cfi_startproc
movabsq $next, %rax
imulq $1103515245, (%rax), %rdx
addq $12345, %rdx
movq %rdx, (%rax)
shrq $16, %rdx
movl %edx, %eax
movl %edx, %esi
leaq (%rax,%rax,2), %rax
shrq $32, %rax
movq %rax, %rcx
movl %edx, %eax
subl %ecx, %eax
shrl %eax
addl %ecx, %eax
shrl $30, %eax
movl %eax, %ecx
sall $31, %ecx
subl %eax, %ecx
subl %ecx, %esi
movl %esi, %eax
ret
.cfi_endproc
.LFE2:
.size rand, .-rand
.p2align 4,,15
.globl srand
.type srand, @function
srand:
.LFB3:
.cfi_startproc
movabsq $next, %rax
movl %edi, %edx
movq %rdx, (%rax)
ret
.cfi_endproc
.LFE3:
.size srand, .-srand
.data
.align 8
.type next, @object
.size next, 8
next:
.quad 7756
.ident "GCC: (GNU) 7.3.0"

View File

@ -0,0 +1,18 @@
.file "status.c"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string ""
.text
.p2align 4,,15
.globl describe_status
.type describe_status, @function
describe_status:
.LFB2:
.cfi_startproc
movabsq $.LC0, %rax
ret
.cfi_endproc
.LFE2:
.size describe_status, .-describe_status
.ident "GCC: (GNU) 7.3.0"

192
obj/kaleid/common/string.S Normal file
View File

@ -0,0 +1,192 @@
.file "string.c"
.text
.p2align 4,,15
.globl strlen
.type strlen, @function
strlen:
.LFB2:
.cfi_startproc
movq %rdi, %rax
.p2align 4,,10
.p2align 3
.L2:
addq $1, %rax
cmpb $0, -1(%rax)
jne .L2
subq %rdi, %rax
subq $1, %rax
ret
.cfi_endproc
.LFE2:
.size strlen, .-strlen
.p2align 4,,15
.globl strcpy
.type strcpy, @function
strcpy:
.LFB3:
.cfi_startproc
movq %rdi, %rax
movq %rdi, %rdx
.p2align 4,,10
.p2align 3
.L6:
addq $1, %rsi
movzbl -1(%rsi), %ecx
addq $1, %rdx
testb %cl, %cl
movb %cl, -1(%rdx)
jne .L6
rep ret
.cfi_endproc
.LFE3:
.size strcpy, .-strcpy
.p2align 4,,15
.globl strncpy
.type strncpy, @function
strncpy:
.LFB4:
.cfi_startproc
testq %rdx, %rdx
movq %rdi, %rax
je .L9
movzbl (%rsi), %r8d
xorl %ecx, %ecx
testb %r8b, %r8b
jne .L11
jmp .L12
.p2align 4,,10
.p2align 3
.L20:
movzbl (%rsi,%rcx), %r8d
testb %r8b, %r8b
je .L12
.L11:
movb %r8b, (%rax,%rcx)
addq $1, %rcx
cmpq %rcx, %rdx
jne .L20
.L9:
rep ret
.p2align 4,,10
.p2align 3
.L12:
addq $1, %rcx
cmpq %rcx, %rdx
movb $0, -1(%rax,%rcx)
jbe .L9
addq $1, %rcx
cmpq %rcx, %rdx
movb $0, -1(%rax,%rcx)
ja .L12
jmp .L9
.cfi_endproc
.LFE4:
.size strncpy, .-strncpy
.p2align 4,,15
.globl xstrcnpy
.type xstrcnpy, @function
xstrcnpy:
.LFB5:
.cfi_startproc
testq %rdx, %rdx
je .L22
movzbl (%rsi), %ecx
xorl %eax, %eax
testb %cl, %cl
jne .L24
jmp .L25
.p2align 4,,10
.p2align 3
.L33:
movzbl (%rsi,%rax), %ecx
testb %cl, %cl
je .L25
.L24:
movb %cl, (%rdi,%rax)
addq $1, %rax
cmpq %rax, %rdx
jne .L33
.L22:
movl $1, %eax
ret
.p2align 4,,10
.p2align 3
.L25:
addq $1, %rax
cmpq %rax, %rdx
movb $0, -1(%rdi,%rax)
jbe .L22
addq $1, %rax
cmpq %rax, %rdx
movb $0, -1(%rdi,%rax)
ja .L25
jmp .L22
.cfi_endproc
.LFE5:
.size xstrcnpy, .-xstrcnpy
.p2align 4,,15
.globl strrev
.type strrev, @function
strrev:
.LFB6:
.cfi_startproc
movq %rdi, %rax
movq %rsi, %rdx
.p2align 4,,10
.p2align 3
.L35:
addq $1, %rdx
cmpb $0, -1(%rdx)
jne .L35
subq %rsi, %rdx
movb $0, -1(%rax,%rdx)
leaq -2(%rsi,%rdx), %rcx
movq %rax, %rdx
.p2align 4,,10
.p2align 3
.L36:
movzbl (%rcx), %esi
addq $1, %rdx
subq $1, %rcx
testb %sil, %sil
movb %sil, -1(%rdx)
jne .L36
rep ret
.cfi_endproc
.LFE6:
.size strrev, .-strrev
.p2align 4,,15
.globl reverse
.type reverse, @function
reverse:
.LFB7:
.cfi_startproc
movq %rdi, %rax
movq %rdi, %rdx
.p2align 4,,10
.p2align 3
.L40:
addq $1, %rdx
cmpb $0, -1(%rdx)
jne .L40
subq $2, %rdx
cmpq %rdx, %rax
jnb .L41
movq %rax, %rcx
.p2align 4,,10
.p2align 3
.L42:
movzbl (%rdx), %esi
movzbl (%rcx), %r8d
subq $1, %rdx
addq $1, %rcx
cmpq %rcx, %rdx
movb %r8b, 1(%rdx)
movb %sil, -1(%rcx)
ja .L42
.L41:
rep ret
.cfi_endproc
.LFE7:
.size reverse, .-reverse
.ident "GCC: (GNU) 7.3.0"

View File

55
obj/kaleid/common/ultoa.S Normal file
View File

@ -0,0 +1,55 @@
.file "convert.c"
.text
.p2align 4,,15
.globl ultoa
.type ultoa, @function
ultoa:
.LFB2:
.cfi_startproc
leal -2(%rdx), %ecx
movq %rdi, %rax
cmpl $34, %ecx
ja .L2
testq %rdi, %rdi
jne .L3
leaq 1(%rsi), %rcx
movb $48, (%rsi)
.L4:
movb $0, (%rcx)
movq %rsi, %rdi
movabsq $reverse, %rax
jmp *%rax
.p2align 4,,10
.p2align 3
.L3:
movslq %edx, %r8
movq %rsi, %rcx
movabsq $digits, %r9
.p2align 4,,10
.p2align 3
.L5:
xorl %edx, %edx
addq $1, %rcx
divq %r8
movzbl (%r9,%rdx), %edx
testq %rax, %rax
movb %dl, -1(%rcx)
jne .L5
jmp .L4
.p2align 4,,10
.p2align 3
.L2:
xorl %eax, %eax
ret
.cfi_endproc
.LFE2:
.size ultoa, .-ultoa
.section .rodata
.align 32
.type digits, @object
.size digits, 36
digits:
.byte 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43
.byte 0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50
.byte 0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a
.ident "GCC: (GNU) 7.3.0"

56
obj/kaleid/common/utoa.S Normal file
View File

@ -0,0 +1,56 @@
.file "convert.c"
.text
.p2align 4,,15
.globl utoa
.type utoa, @function
utoa:
.LFB2:
.cfi_startproc
movl %edx, %r8d
leal -2(%rdx), %edx
movl %edi, %eax
cmpl $34, %edx
ja .L2
testl %edi, %edi
jne .L5
leaq 1(%rsi), %rcx
movb $48, (%rsi)
.L4:
movb $0, (%rcx)
movq %rsi, %rdi
movabsq $reverse, %rax
jmp *%rax
.p2align 4,,10
.p2align 3
.L5:
movq %rsi, %rcx
movabsq $digits, %r9
.p2align 4,,10
.p2align 3
.L3:
xorl %edx, %edx
addq $1, %rcx
divl %r8d
movl %edx, %edx
testl %eax, %eax
movzbl (%r9,%rdx), %edx
movb %dl, -1(%rcx)
jne .L3
jmp .L4
.p2align 4,,10
.p2align 3
.L2:
xorl %eax, %eax
ret
.cfi_endproc
.LFE2:
.size utoa, .-utoa
.section .rodata
.align 32
.type digits, @object
.size digits, 36
digits:
.byte 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43
.byte 0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50
.byte 0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a
.ident "GCC: (GNU) 7.3.0"

30
obj/kaleid/kernel/init.S Normal file
View File

@ -0,0 +1,30 @@
.file "init.c"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "Goodbye World :("
.text
.p2align 4,,15
.globl StartKern
.type StartKern, @function
StartKern:
.LFB2:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
/APP
# 21 "kaleid/kernel/init.c" 1
cli
# 0 "" 2
/NO_APP
movabsq $__kstate, %rax
movb $3, (%rax)
movabsq $InitTerms, %rax
call *%rax
movabsq $.LC0, %rdi
movabsq $StartPanic, %rax
call *%rax
.cfi_endproc
.LFE2:
.size StartKern, .-StartKern
.ident "GCC: (GNU) 7.3.0"

View File

View File

@ -0,0 +1,3 @@
.file "ports.c"
.text
.ident "GCC: (GNU) 7.3.0"

View File

@ -0,0 +1,846 @@
.file "terminal.c"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "kaleid/kernel/io/terminal.c"
.LC1:
.string "kt->kt_init == INITOK"
.section .rodata.str1.8,"aMS",@progbits,1
.align 8
.LC2:
.string "(&(kt)->kt_lock)->lk_init == INITOK"
.align 8
.LC3:
.string "DosAquireLock on an already locked object"
.align 8
.LC4:
.string "DosReleaseLock on an unlocked object"
.text
.p2align 4,,15
.globl ClearTerm
.type ClearTerm, @function
ClearTerm:
.LFB3:
.cfi_startproc
testq %rdi, %rdi
je .L10
pushq %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
cmpl $-889275714, 80(%rdi)
movq %rdi, %rbx
jne .L26
/APP
# 69 "kaleid/kernel/io/terminal.c" 1
cli
# 0 "" 2
/NO_APP
cmpl $-889275714, 24(%rdi)
jne .L27
movl 4(%rdi), %eax
leal 1(%rax), %edx
testl %eax, %eax
movl %edx, 4(%rdi)
jne .L28
.L5:
/APP
# 69 "kaleid/kernel/io/terminal.c" 1
sti
# 0 "" 2
/NO_APP
movq 48(%rbx), %rcx
movzbl 40(%rbx), %edx
imulq 56(%rbx), %rcx
sall $8, %edx
orl $32, %edx
testq %rcx, %rcx
je .L6
movq 32(%rbx), %rax
leaq (%rax,%rcx,2), %rcx
.p2align 4,,10
.p2align 3
.L7:
movw %dx, (%rax)
addq $2, %rax
cmpq %rax, %rcx
jne .L7
.L6:
movq $0, 72(%rbx)
movq $0, 64(%rbx)
/APP
# 71 "kaleid/kernel/io/terminal.c" 1
cli
# 0 "" 2
/NO_APP
cmpl $-889275714, 24(%rbx)
jne .L29
movl 4(%rbx), %eax
leal 1(%rax), %edx
testl %eax, %eax
movl %edx, 4(%rbx)
jne .L30
.L9:
/APP
# 71 "kaleid/kernel/io/terminal.c" 1
sti
# 0 "" 2
/NO_APP
xorl %eax, %eax
popq %rbx
.cfi_remember_state
.cfi_restore 3
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L30:
.cfi_restore_state
movabsq $.LC4, %rdi
xorl %eax, %eax
movabsq $StartPanic, %rdx
call *%rdx
jmp .L9
.p2align 4,,10
.p2align 3
.L28:
movabsq $.LC3, %rdi
xorl %eax, %eax
movabsq $StartPanic, %rdx
call *%rdx
jmp .L5
.p2align 4,,10
.p2align 3
.L26:
movabsq $__func__.1202, %rcx
movl $67, %edx
movabsq $.LC0, %rsi
movabsq $.LC1, %rdi
movabsq $_assert_handler, %rax
call *%rax
.p2align 4,,10
.p2align 3
.L27:
movabsq $__func__.1202, %rcx
movl $69, %edx
movabsq $.LC0, %rsi
movabsq $.LC2, %rdi
movabsq $_assert_handler, %rax
call *%rax
.p2align 4,,10
.p2align 3
.L29:
movabsq $__func__.1202, %rcx
movl $71, %edx
movabsq $.LC0, %rsi
movabsq $.LC2, %rdi
movabsq $_assert_handler, %rax
call *%rax
.L10:
.cfi_def_cfa_offset 8
.cfi_restore 3
movq $-6, %rax
ret
.cfi_endproc
.LFE3:
.size ClearTerm, .-ClearTerm
.section .rodata.str1.8
.align 8
.LC5:
.string "!stdout && _vga_term.kt_init != INITOK"
.text
.p2align 4,,15
.globl InitTerms
.type InitTerms, @function
InitTerms:
.LFB2:
.cfi_startproc
movabsq $stdout, %rdx
cmpq $0, (%rdx)
jne .L32
movabsq $_vga_term, %rdi
cmpl $-889275714, 80(%rdi)
je .L32
movabsq $_vga_term+80, %rax
movq %rdi, (%rdx)
movl $-889275714, (%rax)
movq %rdi, %rax
movabsq %rax, stddbg
movabsq $ClearTerm, %rax
jmp *%rax
.p2align 4,,10
.p2align 3
.L32:
subq $8, %rsp
.cfi_def_cfa_offset 16
movabsq $__func__.1198, %rcx
movl $49, %edx
movabsq $.LC0, %rsi
movabsq $.LC5, %rdi
movabsq $_assert_handler, %rax
call *%rax
.cfi_endproc
.LFE2:
.size InitTerms, .-InitTerms
.p2align 4,,15
.globl ChTermColor
.type ChTermColor, @function
ChTermColor:
.LFB4:
.cfi_startproc
cmpb $15, %sil
ja .L42
testq %rdi, %rdi
je .L43
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
pushq %rbx
.cfi_def_cfa_offset 24
.cfi_offset 3, -24
movl %esi, %ebp
movq %rdi, %rbx
subq $8, %rsp
.cfi_def_cfa_offset 32
/APP
# 87 "kaleid/kernel/io/terminal.c" 1
cli
# 0 "" 2
/NO_APP
cmpl $-889275714, 24(%rdi)
jne .L54
movl 4(%rdi), %eax
leal 1(%rax), %edx
testl %eax, %eax
movl %edx, 4(%rdi)
jne .L55
.L39:
/APP
# 87 "kaleid/kernel/io/terminal.c" 1
sti
# 0 "" 2
/NO_APP
movb %bpl, 40(%rbx)
/APP
# 89 "kaleid/kernel/io/terminal.c" 1
cli
# 0 "" 2
/NO_APP
cmpl $-889275714, 24(%rbx)
jne .L56
movl 4(%rbx), %eax
leal 1(%rax), %edx
testl %eax, %eax
movl %edx, 4(%rbx)
jne .L57
.L41:
/APP
# 89 "kaleid/kernel/io/terminal.c" 1
sti
# 0 "" 2
/NO_APP
addq $8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 24
xorl %eax, %eax
popq %rbx
.cfi_restore 3
.cfi_def_cfa_offset 16
popq %rbp
.cfi_restore 6
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L55:
.cfi_restore_state
movabsq $.LC3, %rdi
xorl %eax, %eax
movabsq $StartPanic, %rdx
call *%rdx
jmp .L39
.p2align 4,,10
.p2align 3
.L57:
movabsq $.LC4, %rdi
xorl %eax, %eax
movabsq $StartPanic, %rdx
call *%rdx
jmp .L41
.p2align 4,,10
.p2align 3
.L54:
movabsq $__func__.1210, %rcx
movl $87, %edx
movabsq $.LC0, %rsi
movabsq $.LC2, %rdi
movabsq $_assert_handler, %rax
call *%rax
.p2align 4,,10
.p2align 3
.L56:
movabsq $__func__.1210, %rcx
movl $89, %edx
movabsq $.LC0, %rsi
movabsq $.LC2, %rdi
movabsq $_assert_handler, %rax
call *%rax
.p2align 4,,10
.p2align 3
.L42:
.cfi_def_cfa_offset 8
.cfi_restore 3
.cfi_restore 6
movq $-5, %rax
ret
.L43:
movq $-6, %rax
ret
.cfi_endproc
.LFE4:
.size ChTermColor, .-ChTermColor
.p2align 4,,15
.globl ClearTermUnlocked
.type ClearTermUnlocked, @function
ClearTermUnlocked:
.LFB7:
.cfi_startproc
movq 48(%rdi), %rcx
movzbl 40(%rdi), %edx
imulq 56(%rdi), %rcx
sall $8, %edx
orl $32, %edx
testq %rcx, %rcx
je .L59
movq 32(%rdi), %rax
leaq (%rax,%rcx,2), %rcx
.p2align 4,,10
.p2align 3
.L60:
movw %dx, (%rax)
addq $2, %rax
cmpq %rcx, %rax
jne .L60
.L59:
movq $0, 72(%rdi)
movq $0, 64(%rdi)
ret
.cfi_endproc
.LFE7:
.size ClearTermUnlocked, .-ClearTermUnlocked
.p2align 4,,15
.globl PutOnTermUnlocked
.type PutOnTermUnlocked, @function
PutOnTermUnlocked:
.LFB8:
.cfi_startproc
cmpb $13, %sil
je .L69
movsbl %sil, %esi
movabsq $PutOnTermUnlocked.part.0, %rax
jmp *%rax
.p2align 4,,10
.p2align 3
.L69:
movq $0, 64(%rdi)
ret
.cfi_endproc
.LFE8:
.size PutOnTermUnlocked, .-PutOnTermUnlocked
.p2align 4,,15
.type PutOnTermUnlocked.part.0, @function
PutOnTermUnlocked.part.0:
.LFB10:
.cfi_startproc
pushq %r13
.cfi_def_cfa_offset 16
.cfi_offset 13, -16
pushq %r12
.cfi_def_cfa_offset 24
.cfi_offset 12, -24
pushq %rbp
.cfi_def_cfa_offset 32
.cfi_offset 6, -32
pushq %rbx
.cfi_def_cfa_offset 40
.cfi_offset 3, -40
movq %rdi, %rbx
subq $8, %rsp
.cfi_def_cfa_offset 48
cmpb $10, %sil
je .L81
cmpb $9, %sil
movq 72(%rdi), %rbp
je .L82
movq 48(%rdi), %rdx
movzbl 40(%rbx), %ecx
movsbw %sil, %si
movq 64(%rdi), %rax
movq 32(%rdi), %rdi
imulq %rdx, %rbp
sall $8, %ecx
orl %ecx, %esi
addq %rax, %rbp
movw %si, (%rdi,%rbp,2)
.L72:
addq $1, %rax
cmpq %rdx, %rax
je .L77
movq %rax, 64(%rbx)
.L70:
addq $8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 40
popq %rbx
.cfi_restore 3
.cfi_def_cfa_offset 32
popq %rbp
.cfi_restore 6
.cfi_def_cfa_offset 24
popq %r12
.cfi_restore 12
.cfi_def_cfa_offset 16
popq %r13
.cfi_restore 13
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L82:
.cfi_restore_state
movq %rbp, %rax
movl $4, %r12d
movabsq $PutOnTermUnlocked, %r13
cmpq %rbp, %rax
je .L83
.L74:
subl $1, %r12d
je .L84
movq 72(%rbx), %rax
cmpq %rbp, %rax
jne .L74
.L83:
movl $32, %esi
movq %rbx, %rdi
call *%r13
jmp .L74
.p2align 4,,10
.p2align 3
.L77:
movq 72(%rbx), %rax
movq $0, 64(%rbx)
addq $1, %rax
cmpq 56(%rbx), %rax
movq %rax, 72(%rbx)
jne .L70
movq $0, 72(%rbx)
addq $8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 40
popq %rbx
.cfi_restore 3
.cfi_def_cfa_offset 32
popq %rbp
.cfi_restore 6
.cfi_def_cfa_offset 24
popq %r12
.cfi_restore 12
.cfi_def_cfa_offset 16
popq %r13
.cfi_restore 13
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L81:
.cfi_restore_state
movq 48(%rdi), %rdx
leaq -1(%rdx), %rax
movq %rax, 72(%rdi)
movq 64(%rdi), %rax
jmp .L72
.p2align 4,,10
.p2align 3
.L84:
movq 64(%rbx), %rax
movq 48(%rbx), %rdx
jmp .L72
.cfi_endproc
.LFE10:
.size PutOnTermUnlocked.part.0, .-PutOnTermUnlocked.part.0
.p2align 4,,15
.globl PutOnTerm
.type PutOnTerm, @function
PutOnTerm:
.LFB5:
.cfi_startproc
testq %rdi, %rdi
je .L94
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
pushq %rbx
.cfi_def_cfa_offset 24
.cfi_offset 3, -24
movl %esi, %ebp
movq %rdi, %rbx
subq $8, %rsp
.cfi_def_cfa_offset 32
cmpl $-889275714, 80(%rdi)
jne .L105
/APP
# 104 "kaleid/kernel/io/terminal.c" 1
cli
# 0 "" 2
/NO_APP
cmpl $-889275714, 24(%rdi)
jne .L106
movl 4(%rdi), %eax
leal 1(%rax), %edx
testl %eax, %eax
movl %edx, 4(%rdi)
jne .L107
.L89:
/APP
# 104 "kaleid/kernel/io/terminal.c" 1
sti
# 0 "" 2
/NO_APP
cmpb $13, %bpl
jne .L90
movq $0, 64(%rbx)
.L91:
/APP
# 106 "kaleid/kernel/io/terminal.c" 1
cli
# 0 "" 2
/NO_APP
cmpl $-889275714, 24(%rbx)
jne .L108
movl 4(%rbx), %eax
leal 1(%rax), %edx
testl %eax, %eax
movl %edx, 4(%rbx)
jne .L109
.L93:
/APP
# 106 "kaleid/kernel/io/terminal.c" 1
sti
# 0 "" 2
/NO_APP
addq $8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 24
xorl %eax, %eax
popq %rbx
.cfi_restore 3
.cfi_def_cfa_offset 16
popq %rbp
.cfi_restore 6
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L90:
.cfi_restore_state
movsbl %bpl, %esi
movq %rbx, %rdi
movabsq $PutOnTermUnlocked.part.0, %rax
call *%rax
jmp .L91
.p2align 4,,10
.p2align 3
.L107:
movabsq $.LC3, %rdi
xorl %eax, %eax
movabsq $StartPanic, %rdx
call *%rdx
jmp .L89
.p2align 4,,10
.p2align 3
.L109:
movabsq $.LC4, %rdi
xorl %eax, %eax
movabsq $StartPanic, %rdx
call *%rdx
jmp .L93
.p2align 4,,10
.p2align 3
.L105:
movabsq $__func__.1217, %rcx
movl $102, %edx
movabsq $.LC0, %rsi
movabsq $.LC1, %rdi
movabsq $_assert_handler, %rax
call *%rax
.p2align 4,,10
.p2align 3
.L106:
movabsq $__func__.1217, %rcx
movl $104, %edx
movabsq $.LC0, %rsi
movabsq $.LC2, %rdi
movabsq $_assert_handler, %rax
call *%rax
.p2align 4,,10
.p2align 3
.L108:
movabsq $__func__.1217, %rcx
movl $106, %edx
movabsq $.LC0, %rsi
movabsq $.LC2, %rdi
movabsq $_assert_handler, %rax
call *%rax
.L94:
.cfi_def_cfa_offset 8
.cfi_restore 3
.cfi_restore 6
movq $-6, %rax
ret
.cfi_endproc
.LFE5:
.size PutOnTerm, .-PutOnTerm
.p2align 4,,15
.globl PrintOnTerm
.type PrintOnTerm, @function
PrintOnTerm:
.LFB6:
.cfi_startproc
testq %rdi, %rdi
je .L121
pushq %r12
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
pushq %rbp
.cfi_def_cfa_offset 24
.cfi_offset 6, -24
movq %rdi, %rbp
pushq %rbx
.cfi_def_cfa_offset 32
.cfi_offset 3, -32
cmpl $-889275714, 80(%rdi)
jne .L132
/APP
# 121 "kaleid/kernel/io/terminal.c" 1
cli
# 0 "" 2
/NO_APP
cmpl $-889275714, 24(%rdi)
jne .L133
movl 4(%rdi), %eax
movq %rsi, %rbx
leal 1(%rax), %edx
testl %eax, %eax
movl %edx, 4(%rdi)
jne .L134
.L114:
/APP
# 121 "kaleid/kernel/io/terminal.c" 1
sti
# 0 "" 2
/NO_APP
movabsq $PutOnTermUnlocked.part.0, %r12
.L115:
movsbl (%rbx), %esi
testb %sil, %sil
je .L135
.L118:
addq $1, %rbx
cmpb $13, %sil
jne .L116
movq $0, 64(%rbp)
movsbl (%rbx), %esi
testb %sil, %sil
jne .L118
.L135:
/APP
# 125 "kaleid/kernel/io/terminal.c" 1
cli
# 0 "" 2
/NO_APP
cmpl $-889275714, 24(%rbp)
jne .L136
movl 4(%rbp), %eax
leal 1(%rax), %edx
testl %eax, %eax
movl %edx, 4(%rbp)
jne .L137
.L120:
/APP
# 125 "kaleid/kernel/io/terminal.c" 1
sti
# 0 "" 2
/NO_APP
xorl %eax, %eax
popq %rbx
.cfi_remember_state
.cfi_restore 3
.cfi_def_cfa_offset 24
popq %rbp
.cfi_restore 6
.cfi_def_cfa_offset 16
popq %r12
.cfi_restore 12
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L116:
.cfi_restore_state
movq %rbp, %rdi
call *%r12
jmp .L115
.p2align 4,,10
.p2align 3
.L137:
movabsq $.LC4, %rdi
xorl %eax, %eax
movabsq $StartPanic, %rdx
call *%rdx
jmp .L120
.p2align 4,,10
.p2align 3
.L134:
movabsq $.LC3, %rdi
xorl %eax, %eax
movabsq $StartPanic, %rdx
call *%rdx
jmp .L114
.p2align 4,,10
.p2align 3
.L132:
movabsq $__func__.1224, %rcx
movl $119, %edx
movabsq $.LC0, %rsi
movabsq $.LC1, %rdi
movabsq $_assert_handler, %rax
call *%rax
.p2align 4,,10
.p2align 3
.L133:
movabsq $__func__.1224, %rcx
movl $121, %edx
movabsq $.LC0, %rsi
movabsq $.LC2, %rdi
movabsq $_assert_handler, %rax
call *%rax
.p2align 4,,10
.p2align 3
.L136:
movabsq $__func__.1224, %rcx
movl $125, %edx
movabsq $.LC0, %rsi
movabsq $.LC2, %rdi
movabsq $_assert_handler, %rax
call *%rax
.L121:
.cfi_def_cfa_offset 8
.cfi_restore 3
.cfi_restore 6
.cfi_restore 12
movq $-6, %rax
ret
.cfi_endproc
.LFE6:
.size PrintOnTerm, .-PrintOnTerm
.p2align 4,,15
.globl PrintOnTermUnlocked
.type PrintOnTermUnlocked, @function
PrintOnTermUnlocked:
.LFB9:
.cfi_startproc
pushq %r12
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
movabsq $PutOnTermUnlocked.part.0, %r12
pushq %rbp
.cfi_def_cfa_offset 24
.cfi_offset 6, -24
movq %rdi, %rbp
pushq %rbx
.cfi_def_cfa_offset 32
.cfi_offset 3, -32
movq %rsi, %rbx
.L139:
movsbl (%rbx), %esi
testb %sil, %sil
je .L144
.L142:
addq $1, %rbx
cmpb $13, %sil
jne .L140
movq $0, 64(%rbp)
movsbl (%rbx), %esi
testb %sil, %sil
jne .L142
.L144:
popq %rbx
.cfi_remember_state
.cfi_restore 3
.cfi_def_cfa_offset 24
popq %rbp
.cfi_restore 6
.cfi_def_cfa_offset 16
popq %r12
.cfi_restore 12
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L140:
.cfi_restore_state
movq %rbp, %rdi
call *%r12
jmp .L139
.cfi_endproc
.LFE9:
.size PrintOnTermUnlocked, .-PrintOnTermUnlocked
.section .rodata
.align 8
.type __func__.1224, @object
.size __func__.1224, 12
__func__.1224:
.string "PrintOnTerm"
.align 8
.type __func__.1217, @object
.size __func__.1217, 10
__func__.1217:
.string "PutOnTerm"
.align 8
.type __func__.1210, @object
.size __func__.1210, 12
__func__.1210:
.string "ChTermColor"
.align 8
.type __func__.1202, @object
.size __func__.1202, 10
__func__.1202:
.string "ClearTerm"
.align 8
.type __func__.1198, @object
.size __func__.1198, 10
__func__.1198:
.string "InitTerms"
.comm stddbg,8,8
.comm stdout,8,8
.data
.align 32
.type _vga_term, @object
.size _vga_term, 88
_vga_term:
.byte 0
.zero 3
.long 0
.quad 0
.quad 0
.long -889275714
.zero 4
.quad 753664
.byte 7
.zero 7
.quad 80
.quad 25
.quad 0
.quad 0
.long 0
.zero 4
.ident "GCC: (GNU) 7.3.0"

View File

View File

@ -0,0 +1,3 @@
.file "lock.c"
.text
.ident "GCC: (GNU) 7.3.0"

View File

@ -0,0 +1,103 @@
.file "panic.c"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "(no message given)"
.LC1:
.string "double panic!\n"
.LC2:
.string "panic! - "
.text
.p2align 4,,15
.globl StartPanic
.type StartPanic, @function
StartPanic:
.LFB3:
.cfi_startproc
pushq %r13
.cfi_def_cfa_offset 16
.cfi_offset 13, -16
pushq %r12
.cfi_def_cfa_offset 24
.cfi_offset 12, -24
pushq %rbp
.cfi_def_cfa_offset 32
.cfi_offset 6, -32
pushq %rbx
.cfi_def_cfa_offset 40
.cfi_offset 3, -40
movq %rdi, %rbx
subq $8, %rsp
.cfi_def_cfa_offset 48
/APP
# 43 "kaleid/kernel/ke/panic.c" 1
cli
# 0 "" 2
/NO_APP
movabsq $__kstate, %rax
movabsq $stdout, %rbp
movabsq $__panicmsg, %r13
movb $2, (%rax)
movq 0(%rbp), %rdi
movabsq $ClearTermUnlocked, %rax
call *%rax
testq %rbx, %rbx
movabsq $.LC0, %rax
movq 0(%rbp), %rdi
cmove %rax, %rbx
cmpq $0, 0(%r13)
movabsq $PrintOnTermUnlocked, %r12
je .L3
movabsq $.LC1, %rsi
call *%r12
/APP
# 55 "kaleid/kernel/ke/panic.c" 1
hlt
# 0 "" 2
/NO_APP
.L3:
movabsq $.LC2, %rsi
movq 0(%rbp), %rdi
movq %rbx, 0(%r13)
call *%r12
movq %rbx, %rsi
movq 0(%rbp), %rdi
call *%r12
.p2align 4,,10
.p2align 3
.L4:
/APP
# 65 "kaleid/kernel/ke/panic.c" 1
hlt
# 0 "" 2
/NO_APP
jmp .L4
.cfi_endproc
.LFE3:
.size StartPanic, .-StartPanic
.p2align 4,,15
.globl _assert_handler
.type _assert_handler, @function
_assert_handler:
.LFB2:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
/APP
# 30 "kaleid/kernel/ke/panic.c" 1
cli
# 0 "" 2
/NO_APP
movabsq $StartPanic, %rax
call *%rax
.cfi_endproc
.LFE2:
.size _assert_handler, .-_assert_handler
.globl __panicmsg
.section .bss
.align 8
.type __panicmsg, @object
.size __panicmsg, 8
__panicmsg:
.zero 8
.ident "GCC: (GNU) 7.3.0"

View File

@ -0,0 +1,4 @@
.file "state.c"
.text
.comm __kstate,1,1
.ident "GCC: (GNU) 7.3.0"

View File

@ -1,11 +1,11 @@
//----------------------------------------------------------------------------#
// GNU GPL OS/K #
// #
// Authors: spectral` #
// NeoX #
// #
// Desc: Project Makefile #
//----------------------------------------------------------------------------#
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Authors: spectral` //
// NeoX //
// //
// Desc: Project Makefile //
//----------------------------------------------------------------------------//
// The madman's Makefile
#include "preproc.h"

View File

@ -4,7 +4,7 @@
// Authors: spectral` //
// NeoX //
// //
// Desc: Conversion utilities //
// Desc: Conversion utilities - itoa family //
//----------------------------------------------------------------------------//
#include <kaleid.h>

View File

@ -17,7 +17,7 @@
//
// Set "bytes"-many bytes starting from ptr to val
//
void *memsetb(void *ptr, int val, size_t bytes)
void *memset(void *ptr, int val, size_t bytes)
{
uchar *uptr = (uchar *)ptr;
@ -45,9 +45,7 @@ void *memsetb(void *ptr, int val, size_t bytes)
}
// deal with what's left
while (bytes--) {
*uptr++ = (uchar)val;
}
while (bytes--) *uptr++ = (uchar)val;
return ptr;
}
@ -61,12 +59,7 @@ void *memsetw(void *ptr, int val, size_t words)
// can't we do this an aligned way?
if unlikely (((ulong)uptr % WORD_ALIGN) > 0) {
// no, we can't align ourselves
while (words--) {
// do it the hard way
*uptr++ = (ushort)val;
}
// too bad '-'
while (words--) *uptr++ = (ushort)val;
return uptr;
}
@ -92,9 +85,7 @@ void *memsetw(void *ptr, int val, size_t words)
}
// deal with what's left
while (words--) {
*uptr++ = (ushort)val;
}
while (words--) *uptr++ = (ushort)val;
return ptr;
}
@ -135,7 +126,6 @@ void *memzero(void *ptr, size_t bytes)
return memsetb(ptr, 0, bytes);
}
//
// Copy "bytes"-many bytes of src to dst
// Does not deal with overlapping blocks (memmove's job)
@ -185,10 +175,45 @@ void *memcpy(void *dst, const void *src, size_t bytes)
ushort *ubdst = (ushort *)udst;
// deal with what's left
while (bytes--) {
*ubdst ++ = *ubsrc++;
}
while (bytes--) *ubdst ++ = *ubsrc++;
return dst;
}
//
// Move memory from src to dest
// To be made more efficient
//
void *memmove(void *dst, const void *src, size_t bytes)
{
const uchar *usrc = src;
uchar *udst = dst;
if (udst < usrc) {
while (bytes--) *udst++ = *usrc++;
return dst;
}
uchar *usrc_end = (uchar *)usrc + bytes - 1;
uchar *udst_end = udst + bytes - 1;
while (bytes--) *udst_end-- = *usrc_end--;
return dst;
}
//
// Compare memory areas
//
int memcmp(const void *ptr1, const void *ptr2, size_t bytes)
{
const uchar *uptr1 = ptr1;
const uchar *uptr2 = ptr2;
while (bytes--) {
if (*uptr1++ != *uptr2++) {
return uptr1[-1] < uptr2[-1] ? -1 : 1;
}
}
return 0;
}

View File

@ -71,20 +71,20 @@ typedef struct { long quot, rem; } ldiv_t;
// Memory management utilities //
//------------------------------------------//
#ifndef memset
#define memset memsetb
#ifndef memsetb
#define memsetb memset
#endif
#ifndef memchr
#define memchr memchrb
#ifndef memchrb
#define memchrb memchr
#endif
void *memsetb(void *, int, size_t);
void *memset(void *, int, size_t);
void *memsetw(void *, int, size_t);
void *memsetd(void *, int, size_t);
void *memsetq(void *, long, size_t);
void *memchrb(const void *, int, size_t);
void *memchr(const void *, int, size_t);
void *memchrw(const void *, int, size_t);
void *memchrd(const void *, int, size_t);
void *memchrq(const void *, long, size_t);

View File

@ -20,7 +20,7 @@
#define memsetd _osk_memsetd
#define memsetq _osk_memsetq
#define memchrb _osk_memchrb
#define memchr _osk_memchrb
#define memchrw _osk_memchrw
#define memchrd _osk_memchrd
#define memchrq _osk_memchrq

View File

@ -16,7 +16,7 @@
# define LINK_KERNEL(out) $(KCC) $(CLDSCR) $(COMMOBJS) $(KERNOBJS) -o $(BINDIR)/out
#endif
#define COMPILE_CONVRT(file) $(CCC) _CSPREF $(COMMDIR)/convert.c -o $(COBJDIR)/file._OUTFIX
#define COMPILE_CONVRT(file) $(CCC) _CSPREF $(COMMDIR)/itoa.c -o $(COBJDIR)/file._OUTFIX
#define COMPILE_COMMON(file) $(CCC) _CSPREF $(COMMDIR)/file.c -o $(COBJDIR)/file._OUTFIX
#define COMPILE_KERNEL(file) $(KCC) _CSPREF $(KERNDIR)/file.c -o $(KOBJDIR)/file._OUTFIX