From: H. Peter Anvin N9ITP (hpa@casbah.acns.nwu.edu)
Date: 11/18/92


From: hpa@casbah.acns.nwu.edu (H. Peter Anvin N9ITP)
Subject: Re: Assembler help needed.  Real bad like.
Date: Wed, 18 Nov 1992 10:08:12 GMT

In article <1992Nov18.062004.545@newshub.ariel.yorku.ca> of comp.os.linux,
  cs911461@ariel.yorku.ca (CHRISTIAN D. ARMOUR) writes:
>
> 1) I'm using as86 because it uses the mnemonics which I like
> and am used to (Intel 8086). Should I use the slightly weird
> gas instead? How can I learn how to use it? Where are the
> docs/man pages for these things hidden in this vast world?

This is WRONG. as86 produces 16-BIT REAL MODE CODE. Linux uses 32-BIT
PROTECTED MODE. The two are NOT compatible, you *have* to use gas.

> 2) Why does as86 give me the following error:
>
> MOV DX,ES:[BX]
> ---------------------^
> Junk after operands

The syntax used by as86 is:

        seg es
        mov dx,(bx)

But, as I said above, don't use as86. Also, under Linux in user mode,
DS == ES == SS; CS points to the same memory as well but is an executable
segment descriptor instead of a data segment descriptor. In either case,
you should never need to use a segment override unless you are hacking the
kernel (in which case you use an FS dereference to access user space).

Also, note that writing to the TEXT portion of your program will cause a
segment violation.

> 3) How is the video controller programmed directly under Linux,
> or for that matter, any Unix-style O/S?

Same way it is otherwise. BIOS is useless under Linux, or any other OS
that uses protected mode (although OS/2 actually lets you access BIOS in a
virtual 8086 session). Your program needs to be run as root and request
I/O privileges from the kernel.

> 4) What is an "unbound label"?

A label that doesn't reference an address, i.e. is undefined.

> 5) How hard/easy is it to mix C and assembler under Linux? I have
> experience doing this under DOS (386) and Ultrix (MIPS) but am a
> little scared to try under Linux. I'm trying to port my extensive
> library of VGA code from the DOS environment. So far, no problems
> except from the assembler.

It shouldn't be hard at all. Either use separate modules or use GCC inline
code. Also, don't miss checking out VGALib... already ann extensive
collection of VGA code to my understanding.

        /hpa

-- 
INTERNET:  hpa@nwu.edu   TALK:      hpa@casbah.acns.nwu.edu
BITNET:    HPA@NUACC     IBMNET:    16331@IBMX400
HAM RADIO: N9ITP         NeXTMAIL:  hpa@lenny.acns.nwu.edu
Keyboard not found, press F1 to continue or Ctrl-Esc for setup