Re: [Possibly OT] 16-bit Assembly Programming

2007-09-17 Thread David Given
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Tobias Weingartner wrote:
[...]
 One thing your teacher may not know is that x86 assembly includes the
 32-bit environment, and (now) also a 64-bit environment.  However, running
 16-bit code under OpenBSD i386 is going to be somewhat difficult.  We don't
 bother supplying 16-bit services, and only consume 16-bit services (from
the
 bios) for a few things necessary.  It is hard, and somewhat error prone.

Linux has a thing called elksemu. It is, basically, a binary loader that will
allow you to run 16-bit ELKS binaries on 32-bit Linux. (ELKS is a
now-moribund
port of a Linux subset to 8086 class machines, using modified Minix
binaries.)
It intercepts int 0x80 and converts the 16-bit ELKS syscalls to 32-bit Linux
ones.

So, write(0, Hello, world!\n, 14) becomes:

mov ax, 0
mov bx, _label
mov cx, 14
int 0x80

...which is, I believe, exactly what the OP wanted.

elksemu does all the dirty work with the vm86() syscall, which was put in for
dosemu. I know that dosemu works, or at least worked, on NetBSD and FreeBSD
- --- does OpenBSD have this functionality?

- --
bbb o=o=o o=o=o=o=o=o=o=oo=o=o=
 bbb
http://www.cowlark.com
bbbbbbbbbbbbbbbbbbb
b
b There does not now, nor will there ever, exist a programming language in
b which it is the least bit hard to write bad programs. --- Flon's Axiom
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG7wDdf9E0noFvlzgRAgIeAJ9tDWiILb5ZvOHdQMFKt3IJx498DQCdHnvX
LCkFDYMfs7Boc07yqcTSVZw=
=/XPv
-END PGP SIGNATURE-



Re: [Possibly OT] 16-bit Assembly Programming

2007-09-16 Thread Tobias Weingartner
In article [EMAIL PROTECTED], Aaron Hsu wrote:
 
  I am attempting to create an assembly program (for a class) on
  OpenBSD. The teacher has no issue with me developing the code based
  on the UNIX-based assembly (int 0x80 syscalls vs. int 0x21 Dos
  Function), but he does not want me to use 32-bit code. I believe this
  has something to do with him wanting me to use a Real-addressing
  Mode as opposed to the 32-bit protected mode. I'm doing x86
  assembly.

One thing your teacher may not know is that x86 assembly includes the
32-bit environment, and (now) also a 64-bit environment.  However, running
16-bit code under OpenBSD i386 is going to be somewhat difficult.  We don't
bother supplying 16-bit services, and only consume 16-bit services (from the
bios) for a few things necessary.  It is hard, and somewhat error prone.

I would recomment you run bochs and/or qemu with a freedos installation or
somesuch.  You can still use OpenBSD as your development platform, but your
code would be run inside a 16-bit (to start with) environment.  The other
nice thing is that you'd have an ICE like debugger for your code, which
can be very handy in debugging what is going wrong.

Good luck,

--Toby.



[Possibly OT] 16-bit Assembly Programming

2007-09-13 Thread Aaron Hsu
Hello all,

I am attempting to create an assembly program (for a class) on OpenBSD. The 
teacher has no issue with me developing the code based on the UNIX-based 
assembly (int 0x80 syscalls vs. int 0x21 Dos Function), but he does not want 
me to use 32-bit code. I believe this has something to do with him wanting me 
to use a Real-addressing Mode as opposed to the 32-bit protected mode. I'm 
doing x86 assembly.

Now, I can create nice and working 32-bit OpenBSD elf executables using yasm 
and so on. It took a bit of work to understand how to do it, but other than 
that, it works fine. Now, the issue I am having is that I can't figure out how 
to instead write 16-bit code. Basically, the teacher should be happy if I 
don't use the extended registers. Reading in the Yasm documentation, I found 
the BITS directive, and also the note that it should not be necessary to use 
this directive, since the object file format I choose should automatically 
handle this. The `obj' format was indicated as one of the file formats that I 
should use. However, the yasm assembler in OpenBSD does not have that as a 
valid format. Also, there seems to be no way to generate 16-bit OpenBSD 
executables. Is this true?

My basic question is, how can I create an assembly program using that will run 
on OpenBSD that is 16-bit (that is, using only the non-extended registers)?

Any help would be greatly appreciated, as searching online has confused me 
royally as to whether this is even possible or not. It seems like it should be.

-- 
((name Aaron Hsu)
 (email/xmpp [EMAIL PROTECTED])
 (phone 703-597-7656)
 (site http://www.aaronhsu.com;))