[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Inline assembly in Perl



In cleaning out my mail folders I ran across this.  Enjoy...

-------- Forwarded message --------
Newsgroups: comp.lang.perl.misc
Date: Thu, 02 Dec 1999 12:20:58 -0800
From: sthoenna@efn.org (Yitzchak Scott-Thoennes)
Subject: Re: Can Perl access INT 10 and conventional memory

In article <3843a27f_2@newsread3.dircon.co.uk>,
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>Mike Wang <mwang@3ware.com> wrote:
>> Hi,
>> 
>>   I am interested in using Perl to write a DOS utility.  I need to usr
>> Int 10 to control screen.  I also need to access the screen buffer, i.e.
>> segment 0b800h.
>> 
>>   Is it possible to do that?
>> 
>
>In short no.  No perl offers the facility to use DOS functions natively
>via that interrupt mechanism,  If you really feel the need to do this
>it might be possible to create an XS extension which does it (I am
>assuming you are using a Perl 5 here and this really presupposes djgpp)
>however I have no idea how this would work with the Dos Extender - so
>yes it might be possible if you have the technical expertise but you
>are basically on your own after you have read perlxstut ...

Actually, due to the power of DOS, you can create assembly language
subroutines with pure Perl, without using XS.

A sample:

#!perl -w
use strict;

sub JAPH {
    BEGIN {
	open F,">japh.com";
	print F 'x'x49;       # count them bytes!
	open F,">dbgtemp";
	print F <<EOF;
a
mov ax,1301
mov bx,001f
mov cx,001b
mov dx,0c1a
mov bp,116
int 10
mov ax,4c00
int 21
db 'Just Another Perl Hacker',d,a,7

w
q
EOF
	close F;
	system "c:/dos/debug.exe japh.com <dbgtemp";
    }
    system "japh.com"
}

# do some stuff

# call the JAPH "assembly language subroutine"
JAPH;

# do some other stuff

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe