Friday, December 19, 2014

Mathew Brandt's c68 and CP/M 68

While looking for C compiler for CP/M 68 looks I've found something that looks quite fine.
As for version "5.1 (beta)/25 Apr 2002" c68 taken from http://homepage.ntlworld.com/itimpi/compsrc.htm has
-cpm68 option and it somehow work. It even claims that it generates AS68compatible source.
There are a lot of versions of this compiler on the net, but this one is surely the best I've tried (but as I understand it's unable to compile itself, what a pity)
The way it does not work is writing hex as 0xXX, not as $XX, so here is a fix:
out68k_c.c:
PRIVATE void put_byte P1 (UVAL,val)
{        
    put_header (bytegen, alignment_of_type (tp_char));
    oprintf ("$%lx", (unsigned long) (val & OxffUL));
/*DtZ     oprintf ("0x%lx", (unsigned long) (val & OxffUL)); */
    outcol += 4; /* or  should be changed to +3 ? */
}

PRIVATE void put_word P1 (UVAL, val)
{
   put_header (wordgen, alignment_of_type (tp_short));
/*DtZ     oprintf ("0x%lx", (unsigned long) (val & OxffffUL)); */
    oprintf ("$%lx", (unsigned long) (val & OxffffUL));
    outcol += 6; /* or should be changed to +7? */
} 

