Author Topic: Problem with CP/M 2.2 on 6128  (Read 2286 times)

0 Members and 1 Guest are viewing this topic.

Offline JonB

  • 6128 Plus
  • ******
  • Posts: 745
  • Country: gb
  • Liked: 203
  • Likes Given: 47
Problem with CP/M 2.2 on 6128
« on: 12:28, 07 March 17 »
Hi

I need to locate the DIRBUFF on CP/M 2.2. This is located in the DPH and to locate that you normally start DDT, set C to zero, and call SELDSK. To locate SELDSK's address, look at the JMP address at address 0000 and round it down to the nearest page (replace last 2 hex numbers with 00), this gives the start of the BIOS jump table. Now add 1B, this gives the JMP to SELDSK.

So far so good. I have the address C2F2h for SELDSK in the 6128 under CPM 2.2.

The problem comes when I try to step into it in DDT.

Code: [Select]
A>ddt
DDT VERS 2.2
-xp
P=0100 C2F2
-t
C0Z0M0E0I0 A=00 B=0000 D=0000 H=0000 S=0100 P=C2F2 CALL AD33*AD33
-t

At this point the 6128 crashes.

This procedure works on any normal CP/M 2.2 implementation, but seemingly not on the 6128.

Could someone try it on their machine, please, or suggest why it isn't working?

Thanks
JonB
« Last Edit: 12:30, 07 March 17 by JonB »

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.332
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2247
  • Likes Given: 3477
Re: Problem with CP/M 2.2 on 6128
« Reply #1 on: 15:37, 07 March 17 »
Hi Jon,

AD33 is "ENTER FIRMWARE" a special trampoline function to call into the firmware from CPM. It's the CALL at C2F2.

The form is:

Code: [Select]
C2F2:
CALL &AD33
defw &c4f0

In addition C2F2 is the ROM version of SELDSK. See http://www.cpctech.org.uk/docs/amdos.asm

I have commented some of the rom.

Following it back up the chain it is called via AD1B. The main block is AD00.

These are the original calls from the amsdos rom (copied to AD00):

Code: [Select]
c17f c3b2c1    jp      $c1b2            ;; boot
c182 c3bec2    jp      $c2be            ;; wboot
c185 c3e1c2    jp      $c2e1            ;; const
c188 c3c3c2    jp      $c2c3            ;; conin
c18b c3c8c2    jp      $c2c8            ;; conout
c18e c3d2c2    jp      $c2d2            ;; list
c191 c3d7c2    jp      $c2d7            ;; punch
c194 c3dcc2    jp      $c2dc            ;; reader
c197 c3e9c2    jp      $c2e9            ;; home
c19a c3f2c2    jp      $c2f2            ;; seldsk
c19d c324c5    jp      $c524            ;; settrk
c1a0 c329c5    jp      $c529            ;; setsec
c1a3 c31ac5    jp      $c51a            ;; setdma
c1a6 c3f7c2    jp      $c2f7            ;; read
c1a9 c3fcc2    jp      $c2fc            ;; write
c1ac c3cdc2    jp      $c2cd            ;; lstst
c1af c35ac5    jp      $c55a            ;; sectran

At 0000:

Code: [Select]
JP &AD03

So as you say, look at the JMP at 0000 and round down. This gives you the ram based start of the BIOS jump block. Add 1B, this is the ram based JMP to SELDSK.

You can patch this easily.

With DDT can you step over the JP so it does the whole lot?

EDIT: Yes seldsk returns the DPH.

If you need to check:
AE78 is the buffer you need
DPB is at ADD8
« Last Edit: 15:47, 07 March 17 by arnoldemu »
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline JonB

  • 6128 Plus
  • ******
  • Posts: 745
  • Country: gb
  • Liked: 203
  • Likes Given: 47
Re: Problem with CP/M 2.2 on 6128
« Reply #2 on: 16:17, 07 March 17 »
OK @arnoldemu, I will try these values.


The other question is about the 2.2 BIOS. It seems rather low in memory at AD00h. When I did MOVCPM it tried to create a 48k CP/M system, is that the default? I'd have to move this down to 43k to get the full drive access, which I think is a bit low...


How big is the CP/M 2.2 TPA? Must be titchy - and what is the upper RAM all getting used for, if the BIOS is actually in ROM? What does the CP/M 2.2 memory map really look like?


A quick look at one of your disassemblies (AMSDOS.COM for 2.2) shows some memory paging going on. This doesn't happen in 6128 CP/M 2.2 normally, I hope!
« Last Edit: 16:20, 07 March 17 by JonB »

Offline JonB

  • 6128 Plus
  • ******
  • Posts: 745
  • Country: gb
  • Liked: 203
  • Likes Given: 47
Re: Problem with CP/M 2.2 on 6128
« Reply #3 on: 18:40, 07 March 17 »
Just trying to allocate some space for the uIDE-16 driver, and it seems MOVCPM.COM doesn't like any memory sizes I have tried. It simply reports "INVALID MEMORY SIZE".


