fix program
This commit is contained in:
parent
8cb0ac6070
commit
3477bb5888
@ -66,7 +66,6 @@ key_press_int:
|
|||||||
|
|
||||||
mov [rsp], r1
|
mov [rsp], r1
|
||||||
add rsp, 2
|
add rsp, 2
|
||||||
;call print_char
|
|
||||||
call print_u16
|
call print_u16
|
||||||
sub rsp, 2
|
sub rsp, 2
|
||||||
|
|
||||||
@ -112,35 +111,44 @@ print_u16:
|
|||||||
mov rbp, rsp
|
mov rbp, rsp
|
||||||
|
|
||||||
mov r1, [rbp-6] ; value to print
|
mov r1, [rbp-6] ; value to print
|
||||||
mov r4, 0 ; place index
|
mov r2, 0 ; place index
|
||||||
|
|
||||||
jmp .digits_cond
|
jmp .digits_cond
|
||||||
.digits_body:
|
.digits_body:
|
||||||
mov r2, .places
|
mov r3, .places
|
||||||
add r2, r4
|
add r3, r2
|
||||||
mov r2, [r2] ; place
|
mov r3, [r3] ; place
|
||||||
|
|
||||||
mov r3, 0 ; place occurences
|
mov r4, 0 ; place occurences
|
||||||
jmp .place_cond
|
jmp .place_cond
|
||||||
.place_body:
|
.place_body:
|
||||||
add r3, 1
|
add r4, 1
|
||||||
sub r1, r2
|
sub r1, r3
|
||||||
.place_cond:
|
.place_cond:
|
||||||
cmp r2, r1
|
cmp r3, r1
|
||||||
mov r0, rfl
|
mov r0, rfl
|
||||||
and r0, fl_eq | fl_lt
|
and r0, fl_eq | fl_lt
|
||||||
jnz r0, .place_body
|
jnz r0, .place_body
|
||||||
|
|
||||||
mov r0, r3
|
mov r0, r4
|
||||||
add r0, 48
|
add r0, 48
|
||||||
|
|
||||||
|
add rsp, 4
|
||||||
|
mov [rsp-4], r1
|
||||||
|
mov [rsp-2], r2
|
||||||
|
|
||||||
mov [rsp], r0
|
mov [rsp], r0
|
||||||
add rsp, 2
|
add rsp, 2
|
||||||
call print_char
|
call print_char
|
||||||
sub rsp, 2
|
sub rsp, 2
|
||||||
|
|
||||||
add r4, 2
|
mov r2, [rsp-2]
|
||||||
|
mov r1, [rsp-4]
|
||||||
|
sub rsp, 4
|
||||||
|
|
||||||
|
add r2, 2
|
||||||
.digits_cond:
|
.digits_cond:
|
||||||
cmp r4, 10
|
cmp r2, 10
|
||||||
mov r0, rfl
|
mov r0, rfl
|
||||||
and r0, fl_lt
|
and r0, fl_lt
|
||||||
jnz r0, .digits_body
|
jnz r0, .digits_body
|
||||||
|
|||||||
@ -279,7 +279,7 @@ int VM::run_instruction()
|
|||||||
auto ins = InsReader(*this);
|
auto ins = InsReader(*this);
|
||||||
auto op = static_cast<Op>(ins.to_u16() & 0b11'1111);
|
auto op = static_cast<Op>(ins.to_u16() & 0b11'1111);
|
||||||
std::println(
|
std::println(
|
||||||
" [{: >2x}]: 0x{:04x} {: <6} {:04b} {:04b} {:04b} {:04b} {:04x}",
|
" [{: >3x}]: 0x{:04x} {: <6} {:04b} {:04b} {:04b} {:04b} {:04x}",
|
||||||
ip,
|
ip,
|
||||||
ins.to_u16(),
|
ins.to_u16(),
|
||||||
op_str(op),
|
op_str(op),
|
||||||
@ -315,7 +315,7 @@ int VM::run_instruction()
|
|||||||
"rfl"sv,
|
"rfl"sv,
|
||||||
"rip"sv,
|
"rip"sv,
|
||||||
};
|
};
|
||||||
std::println(" {: <3} | {:04x} {: 5}",
|
std::println(" {: <3} | {:04x} {: >5}",
|
||||||
reg_strs[reg],
|
reg_strs[reg],
|
||||||
this->reg(static_cast<Reg>(reg)),
|
this->reg(static_cast<Reg>(reg)),
|
||||||
this->reg(static_cast<Reg>(reg)));
|
this->reg(static_cast<Reg>(reg)));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user