Next, AS68 does not need/want "\t.sect", it accepts .data and .text directly.
out68k_c.c:
static void seg P3 (enum e_sg, segtype, const char *, segname, SIZE, al)
{
 nl();
 if (curseg != segtype) {                                                                                     
/*DtZ   oprintf ("\t.sect\t%s%s", segname, newline);*/                                                        
        oprintf ("\t%s * Segment %s", segname, newline);                                                       

And you should edit config.h the way it can generate for 68000 and to check the compiler binary you get can do -cpm68k and -int=16.
Next, remember that's just compiler, not even preprocessor: so on unix side I had to do
cc -E -I/home/dtz/8BIT/68K/CPM1.3/DISK4 main.c > p_main.c
./cc68 -int=16 -cpm68k -v p_main.c > main.s
Also, note that standard CP/M 68's headers lacks most of the C functions; so I had to copy them from "C language programming manual" (do not forget to add link link there!)
On CP/M system, assemble the file with AS68 -U file.o, and then link it with CLINK.SUB
UPD: More, the code it generates can be feed to jas assembler mentioned some time ago.
UPDD: Looks like optimization code is faulty.
UPDDD: 201607 Mirrored Here

Monday, December 8, 2014

Sozobon's JAS runs at CP/M 68K

As I expected, JAS from Sozobon C compiler for Atari was easy to port back to CP/M 68 and it works natively.
To do it, do the following: compile Sozobon C on unix host (see virtuallyfun.superglobalmegacorp.com/?p=97 (or mirrored on my site), then compile jas by xhcc, now using makefile , not make.unx.
First, make a small patch in main.c:
        if ( freopb( ofile, "w", stdout ) ==  NULL )
                error( 0, "can't open object file for writing" );
      if ( freopen( ofile, "bw", stdout ) == (FILE *) NULL )
             error( 0, "can't open object file for writing" );


Then take CP/M-68 1.3 distribution files; here you'll find DISK4 and header files on it. You have to convert them to lowercase and erase all symbols after (and including) ^Z.
Then edit makefile to became smth like that:
CC = ./xhcc
CFLAGS = -c -v -O -I/home/dtz/8BIT/68K/CPM1.3/DISK4
Run make, you'll get 10 *.s files; then assemble them by jas:
#!/usr/local/bin/tclsh
foreach f [glob *.s] {
 exec ./xjas -8 $f
}
You'll get 10 .o files. Transfer them to CP/M 68K host and link by DRI's LO68: c:lo68 -R -u_nofloat -o jas.68k c:s.o CBUF.O CPY.O GEN.O HDR.O LEX.O MAIN.O OPS.O OPT.O PARSE.O PASS.O SCAN.O SYM.O c:clib And know what? It works! (do not forget to add -8 switch when calling jas). However, that's not very useful as assembler, but better to have an assembler with SOURCE as alternative to AS68.
Get it from here ;-) [ok from here]

Sunday, December 7, 2014

Use of Sozobon C on CP/M 68

I've tried to make some use of Sozobon C compiler to be somehow-used on[or together with] CP/M 68.
First, it can be compiled on modern Linux/MacOSX; that's good. And the thing that is useful is xjas assembler. At least with -8 flag it generates .o files with can be linked natively on CP/M'68 lo68.

And, what I say? I say: GOOOOOOOOOD!

Tuesday, November 18, 2014

Hello world assember 68k / as68

One more reminder to myself: the skeleton of assembler program
        text
        globl   _main
_main:
        move.b  #'*',d1
        move.w  #2,d0           * calling BDOS '2'
        trap    #2
        move.b  #'*',d1
        move.w  #2,d0           * calling BDOS '2'
        trap    #2
        move.b  #$0A,d1
        move.w  #2,d0           * calling BDOS '2'
        trap    #2
        move.b  #$0D,d1
        move.w  #2,d0           * calling BDOS '2'
        trap    #2
        rts

Assemble
AS68 hello.s
Link

LO68 -R -O hello.68K hello.O


Tuesday, October 21, 2014

Compaq Prosignia VS - pcnet32 solution

Oh yes - that was easy: just add 0x8800 address to pcnet32.c in kernel. It works both with 2.2 kernels and 2.4.latest, at least.
So currenty my Compaq Prosignia VS runs Slackware 7 with 2.4.latest kernel with all devices (except it sees only 16M of 40M of RAM)
Generally it was a bad idea to start with Slackware 7; looks like I could start with Slackware 11, but! - it is unable to start the installation with initrd - looks like it cannot fit my [or original] kernel and initrd in memory (as I said, 16M of 40M). I've tried different memmap='s , but still it does not helps. UPD: append="sim710=addr:0x8000,irq:14 mem=exactmap mem=640k@0 mem=15M@1M mem=20M@16M mem=nopentium acpi=off debug noisapnp" - with this setting in lilo.conf 2.4.37 sees all my 36M of memory! UPD: looks like that's not pcnet32.c , but lance.c should be edited.

Monday, October 6, 2014

ppp over ssh

Just as reminder to myself, here is an easy ppp over ssh solution with openbsd as server and linux as client.
Openbsd server:
  • Allow IP forwarding for nat: sysctl net.inet.ip.forwarding=1
  • Configure NAT in /etc/pf.conf:
    
    ext_if="xl0"
    int_if="ppp0"
    ext_ip="*.*.*.*" # your's external IP
    int_net="10.0.0.1/24"
    match out on {$ext_if} from {$int_net} to any nat-to {$ext_ip} 
    pass out on {$ext_if} from {$int_net} to any
    
    
  • Create a user ppp, configure linux client and openbsd's server user ppp, [optionally, but highly recommended] set ssh key auth, check that ssh ppp@server linux client reaches openbsd's shell. Add ppp user to /etc/ftpusers. Disable password auth for that user.
  • Create /usr/local/bin/ppplogin and make it executable for user ppp:
    
    #!/bin/sh
    TTY=`tty`
    /usr/sbin/pppd $TTY nodetach proxyarp ms-dns server.dns.IP.addr 10.0.0.1:
    exit
    
    
    [UPD: no need for proxyarp, probably] In /etc/ppp/chap-secrets create an ppp auth entry:
    
    clientusername * clientpassword 10.0.0.12
    
    
  • Add /usr/local/bin/ppplogin to /etc/shells. Also check if you have ppp0 interface; you may need to run ifconfig ppp0 create (and several ppp interfaces if you need it)
  • On linux client side, create callppp script:
    
    pppd debug nodetach defaultroute usepeerdns name clientusername passive pty  \
        "ssh ppp@openbsd.serv.er -o Batchmode=yes"
    
    
    Strange thing, if we say defaultroute - it does not help us to set the default route over the ppp link; we have to do that manually (in ip-up and ip-down scripts)
  • An auth entry in /etc/ppp/chap-secrets:
    clientusername * clientpassword
  • In /etc/ppp/ip-up:
    
    /sbin/route add -host openbsd.serv.er gw yours.ethernet.default.gw
    /sbin/route del default 
    /sbin/route add default gw $5 
    
    
    (also, here you can keed those routes that should not pass via ppp interface)
  • And in /etc/ppp/ip-down we should restore everything back:
    
    /sbin/route del default
    /sbin/route del -host openbsd.serv.er
    /sbin/route add default gw yours.ethernet.default.gw
    
    

Do not forget to run traceroute and check how are you connected to the internet now.
And the last advice: do not listen to my advices [because I do not undestand anything in the things I write, at least for now, even handcrafted that all myself], read all the docs and do it the right way (mostly be aware of some security holes in this installation - but only in OpenBSD NAT rules, I believe).

Sunday, October 5, 2014

Compaq Prosignia 486 VS

For years, I owned Compaq Prosignia VS motherboard and now it is old enough to turn it on.
And, well, it is one of the most tricky 486 computer I've ever touched.
This is the first part of story.

First, yes, it can be run from an AT PSU, but WARNING! - it must not be plugged as in normal PC AT PSU, but with a specific shift. Better read the docs, if you fail - you'll burn it (maybe I'll post photo later). [UPD: see it here (Let me explain: looking from CPU side: left, 5 pin socket: Black HANGING in air covering no pins, next Black, Blue, Light Yellow, Red, Dark Yellow; right: Red Red Red White Black Black Unconnected pin)]
Next, a SCSI drive. I use IBM 4G 68pin drive via SCSI converter.
And a floppy.

As you know, old Compaqs has a system partition instead of BIOS setup program. You have to download Compaq System Configuration Utility and to install it first.
Can you avoid it? Looks like yes. But if you want to see your's SCSI controller settings itself, install it.

Then I've installed FreeDOS from a floppy and tried to find PCNET packet driver. And failed! Because the onboard PCNET32 is EISA. It means it behaves mostly as ISA one, but 32 bit wide and on io 0x8800.
Ok, let's install an old linux - sure, that to be Slackware, saying, 7.1. I've downloaded (via Null Modem and conex.exe (c) 98 Erhard Hilbig -nice small and simple DOS terminal with Zmodem) n_53c7xx.s and color.gz - and it could not find SCSI controller. I boot it via loadlin,exe, btw.
It needs to know the IO and IRQ of SCSI contoller, that is done by
loadlin bzImage root=/dev/ram rw initrd=c:\linux\color.gz sim710=addr:0x8000,irq:14
Guess what? It refuses to see both pcnet32 and lance network! (and it sees only 16M of my 40M of RAM)
[end of first part]