2022-09-14 21:54:59 -05:00
|
|
|
[BITS 16]
|
|
|
|
real_hexprint:
|
|
|
|
xor cx, cx
|
|
|
|
mov bl, al
|
|
|
|
shr al, 4
|
|
|
|
jmp .donibble
|
|
|
|
.nibble2:
|
|
|
|
mov al, bl
|
|
|
|
inc cx
|
|
|
|
.donibble:
|
|
|
|
and al, 0x0F
|
|
|
|
cmp al, 0x0A
|
|
|
|
jl .noadjust
|
|
|
|
add al, 'A' - '0' - 10
|
|
|
|
.noadjust:
|
|
|
|
add al, '0'
|
|
|
|
mov ah, 0x1f
|
|
|
|
stosw
|
|
|
|
test cx, cx
|
|
|
|
jz .nibble2
|
|
|
|
ret
|
|
|
|
real_printword:
|
|
|
|
mov dx, ax
|
|
|
|
mov al, ah
|
|
|
|
call real_hexprint
|
|
|
|
mov ax, dx
|
|
|
|
call real_hexprint
|
|
|
|
ret
|
2022-09-19 16:06:01 -05:00
|
|
|
global v86Test
|
|
|
|
v86Test:
|
2022-09-14 21:54:59 -05:00
|
|
|
mov ax, 0xb814
|
|
|
|
mov es, ax
|
|
|
|
mov di, 20
|
|
|
|
mov ax, sp
|
|
|
|
call real_printword
|
|
|
|
add di, 2
|
|
|
|
mov ax, ds
|
|
|
|
call real_printword
|
|
|
|
add di, 2
|
|
|
|
mov ax, cs
|
|
|
|
call real_printword
|
|
|
|
.loop:
|
|
|
|
inc byte [0]
|
|
|
|
int 3
|
2022-09-16 15:50:58 -05:00
|
|
|
int 3
|
2022-09-14 21:54:59 -05:00
|
|
|
int 0x30 ; exit
|
|
|
|
jmp $
|
2022-09-19 16:06:01 -05:00
|
|
|
global v86GfxMode
|
|
|
|
v86GfxMode:
|
|
|
|
mov ax, 0x13
|
|
|
|
int 0x10
|
|
|
|
int 0x30
|
2022-09-14 21:54:59 -05:00
|
|
|
jmp $
|
|
|
|
[BITS 32]
|
|
|
|
; extern void enter_v86(uint32_t ss, uint32_t esp, uint32_t cs, uint32_t eip);
|
|
|
|
global enter_v86
|
|
|
|
enter_v86:
|
2022-09-19 16:06:01 -05:00
|
|
|
pop eax
|
2022-09-14 21:54:59 -05:00
|
|
|
mov ebp, esp ; save stack pointer
|
2022-09-19 16:06:01 -05:00
|
|
|
call save_current_task
|
|
|
|
push dword [ebp+0] ; ss
|
|
|
|
push dword [ebp+4] ; esp
|
2022-09-14 21:54:59 -05:00
|
|
|
pushfd ; eflags
|
|
|
|
or dword [esp], (1 << 17) ; set VM flags
|
|
|
|
;or dword [esp], (3 << 12) ; IOPL 3
|
2022-09-19 16:06:01 -05:00
|
|
|
push dword [ebp+8] ; cs
|
|
|
|
push dword [ebp+12] ; eip
|
2022-09-14 21:54:59 -05:00
|
|
|
iret
|
|
|
|
|
2022-09-19 16:06:01 -05:00
|
|
|
; return address in eax, return stack in ebp
|
|
|
|
extern save_current_task
|