Board index » delphi » Inline Assembly

Inline Assembly

Ok, I'm pretty new to Turbo Pascal and I want a good tutorial/help on
inline assembly.  It seems complex, but I consider myself an experienced
programmer (Just new to TP).
--
Peter Binsted (cm961)

 

Re:Inline Assembly


In article <E72Inv.4M9.0.qu...@torfree.net>,

Quote
Peter Binsted <cm...@torfree.net> wrote:

:Ok, I'm pretty new to Turbo Pascal and I want a good tutorial/help on
:inline assembly.  It seems complex, but I consider myself an experienced
:programmer (Just new to TP).

This is about all the little I know of this subject

-From: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip Frequently Asked TP Questions
-Subject: Writing inline code

50. *****
 Q: How can I write inline code?

 A: In Turbo Pascal versions prior 6.0 assembler code could not be
directly included in the code. Instead one had to assemble the code
into inline statements. Consider the task of rebooting the PC
(without disk closing and cache flushing).  The assembler code for
this is
  mov ax,$40
  mov ds,ax
  mov wo [$72],$1234
  jmp $FFFF:$0000
To assemble this code into an inline statement write the following
file calling it e.g. debug.in.  The empty line is important. Also
carefully note that debug assumes hexadecimal notation. Do not use
the $ designator in debug.in.
  .... begin debug.in, cut here ....
  a 100
  mov ax,40
  mov ds,ax
  mov wo [72],1234
  jmp FFFF:0000

  u 100
  q
  .... end debug.in, cut here ....
Give the following command
  debug < debug.in
You'll get
  0E9E:0100 B84000        MOV     AX,0040
  0E9E:0103 8ED8          MOV     DS,AX
  0E9E:0105 C70672003412  MOV     WORD PTR [0072],1234
  0E9E:010B EA0000FFFF    JMP     FFFF:0000
This translates into
    Inline ($B8/$40/$00/
            $8E/$D8/
            $C7/$06/$72/$00/$34/$12/
            $EA/$00/$00/$FF/$FF);

 A2: You can also utilize an inline <--> asm converter called
  ftp://garbo.uwasa.fi/pub/pc/turbopas/inlin219.zip
  inlin219.zip Inline assembler for Turbo Pascal, w/src, D.Baldwin
It has two sources, inline.pas and uninline.pas which you can
compile to do the conversions in both directions for you. For
example, if you have a file test.asm containing the
  mov ax,$0040
  mov ds,ax
  mov word ptr [$72],$1234
  jmp far $FFFF:$0000
then "inline test.asm" will produce test.obj with the following,
expected contents
  Inline(
    $B8/$40/$00/           {mov ax,$0040}
    $8E/$D8/               {mov ds,ax}
    $C7/$06/$72/$00/$34/$12/ {mov word ptr [$72],$1234}
    $EA/$00/$00/$FF/$FF);  {jmp far $FFFF:$0000}
--------------------------------------------------------------------

   All the best, Timo

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
mailto:t...@uwasa.fi  <URL:http://uwasa.fi/~ts>  ; FIN-65101,  Finland

Re:Inline Assembly


cm...@torfree.net (Peter Binsted) once said:

Quote
>Ok, I'm pretty new to Turbo Pascal and I want a good tutorial/help on
>inline assembly.  It seems complex, but I consider myself an experienced
>programmer (Just new to TP).

Asm
        opcode operand[,operand]
End;

Or, you could go get a book on assembler :) or atleast a tutorial. I belive
there are  few tutorials out there, just fire up yer old port 80 crawler, and
search for "asm tutorial"

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Kim Robert Blix  ( kb...@sn.no  &  http://home.sn.no/~kblix )

 "How do you shoot the devil in the back?"
 "What if you miss?" -Verbal Kint
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Other Threads