If you do MOVCPM * * it will work, constructing a 48k system, which according to the DRI manual means "the current configuration", which in turn means the 6128 CP/M 2.2 is a 48k system. That's very mean on a 128k machine. You'd think they would at least give you the full 64k!


Moreover, unless I am mistaken, Amstrad / Locomotive didn't want anyone moving their CP/M about, because they appear to have written MOVCPM.COM so that it won't actually do anything other than reproduce the current system.


Under these circumstances I do not think I can port my CP/M 2.2 driver to it, but before I give up, could someone try the following:
  • MOVCPM 48 *
  • MOVCPM 46 *
  • MOVCPM 44 *
  • MOVCPM 42 *
  • MOVCPM 40 *
..and report on the result, please? Maybe my disk image is corrupt and MOVCPM.COM is bad.

[edit: I tried 4 different disk images - English, Spanish, German and French, but they all do the same.]

Thanks
JonB
« Last Edit: 19:21, 07 March 17 by JonB »

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.332
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2247
  • Likes Given: 3477
Re: Problem with CP/M 2.2 on 6128
« Reply #4 on: 21:04, 07 March 17 »
OK @arnoldemu, I will try these values.


The other question is about the 2.2 BIOS. It seems rather low in memory at AD00h. When I did MOVCPM it tried to create a 48k CP/M system, is that the default? I'd have to move this down to 43k to get the full drive access, which I think is a bit low...


How big is the CP/M 2.2 TPA? Must be titchy - and what is the upper RAM all getting used for, if the BIOS is actually in ROM? What does the CP/M 2.2 memory map really look like?


A quick look at one of your disassemblies (AMSDOS.COM for 2.2) shows some memory paging going on. This doesn't happen in 6128 CP/M 2.2 normally, I hope!
TPA is about 41K for 2.2.

Memory map looks a bit like this:

0000- approx 0040: used for cpm and other firmware jumps
9700-b400 CPM - says "copyright digital research" Possibly BIOS. I don't really know.
b400-bb00 some firmware variables
bb00-~be00 firmware jumpblock
be00-bf00  normally stack not sure for cpm
c000-fffff screen

TPA appears to be &0040->&9700.

It's a CPM for a 64KB system, it doesn't change on 6128.

CPM uses 2nd bank of 64KB for TPA so has a TPA of about 63KB I think. Main ram bank is used for cpm bios etc.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.332
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2247
  • Likes Given: 3477
Re: Problem with CP/M 2.2 on 6128
« Reply #5 on: 21:10, 07 March 17 »
MOVCPM seems to be the original digital research code, but it is more likely that Amstrad's CPM doesn't return the appropiate values to define the TPA limits?

Question: Is there a guide for building a version of CPM? It would be nice if one day I could work out how to re-create all of CPC's CPM from build files I made.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline JonB

  • 6128 Plus
  • ******
  • Posts: 745
  • Country: gb
  • Liked: 203
  • Likes Given: 47
Re: Problem with CP/M 2.2 on 6128
« Reply #6 on: 21:46, 07 March 17 »
The bit that says copyright DR! Is either the BDOS or CCP.


The memory map looks weird. Most CP/M 2.2 systems are simpler. Syestem variables etc to 100h, TPA, BDOS, BIOS, simple. The BIOS is at the top of memory, so when you MOVCPM in a normal system, you allocate space above it for your code.


Unless we can work out how to allocate 2-5k of memory that the BIOS can access, this driver's not going to happen. That is the only thing stopping me now.


If you want to see a set of commented CP/M source (from a disassembly, converted to Z80 mnemonics), check out the CP/M download section of Grant Searle's web site here : http://searle.hostei.com/grant/Multicomp/cpm/fpgaCPM.html


I've built the whole thing from the source in that zip file, and run it on my Multicomp.


Cheers
JonB
« Last Edit: 21:48, 07 March 17 by JonB »

Offline FloppySoftware

  • CPC6128
  • ****
  • Posts: 243
  • Country: es
  • The best team: Amstrad PCW, CP/M, and the Z80 cpu.
    • Floppy Software
  • Liked: 234
  • Likes Given: 171
Re: Problem with CP/M 2.2 on 6128
« Reply #7 on: 23:41, 07 March 17 »
DDT fakes some CP/M addresses in the zero page because it reloads itself in the upper memory.


I think you can't use MOVCPM to construct another version of Amstrad CP/M 2.2.


In CP/M 3 you could use CP/M RSXs (not the Amsdos ones) to add new functionalities or patches to the BDOS or BIOS, but in CP/M 2 is trickiest because it does not have (official) support for RSXs.





floppysoftware.es < NEW URL!!!
cpm-connections.blogspot.com.es

Offline JonB

  • 6128 Plus
  • ******
  • Posts: 745
  • Country: gb
  • Liked: 203
  • Likes Given: 47
Re: Problem with CP/M 2.2 on 6128
« Reply #8 on: 09:19, 08 March 17 »

I think you can't use MOVCPM to construct another version of Amstrad CP/M 2.2.


Makes me wonder why they bothered including it!


Quote
In CP/M 3 you could use CP/M RSXs (not the Amsdos ones) to add new functionalities or patches to the BDOS or BIOS, but in CP/M 2 is trickiest because it does not have (official) support for RSXs.


I thought there was no true RSX support in Plus because I could not see a GENCPM compile or CPM.SYS. But I was looking on the wrong disk, and I found out that the CPM.SYS is contained within the EMT boot file. So, if I can find out how to make an EMT I can switch back to Plus. Hopefully that book will help..

Offline rpalmer

  • 6128 Plus
  • ******
  • Posts: 548
  • Country: au
  • Liked: 362
  • Likes Given: 18
Re: Problem with CP/M 2.2 on 6128
« Reply #9 on: 12:41, 08 March 17 »
The MOVCPM command does allow to re-allocate the upper max memory of CP/M 2.2. With this you can create a pseudo-RSX area.

rpalmer

Offline JonB

  • 6128 Plus
  • ******
  • Posts: 745
  • Country: gb
  • Liked: 203
  • Likes Given: 47
Re: Problem with CP/M 2.2 on 6128
« Reply #10 on: 14:43, 08 March 17 »
@rpalmer : Not on the CPC6128 it doesn't, seemingly, unless you have some working example other than "MOVCPM * *"?

Offline JonB

  • 6128 Plus
  • ******
  • Posts: 745
  • Country: gb
  • Liked: 203
  • Likes Given: 47
Re: Problem with CP/M 2.2 on 6128
« Reply #11 on: 12:55, 16 March 17 »
This might help, though..


 [ Invalid Attachment ]


 ;D

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.332
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2247
  • Likes Given: 3477
Re: Problem with CP/M 2.2 on 6128
« Reply #12 on: 21:53, 05 May 18 »
I've documented the Amstrad CPM2.2 boot procedure. It peeks at the JP at the start of CPM to indicate where to load to.

Then I realised the important bit about MOVCPM is in the DDI-1 firmware manual (SOFT158A).
I don't know why it's not replicated in the SOFT968 manual.

Anyone have a PDF of it? If not I'll have to scan and re-type mine.


"Using MOVCPM.COM

In order to insert an RSX into store it is necessary to move CP/M system down store. The CP/M utility MOVCPM.COM will create an in-store image of CP/M system of the required size. The utility SYSGEN.COM is then used to write this image to disc, see section 4.11

The MOVCPM utility requires the size of CP/M to be specified. Historically this size meant the total amount of RAM available to the original CP/M system with BIOS size of 1.5K. Nowadays it is merely a magic number to feed MOVCPM with! The MOVCPM utility supplied requires this size to be expressed in pages (1 page = 256 bytes). it is calculated as follows.

Let scpm be the size of cpm in pages required by the MOVCPM utility.
Let srsx be the size in pages of the rsx required.

Then Scpm = 179 - srsx
The BDOS will start at address bstart=(scpm-20)*256
The BDOS entry point will be at address bentry = bstart + 6
The TPA size = Bentry-#100
To run MOVCPM type
MOVCPM nnn *
where nnn is the size required and must be in the range 64-179.
The asterix must be present and separated from the size by a space.
The system supplied has been created from
MOVCPM 179 *"

It says:

SYSGEN *
SYSGEN <filename>

* is from in memory following a MOVCPM <nnn> *.

SYSGEN <filename> is if SAVE 34 ... is used.

BOOTGEN copies boot and config sector.
SYSGEN copies CCP and BDOS
SYSGEN * saves CCP and BDOS from TPA image
SYSGEN <filename> writes CCP and BDOS from SAVEd file of TPA image.

RSXs etc go after the bios jumpblock (normally at &AD00-&ad33 and it does appear it would move it).

I'm not sure where it goes. I will need to find out because &ad33 is hard coded.

So that is how to adjust CPM2.2.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.332
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2247
  • Likes Given: 3477
Re: Problem with CP/M 2.2 on 6128
« Reply #13 on: 21:58, 05 May 18 »
MOVCPM 179 * says "CONSTRUCTING 44k CPM"
MOVCPM 160 * says "CONSTRUCTING 40k CPM".
etc

Now there seems to be 33KB TPA available by default in cpm2.2 because of upper range being &9700, so this size must include the CPM CCP/BDOS itself.

(Of course there are other CPM 2.2 available which have been patched for ram expansions which give 62KB or 63KB TPA. I'm not sure how those can be adapted).

Next step is to work out what CPM+ is doing, because it's not in the DDI-1 manual. Maybe it's similar to CPM 2.2 MOVCPM?

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline JonB

  • 6128 Plus
  • ******
  • Posts: 745
  • Country: gb
  • Liked: 203
  • Likes Given: 47
Re: Problem with CP/M 2.2 on 6128
« Reply #14 on: 13:42, 13 May 18 »
Sample RSX code. One of them implements a full BIOS jump table and I was thinking of using it as a guide. They are for "generic" CP/M Plus and I haven't tried them on the 6128.