add shell
This commit is contained in:
parent
c1c8bcf0b3
commit
21234a882d
@ -60,29 +60,121 @@ key_press_int:
|
||||
mov r0, [counter]
|
||||
add r0, vcd_base
|
||||
mov r1, [kbd_code]
|
||||
|
||||
cmp r1, 44 ; spacebar
|
||||
mov r2, rfl
|
||||
and r2, fl_eq
|
||||
jnz r2, .print_space
|
||||
add r1, 61 ; scancode letter -> ascii
|
||||
|
||||
cmp r1, 40 ; enter
|
||||
mov r2, rfl
|
||||
and r2, fl_eq
|
||||
jnz r2, .print_newline
|
||||
|
||||
cmp r1, 55 ; dot
|
||||
mov r2, rfl
|
||||
and r2, fl_eq
|
||||
jnz r2, .print_dot
|
||||
|
||||
add r1, 61 ; scancode letter -> ascii
|
||||
mov [rsp], r1
|
||||
add rsp, 2
|
||||
call term_putc
|
||||
;call print_u16
|
||||
sub rsp, 2
|
||||
|
||||
jmp .leave
|
||||
|
||||
.print_space:
|
||||
mov r1, ' '
|
||||
|
||||
mov [rsp], r1
|
||||
add rsp, 2
|
||||
call term_putc
|
||||
sub rsp, 2
|
||||
jmp .leave
|
||||
|
||||
.print_newline:
|
||||
mov r1, '\n'
|
||||
mov [rsp], r1
|
||||
add rsp, 2
|
||||
call term_putc
|
||||
sub rsp, 2
|
||||
jmp .leave
|
||||
|
||||
.print_dot:
|
||||
mov r1, ':'
|
||||
mov [rsp], r1
|
||||
add rsp, 2
|
||||
call term_putc
|
||||
sub rsp, 2
|
||||
jmp .leave
|
||||
|
||||
.leave:
|
||||
reti
|
||||
|
||||
shell_start:
|
||||
mov [rsp], rbp
|
||||
add rsp, 2
|
||||
mov rbp, rsp
|
||||
.loop_body:
|
||||
|
||||
mov r1, .prompt
|
||||
mov r2, 5
|
||||
add rsp, 4
|
||||
mov [rsp-4], r1
|
||||
mov [rsp-2], r2
|
||||
call term_puts
|
||||
sub rsp, 4
|
||||
|
||||
hlt
|
||||
jmp .loop_body
|
||||
.leave:
|
||||
mov rsp, rbp
|
||||
sub rsp, 2
|
||||
mov rbp, [rsp]
|
||||
ret
|
||||
.prompt:
|
||||
db "C ABC", 0
|
||||
|
||||
term_puts:
|
||||
mov [rsp], rbp
|
||||
add rsp, 2
|
||||
mov rbp, rsp
|
||||
|
||||
mov r1, [rbp-8]
|
||||
mov r2, [rbp-6]
|
||||
|
||||
mov r3, 0
|
||||
jmp .l1_cond
|
||||
.l1_body:
|
||||
mov r4, r1
|
||||
add r4, r3
|
||||
mov r4, byte [r4]
|
||||
|
||||
add rsp, 8
|
||||
mov [rsp-8], r1
|
||||
mov [rsp-6], r2
|
||||
mov [rsp-4], r3
|
||||
mov [rsp-2], r4
|
||||
|
||||
call term_putc
|
||||
|
||||
mov r3, [rsp-4]
|
||||
mov r2, [rsp-6]
|
||||
mov r1, [rsp-8]
|
||||
sub rsp, 8
|
||||
|
||||
add r3, 1
|
||||
.l1_cond:
|
||||
cmp r3, r2
|
||||
mov r0, rfl
|
||||
and r0, fl_lt
|
||||
jnz r0, .l1_body
|
||||
|
||||
.leave:
|
||||
mov rsp, rbp
|
||||
sub rsp, 2
|
||||
mov rbp, [rsp]
|
||||
ret
|
||||
|
||||
const term_width 20
|
||||
const term_height 12
|
||||
@ -163,8 +255,8 @@ term_scroll:
|
||||
mov r0, term_width
|
||||
mul r0, r1
|
||||
add r0, r2
|
||||
mov r4, byte [vcd_base + term_width + r0]
|
||||
mov byte [vcd_base + r0], r4
|
||||
mov r3, byte [vcd_base + term_width + r0]
|
||||
mov byte [vcd_base + r0], r3
|
||||
|
||||
add r2, 1
|
||||
.l2_cond:
|
||||
@ -195,16 +287,6 @@ term_scroll:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print_u16:
|
||||
mov [rsp], rbp
|
||||
add rsp, 2
|
||||
|
||||
@ -1015,16 +1015,14 @@ auto Parser::parse_align() -> std::unique_ptr<Align>
|
||||
assert(test(TT::KwAlign));
|
||||
auto loc = m_tok.loc;
|
||||
step();
|
||||
if (!test(TT::Ident)) {
|
||||
error(current_loc(), "expected identifier");
|
||||
if (!test(TT::Int)) {
|
||||
error(current_loc(), "expected integer");
|
||||
return nullptr;
|
||||
}
|
||||
auto ident = m_tok.text;
|
||||
step();
|
||||
auto expr = parse_expr();
|
||||
if (not expr)
|
||||
return nullptr;
|
||||
return std::make_unique<Align>(loc, ident, std::move(expr));
|
||||
return std::make_unique<Align>(loc, std::move(expr));
|
||||
}
|
||||
|
||||
auto Parser::parse_line() -> std::unique_ptr<Line>
|
||||
|
||||
@ -102,7 +102,6 @@ namespace asmer {
|
||||
|
||||
struct Align {
|
||||
Loc loc;
|
||||
std::string_view ident;
|
||||
std::unique_ptr<Expr> expr;
|
||||
};
|
||||
|
||||
|
||||
@ -58,6 +58,9 @@ constexpr uint64_t char_data(uint8_t ch)
|
||||
case 'X': return 0x0066663C3C666666;
|
||||
case 'Y': return 0x0066663C18181818;
|
||||
case 'Z': return 0x007E7E0C18307E7E;
|
||||
|
||||
case ':': return 0x0018180000181800;
|
||||
|
||||
default: return 0x55AA55AA55AA55AA;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user