fix NOT logical error

i am extremely dumb and spent an inordinate amount of time debugging
This commit is contained in:
dogeystamp 2024-01-20 12:56:21 -05:00
parent 129383adba
commit ebc4d425dc
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
2 changed files with 43 additions and 1 deletions

42
contrib/gdb_cmds.gdb Normal file
View File

@ -0,0 +1,42 @@
# misc helpers for gdb debugging
# first run lc3, then
#
# echo 0 | doas tee /proc/sys/kernel/yama/ptrace_scope
#
# to disable security measures that prevent debugging,
# then
#
# rust-gdb -p $(pgrep lc3)
#
# then in the gdb shell
#
# source contrib/gdb_cmds.gdb
#
# you can then use the commands defined here
define vmb
# set a breakpoint at VM addr $0
break lc3::vm::instruction::execute_instruction if vm.registers.pc == $arg0 + 1
set $vmb_break = $bpnum
end
define vmj
# jump execution to VM addr $0
vmb $arg0
c
d $vmb_break
p vm.registers.pc-1
end
define vms
# step in vm with breakpoint $0
# before this break at the second line in lc3::vm::instruction::execute_instruction
# pass the number of this breakpoint in as $0
enable $arg0
c
p opcode
p vm.registers.pc-1
disable $arg0
end

View File

@ -276,7 +276,7 @@ fn op_not(vm: &mut VM, instr: u16) {
// NOTE // NOTE
// rustc is very friendly and tells you off if you use ~ as bitwise not // rustc is very friendly and tells you off if you use ~ as bitwise not
let res = !vm.registers.get_reg(sr); let res = !vm.registers.get_reg(sr);
vm.registers.set_reg_with_cond(sr, res); vm.registers.set_reg_with_cond(dr, res);
} }
//////////////// ////////////////