Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!pitt!willett!ForthNet From: ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: FPC forth????????? Message-ID: <2664.UUL1.3#5129@willett.pgh.pa.us> Date: 24 Apr 91 03:10:38 GMT Organization: (n.) to be organized. But that's not important right now. Lines: 141 Category 1, Topic 21 Message 97 Tue Apr 23, 1991 R.BERKEY [Robert] at 05:16 PDT Tom Bushell writes, 91-04-17: > Is there any way to access extended memory from FPC? I'm SURE > I've seen some reference to doing this somewhere. There is an article on extended memory in Forth Dimensions, sometime during the last couple of years. Here's a driver I wrote (as is, no guarantees, no warranties). The fascinating thing about accessing extended memory involves the inability of the 80286 to switch from protected mode to real mode. The IBM AT overcomes that by having an external processor, the keyboard controller, raise the reset line on the 80286. Fortunately, the 80286 reset is well-defined, but the whole process is still a bit shaky because interrupts can't be routinely processed while in the protected mode. Anyway, this driver worked without problems for the application I used it in. I can second Milan Merhar's suggestion to get a copy of the IBM AT Technical Reference, I find it invaluable. \ EXTENDED.SEQ Extended-memory driver only FORTH also DEFINITIONS HEX assembler POSTVAR @ forth \ save POSTVAR setting until end of file POSTFIX \ use postfix assembler mode ( GDT table for extended memory ) here 1+ 1 and allot \ dealign \ puts GDT on an even address, for efficiency CREATE GDT ( Global Descriptor Table ) 10 allot gdt 10 erase -2 , ( length of segment ) HERE 3 allot ( source address ) 93 C, ( access rights byte ) 0 , ( reserved ) -2 , ( length of segment ) HERE 3 allot ( target address ) 93 C, ( access rights byte ) 12 allot constant EXTENDED-TARGET ( 24 bits ) extended-target 4 + 12 erase constant EXTENDED-SOURCE ( 24 bits ) ( Extended-memory move BIOS call ) ( Note that this BIOS call works only with 80286 and 80386 ) CODE ( #w GDT-offset GDT-segment -- error# ) bx pop ( gdt segment ) dx pop ( gdt offset ) cx pop ( block size in words ) si push bp push es push pushf bx, es mov dx, si mov $87 # ah mov $15 int popf es pop bp pop si pop al, al xor ah, al xchg ax push ( completion code ) next end-code code >ABS ( a seg -- da ) \ ;p convert address & segment to absolute addr \ : >ABS ( a seg -- da ) \ $10 um* rot 0 d+ ; ax pop $10 # cx mov cx mul bx pop bx, ax add 0 # dx adc $0f # dx and ( 80186 wraparound ) ax push dx push next end-code ( Hi-level extended-memory block move ) : ?EXTENDED-ERROR ( n -- ) ?dup if dup 1 = if ." Ram Parity," else dup 2 = if ." Exception Interrupt Error," else dup 3 = if ." Gate Address Line 20 Failed," else dup ." Undocumented error: " . then then then abort" Extended Memory Error" then ; ( Extended-memory block move ) : >EX ( from seg dto #b -- ) 2/ >r \ odd byte counts are rounded down extended-target 2+ c! extended-target ! \ dest adr into GDT >abs extended-source 2+ c! extended-source ! \ source adr into GDT r> gdt ?cs: ?extended-error ; : EX> ( dfrom to seg #b -- ) 2/ >r \ odd byte counts are rounded down >abs extended-target 2+ c! extended-target ! \ dest adr into GDT extended-source 2+ c! extended-source ! \ source adr into GDT r> gdt ?cs: ?extended-error ; \ The extended driver must have a count in words, not bytes. ( Get Extended-Memory Size ) CODE @EXMEMSIZE ( -- u ) $88 # ah mov si push bp push $15 int bp pop si pop ax push next end-code cr .( Extended memory available: $) @exmemsize u. .( Kbytes ) \ restore original POSTVAR setting #if POSTFIX #else PREFIX #then \ End EXTENDED.SEQ ________________________________________________ ----- This message came from GEnie via willett. You *cannot* reply to the author using e-mail. Please post a follow-up article, or use any instructions the author may have included (USMail addresses, telephone #, etc.). Report problems to: dwp@willett.pgh.pa.us _or_ uunet!willett!dwp