diff --git a/vm/in/instrs.h b/vm/in/instrs.h index 7c3a9b3..6a88eba 100644 --- a/vm/in/instrs.h +++ b/vm/in/instrs.h @@ -68,7 +68,7 @@ bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *r1, ulong *r2) \ #define CHK_SUPERV() \ do { \ - if ((cr0 & UF) == 1) { \ + if ((cr0 & UF) > 0) { \ _except(ctx, E_SYS, "Supervisor-only INSTR"); \ } \ } while (0) diff --git a/vm/pc/regs.h b/vm/pc/regs.h index 7dde844..9858c6c 100644 --- a/vm/pc/regs.h +++ b/vm/pc/regs.h @@ -1,6 +1,46 @@ // The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +// Register types +enum +{ + GPR = 1 << 0, // General + CTL = 1 << 1, // Control + SEG = 1 << 2, // Segment + RES = 1 << 8, // Reserved for insternal use + SYS = 1 << 9, // Reserved for supervisor mode +}; + +// FLG register +enum +{ + CF = 1 << 0, // Carry flag + OF = 1 << 1, // Overflow flag + + ZF = 1 << 2, // Zero flag + SF = 1 << 3, // Sign flag + + PF = 1 << 4, // Parity flag + DF = 1 << 5, // Direction flag + + IF = 1 << 16, // Interrupts enable flag +}; + +// CR0 register +enum +{ + UF = 1 << 15, // User-mode flag +}; + +struct reg_t +{ + char *name; + char *desc; + char *conv; + ulong val; + ulong flags; +}; + enum { INV, @@ -71,37 +111,4 @@ enum NREGS }; -enum -{ - GPR = 1 << 0, // General - CTL = 1 << 1, // Control - SEG = 1 << 2, // Segment - RES = 1 << 8, // Reserved for insternal use - SYS = 1 << 9, // Reserved for supervisor mode -}; - -// FLG register -enum -{ - CF = 1 << 0, // Carry flag - OF = 1 << 1, // Overflow flag - - ZF = 1 << 2, // Zero flag - SF = 1 << 3, // Sign flag - - PF = 1 << 4, // Parity flag - DF = 1 << 5, // Direction flag - - UF = 1 << 16, // User-mode flag - IF = 1 << 17, // Interrupts enable flag -}; - -struct reg_t -{ - char *name; - char *desc; - char *conv; - ulong val; - ulong flags; -};