home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
misc_programming
/
example2.asm
< prev
next >
Wrap
Assembly Source File
|
1993-10-03
|
5KB
|
229 lines
; 32BIT DOS EXTENDER
;
; Written by Adam Seychell Wed 8-25-1993
;
.386p
DATA32 SEGMENT PUBLIC 'data' use32
CODE32_sel dw 50h ; Selector Values
CODE16_sel dw 58h
DATA_sel dw 60h
TheSTACK_sel dw 30h
VIDEO_sel dw 28h
FLAT_CODE32_sel dw 10h
FLAT_DATA_sel dw 08h
XMS_sel dw 18h
BASE_sel dw 20h
PSP_sel dw 48h
xms_usage dd 0f00000h ; Requested size of XMS block in bytes.
xms_base dd ? ; Linear base address of the XMS block.
Base_Segment dw ? ; Real mode segment value for base memory.
PSP_segment dw ? ; Real mode segment value for PSP segment.
align 4
count dd 0
v86_mesg db ' Message printed in v86 mode !!!!',10,13,36
file_name db 'C:\Command.COM',0
parmBlock db 10h dup (0)
welcom_mesg db 'Now in V86 mode',10,13,36
exit_mesg db 'back to borring real mode',10,13,36
cunt db 0
DATA32 ENDS
CODE32 SEGMENT PUBLIC 'CODE' USE32
assume DS:DATA32 , CS:CODE32
include stdio.asm
include macros.386
include dos32.inc
start32: ; 32 bit code entry point. DS -> data descripor
mov es,[xms_sel] ;Must load these with valid selectors
mov fs,[FLAT_DATA_sel]
mov gs,[video_sel]
sti
mov ss:real_ds,data32
mov ah,7
call clrscr
writeln ' Got Into 32 bit protected mode '
write <10,13,' A '>
mov edx,xms_usage
mov ah,0eh
call hex_dword
write <' byte extended memory block with base address '>
mov ah,0eh
mov edx,xms_Base
call hex_dword
writeln ' was allocated'
write <10,13,'Start of free base memory '>
xor edx,edx
mov dx,Base_Segment
shl edx,4
mov ah,0eh
call hex_dword
writeln
write <10,13,'PSP memory address '>
xor edx,edx
mov dx,PSP_Segment
shl edx,4
mov ah,0eh
call hex_dword
writeln
writeln
writeln ' Press any key to continue '
mov ah,0
dosint 16h
mov es,xms_sel
cld
mov cunt,10
tsm3:
writeln ' Filling memory ',5fh
mov es,xms_sel
mov ecx,xms_usage
shr ecx,2
mov edi,0
cld
rep stosd
mov es,base_sel
mov ecx,0A000h
sub cx,Base_segment
shl ecx,2
mov edi,0
cld
rep stosd
dec cunt
jnz tsm3
; jmp exit
open 1,'example2.exe'
jnc opok
writeln ' error openning file '
jmp exit
opok:
writeln ' reading file '
blockread 1,0B800h,00,1000
close 1
mov ss:real_ds,data32
dorr:
skipo:
sti
mov ax,psp_segment ; Resize memory block
mov word ptr ss:[real_ES],ax
mov bx,base_segment
sub bx,ax
mov ah,4ah
dosint 21h
jc exit
mov dx,offset welcom_mesg
mov ah,9
dosint 21h
mov es,PSP_sel
mov ax,es:[2Ch]
mov word ptr parmBlock,ax ; set environment segment
mov bx,psp_segment
mov word ptr parmBlock+2,80h ; set command line
mov word ptr parmBlock+4,bx
mov word ptr parmBlock+6,5Ch ; Set FCB 1
mov word ptr parmBlock+8,bx
mov word ptr parmBlock+0Ah,6Ch ; Set FCB 2
mov word ptr parmBlock+0Ch,bx
mov ss:[real_ES],data32
mov bx,offset parmBlock ; ES:BX > parameter block
mov ah,4bh
mov al,0
mov dx,offset file_name
dosint 21h
; mov ah,7
; call clrscr
mov dx,offset exit_mesg
mov ah,9
dosint 21h
exit:
mov ah,4ch ; Termiate the program
int 21h
; The 16 hardware inetrrupts.
; If an IRQ accours in V86 mode then the data segment registers will
; be equal to what they were before the last V86 call. ( i.e dosint xx ).
IRQ0: dosint 08h ; 8253 Timer 0
iretd
IRQ1: dosint 09h ; 8242 Keyboard
iretd
IRQ2: dosint 0Ah ; LPT 2 or Vert Retrate (6845)
iretd
IRQ3: dosint 0Bh ; Serial communications ports 2 & 4
iretd
IRQ4: dosint 0Ch ; Serial communications ports 1 & 3
iretd
IRQ5: dosint 0Dh ; Reserved
iretd
IRQ6: dosint 0Eh ; NEC µPD765 Floppy Disk Controler
iretd
IRQ7: dosint 0Fh ; LPT 1
iretd
IRQ8: dosint 70h ; 6818 CMOS CLOCK
iretd
IRQ9: dosint 71h ; Reserved
iretd
IRQ10: dosint 72h ; Reserved
iretd
IRQ11: dosint 73h ; Reserved
iretd
IRQ12: dosint 74h ; Reserved
iretd
IRQ13: dosint 75h ; 80x87 Math Co-Pro exception.
iretd
IRQ14: dosint 76h ; Hard Drive Cotroller.
iretd
IRQ15: dosint 77h ; Reserved
iretd
CODE32 ENDS
END