🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.linux.development.apps
Article #14

Re: Assembler Statement in C program

#14
From: Roger Espel Llima
Date: Sun, 21 Apr 1996 14:00
54 lines
2957 bytes
In article <317A2105.77EF485@bis.co.il>, Meir Dukhan  <meir@bis.co.il> wrote:
>Hi, 
>
>I'm trying to port some piece of C code to linux/unix.
>This code contains statement in assembler.
>
>1. How can I compile it under linux with gcc or gas ?
>
>2. Will this be portable ?

[ code snipped ]

There are various problems with that; one is that your code is 8086 
assembler, which runs unmodified on 386+ processors only when they are 
in "real mode".  However, Linux runs in protected mode, which is much 
more powerful but not compatible.  Also, your code accesses some 
absolute memory addresses and calls BIOS interrupts, which Linux won't 
let you do (because of memory protection and security, as well as 
different addressing).  Thirdly, none of this would be portable to any 
other Unix system.

Porting programs from DOS to Unix isn't that easy if they interact 
directly with the system and/or do any kind of full-screen handling;
to do this properly in Unix (and Linux), you can do either of these:

 . use the 'ncurses' library, which is a portable and powerful package 
 of full-screen handling routines.  Check out the manual page for it,
 with "man ncurses".

 . use the termcap interface, which is portable but much less of a 
 powerful library.  it might actually be easier to you if you're used
 to low-level handling in DOS, as this is pretty low-level too.
 Check out the man pages for 'termcap'.  Under some Linux versions this 
 is in fact emulated by the ncurses library, and documented in the
 man page for 'curs_termcap'.  Also, this won't handle the tty mode
 (keyboard input mode) for you, so check out the manpage for 
 'tcgetattr' and 'tcsetattr'.

 . if you're only going to be using your program on the Linux console
 and other ANSI-compatible terminals, directly use the ANSI escape 
 sequences to do things like clear the screen.  As far as I know they're 
 not on any man page on Linux.  You'll also need to deal with 
 tcgetattr() and tcsetattr() yourself.  It's not portable to general
 terminals.

Mail me if you want some sample code that uses the 2nd alternative.

	-Roger
--
#!/usr/local/bin/perl                       # e-mail: roger.espel.llima@ens.fr
s**QJwEw=QGv:vt=PGwEvvvEwt=OGUtMGUt=N\@:tKG:A=O> G:GNb,&+ 1%" Z)2" j&zz,+ Y+1*
,s^$^&E["+0,/0%&- [y*-y&\$+!=Pt:S=QtUSQM%11-RGG444F"##F,/\$Gz)2"/&zz,+F%1*)=^,
s@$@Q SF=QSUUt=PSF:t=OSJ>=NSL>PN/,\$"/F"0-")F))&*yX"+0F#/=NtUUGNtUUG=OtGPtG=@,
y,= :-|"-9,\n "-|, ,s,&,\\"\\,g,s,;,/"/,g,s,",===,g,s,(\d),' 'x$1,eg,print $_;
Technical Details
Message-ID: <4ldf2n$gf6@nef.ens.fr>
Path: arc1-ca.pugleaf.net!nef.ens.fr!bireme!espel
References: <317A2105.77EF485@bis.co.il>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nef.ens.fr!bireme!espel
From: espel@bireme.ens.fr (Roger Espel Llima)
Newsgroups: comp.os.linux.development.apps,comp.unix.programmer,comp.lang.c
Subject: Re: Assembler Statement in C program
Date: 21 Apr 1996 14:00:55 GMT
Organization: Ecole Normale Superieure, Paris
Message-ID: <4ldf2n$gf6@nef.ens.fr>
References: <317A2105.77EF485@bis.co.il>
NNTP-Posting-Host: bireme.ens.fr