Fixed paging test and newAddr()
This commit is contained in:
parent
8f6f3d8928
commit
65ca078b55
3 changed files with 19 additions and 15 deletions
|
|
@ -78,7 +78,7 @@
|
||||||
"debugger": {
|
"debugger": {
|
||||||
"id": "pc386.debugger",
|
"id": "pc386.debugger",
|
||||||
"name": "",
|
"name": "",
|
||||||
"commands": "bp F000:825F;g",
|
"commands": "",
|
||||||
"messages": ""
|
"messages": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1594,7 +1594,7 @@ if (DEBUGGER) {
|
||||||
* @this {Debugger}
|
* @this {Debugger}
|
||||||
* @param {number|null|undefined} [off] (default is zero)
|
* @param {number|null|undefined} [off] (default is zero)
|
||||||
* @param {number|null|undefined} [sel] (default is null)
|
* @param {number|null|undefined} [sel] (default is null)
|
||||||
* @param {number|null|undefined} [addr] (default is zero)
|
* @param {number|null|undefined} [addr] (default is undefined)
|
||||||
* @param {boolean} [fData32] (default is false)
|
* @param {boolean} [fData32] (default is false)
|
||||||
* @param {boolean} [fAddr32] (default is false)
|
* @param {boolean} [fAddr32] (default is false)
|
||||||
* @return {{DbgAddr}}
|
* @return {{DbgAddr}}
|
||||||
|
|
@ -1603,7 +1603,7 @@ if (DEBUGGER) {
|
||||||
{
|
{
|
||||||
if (fData32 === undefined) fData32 = (this.cpu && this.cpu.segCS.dataSize == 4);
|
if (fData32 === undefined) fData32 = (this.cpu && this.cpu.segCS.dataSize == 4);
|
||||||
if (fAddr32 === undefined) fAddr32 = (this.cpu && this.cpu.segCS.addrSize == 4);
|
if (fAddr32 === undefined) fAddr32 = (this.cpu && this.cpu.segCS.addrSize == 4);
|
||||||
return {off: off || 0, sel: sel || null, addr: addr || 0, fTempBreak: false, fData32: fData32 || false, fAddr32: fAddr32 || false};
|
return {off: off || 0, sel: sel || null, addr: addr, fTempBreak: false, fData32: fData32 || false, fAddr32: fAddr32 || false};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
bits 16
|
bits 16
|
||||||
|
|
||||||
PAGING equ 0
|
PAGING equ 1
|
||||||
|
|
||||||
;
|
;
|
||||||
; If we built our data structures in RAM, we might use the first page of RAM (0x0000-0x0fff) like so:
|
; If we built our data structures in RAM, we might use the first page of RAM (0x0000-0x0fff) like so:
|
||||||
|
|
@ -199,18 +199,21 @@ initGDT:
|
||||||
%endif
|
%endif
|
||||||
;
|
;
|
||||||
; Now we want to build a page directory and a page table, but we need two pages of
|
; Now we want to build a page directory and a page table, but we need two pages of
|
||||||
; 4K-aligned physical memory. We can use hard-coded addresses in we're running in ROM,
|
; 4K-aligned physical memory. We can use a hard-coded address (segment 0x100, corresponding
|
||||||
; otherwise we ask DOS for some memory.
|
; to physical address 0x1000) if we're running in ROM; otherwise, we ask DOS for some memory.
|
||||||
;
|
;
|
||||||
cmp ax,CSEG_REAL
|
cmp ax,CSEG_REAL
|
||||||
mov edi,0x1000 ; default to the 2nd physical page in low memory
|
mov ax,0x100 ; default to the 2nd physical page in low memory
|
||||||
je initPages
|
je initPages
|
||||||
|
|
||||||
mov bx,0x1000 ; 4K paragraphs == 64K bytes
|
mov bx,0x1000 ; 4K paragraphs == 64K bytes
|
||||||
mov ah,DOS_SETBLOCK ; resize the current block so we can allocate a new block
|
mov ah,DOS_SETBLOCK ; resize the current block so we can allocate a new block
|
||||||
int INT_DOS
|
int INT_DOS
|
||||||
jnc allocPages
|
jnc allocPages
|
||||||
|
|
||||||
exitErrDOSMem:
|
exitErrDOSMem:
|
||||||
mov dx,errDOSMem
|
mov dx,errDOSMem
|
||||||
|
|
||||||
exitErrDOS:
|
exitErrDOS:
|
||||||
mov ah,DOS_STD_CON_STRING_OUTPUT
|
mov ah,DOS_STD_CON_STRING_OUTPUT
|
||||||
int INT_DOS
|
int INT_DOS
|
||||||
|
|
@ -231,20 +234,21 @@ allocPages:
|
||||||
;
|
;
|
||||||
; AX == segment of 64K memory block
|
; AX == segment of 64K memory block
|
||||||
;
|
;
|
||||||
|
initPages:
|
||||||
movzx eax,ax
|
movzx eax,ax
|
||||||
shl eax,4
|
shl eax,4
|
||||||
add eax,0xfff
|
add eax,0xfff
|
||||||
and eax,~0xfff
|
and eax,~0xfff
|
||||||
mov edi,eax ; EDI == first physical 4K-aligned page within the 64K
|
mov esi,eax ; ESI == first physical 4K-aligned page within the given segment
|
||||||
|
shr eax,4
|
||||||
initPages:
|
mov es,ax
|
||||||
mov esi,edi ; ESI == saved copy of EDI
|
xor edi,edi
|
||||||
;
|
;
|
||||||
; Build a page directory at EDI with only 1 valid PDE (the first one)
|
; Build a page directory at ES:EDI with only 1 valid PDE (the first one)
|
||||||
;
|
;
|
||||||
cld
|
cld
|
||||||
cli ; make sure interrupts are still off (in case any DOS calls turned them back on)
|
cli ; make sure interrupts are still off (in case any DOS calls turned them back on)
|
||||||
mov eax,edi
|
mov eax,esi
|
||||||
add eax,0x1000 ; EAX == page frame address (of the next page)
|
add eax,0x1000 ; EAX == page frame address (of the next page)
|
||||||
or eax,PTE_USER | PTE_READWRITE | PTE_PRESENT
|
or eax,PTE_USER | PTE_READWRITE | PTE_PRESENT
|
||||||
stosd
|
stosd
|
||||||
|
|
@ -284,7 +288,7 @@ toProt32:
|
||||||
;
|
;
|
||||||
; Test moving a segment register to a 32-bit memory location
|
; Test moving a segment register to a 32-bit memory location
|
||||||
;
|
;
|
||||||
test1: mov edx,[0x0000] ; save the DWORD at 0x0000:0x0000 in EDX
|
test1: mov edx,[0x0000] ; save the DWORD at 0x0000:0x0000 in EDX
|
||||||
or eax,-1
|
or eax,-1
|
||||||
mov [0x0000],eax
|
mov [0x0000],eax
|
||||||
mov [0x0000],ds
|
mov [0x0000],ds
|
||||||
|
|
@ -295,7 +299,7 @@ test1: mov edx,[0x0000] ; save the DWORD at 0x0000:0x0000 in EDX
|
||||||
xor eax,0xffff0000
|
xor eax,0xffff0000
|
||||||
cmp eax,[0x0000]
|
cmp eax,[0x0000]
|
||||||
jne error
|
jne error
|
||||||
mov [0x0000],edx ; restore the DWORD at 0x0000:0x0000 from EDX
|
mov [0x0000],edx ; restore the DWORD at 0x0000:0x0000 from EDX
|
||||||
jmp test2
|
jmp test2
|
||||||
;
|
;
|
||||||
; Test moving a byte to a 32-bit register with sign-extension
|
; Test moving a byte to a 32-bit register with sign-extension
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue