🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc.misc
Article #2797

Inline assembly code possible with any compiler

#2797
From: Monte Bateman
Date: Tue, 04 Sep 1990 10:05
37 lines
1526 bytes
It's possible to do in-line assembler with ANY compiler.    

This technique was discussed in the "C Users's Journal" for 
May, 1990 - author James Kuzdrall.

First, figure out what the machine codes are for the 
assembly language you want to execute - 

  NOTE: The nice thing about this procedure is that it will port
   to other processors - say if you had a C compiler that 
   compiles to 6809 machine code...

finish by converting your opcodes to octal.  The author suggests
making a hex-octal conversion table by using printf().


Second, in you C code, do something like

    char *x_str;              /* declare the executable string  */
    x_str = "\032\020\071";   /* insert your OCTAL opcodes here */


Third, execute this string, using the incantation:

   (*((void (*)()) x_str))();



This should do the trick.

-Monte


Monte Bateman
WB5RZX @ WB5RZX
bateman @ nsslsun.gcn.uoknor.edu
National Severe Storms Laboratory, Norman, OK!  73069
Technical Details
Message-ID: <1990Sep4.100511.10686@uokmax.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!tut.cis.ohio-state.edu!unmvax!uokmax!nsslsun.gcn.uoknor.edu!bateman
References: <1990Sep3.220503.21586@ucselx.sdsu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!tut.cis.ohio-state.edu!unmvax!uokmax!nsslsun.gcn.uoknor.edu!bateman
From: bateman@nsslsun.gcn.uoknor.edu (Monte Bateman)
Newsgroups: comp.sys.ibm.pc.misc,comp.os.msdos.programmer
Subject: Inline assembly code possible with any compiler
Message-ID: <1990Sep4.100511.10686@uokmax.uucp>
Date: 4 Sep 90 10:05:11 GMT
References: <1990Sep3.220503.21586@ucselx.sdsu.edu>
Sender: news@uokmax.uucp (Nets)
Organization: National Severe Storms Laboratory
Lines: 37