Wrap the mmap2 syscall
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
# obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
.global symbol_table_build, symbol_table_find
|
||||
.global symbol_table_build, symbol_table_find, symbol_table_make_pointer
|
||||
|
||||
.include "boot/definitions.inc"
|
||||
|
||||
@@ -18,6 +18,8 @@ symbol_builtin_name_word: .ascii "Word"
|
||||
symbol_builtin_name_byte: .ascii "Byte"
|
||||
.type symbol_builtin_name_char, @object
|
||||
symbol_builtin_name_char: .ascii "Char"
|
||||
.type symbol_builtin_name_bool, @object
|
||||
symbol_builtin_name_bool: .ascii "Bool"
|
||||
|
||||
# Every type info starts with a word describing what type it is.
|
||||
|
||||
@@ -34,6 +36,9 @@ symbol_builtin_type_byte: .word TYPE_PRIMITIVE
|
||||
.type symbol_builtin_type_char, @object
|
||||
symbol_builtin_type_char: .word TYPE_PRIMITIVE
|
||||
.word 1
|
||||
.type symbol_builtin_type_bool, @object
|
||||
symbol_builtin_type_bool: .word TYPE_PRIMITIVE
|
||||
.word 1
|
||||
|
||||
.section .bss
|
||||
|
||||
@@ -81,20 +86,19 @@ symbol_table_find:
|
||||
beqz s2, .Lsymbol_table_find_not_found
|
||||
|
||||
# Compare string lengths.
|
||||
mv a0, s3
|
||||
mv a1, s4
|
||||
lw a2, 0(s1)
|
||||
bne s3, a2, .Lsymbol_table_find_continue
|
||||
lw a3, 4(s1)
|
||||
call _string_equal
|
||||
|
||||
# If lengths match, compare the content.
|
||||
mv a0, s4
|
||||
lw a1, 4(s1)
|
||||
call _memcmp
|
||||
|
||||
bnez a0, .Lsymbol_table_find_continue
|
||||
beqz a0, .Lsymbol_table_find_continue
|
||||
|
||||
lw a0, 8(s1) # Pointer to the symbol.
|
||||
j .Lsymbol_table_end
|
||||
|
||||
.Lsymbol_table_find_continue:
|
||||
addi s1, s1, 12
|
||||
addi s2, s2, -1
|
||||
j .Lsymbol_table_find_loop
|
||||
|
||||
@@ -113,6 +117,22 @@ symbol_table_find:
|
||||
addi sp, sp, 32
|
||||
ret
|
||||
|
||||
# Creates a pointer type.
|
||||
#
|
||||
# Parameters:
|
||||
# a0 - Pointer to the base type.
|
||||
# a1 - Output memory.
|
||||
#
|
||||
# Sets a0 to the size of newly created type in bytes.
|
||||
.type symbol_table_make_pointer, @function
|
||||
symbol_table_make_pointer:
|
||||
li t0, TYPE_POINTER
|
||||
sw t0, 0(a1)
|
||||
sw a0, 4(a1)
|
||||
|
||||
li a0, 8
|
||||
ret
|
||||
|
||||
# Build the initial symbols.
|
||||
#
|
||||
# Sets a0 to the pointer to the global symbol table.
|
||||
@@ -165,4 +185,15 @@ symbol_table_build:
|
||||
sw t1, 0(a0)
|
||||
addi t0, t0, 12
|
||||
|
||||
li t1, 4 # Length of the word "Bool".
|
||||
sw t1, 0(t0)
|
||||
la t1, symbol_builtin_name_bool
|
||||
sw t1, 4(t0)
|
||||
la t1, symbol_builtin_type_bool
|
||||
sw t1, 8(t0)
|
||||
lw t1, 0(a0)
|
||||
addi t1, t1, 1
|
||||
sw t1, 0(a0)
|
||||
addi t0, t0, 12
|
||||
|
||||
ret
|
||||
|
Reference in New Issue
Block a user