New project: An ACT Apricot F1 "barn find"
- mrbombermillzy
- Posts: 1468
- Joined: Sun Jun 03, 2018 7:37 pm
Re: New project: An ACT Apricot F1 "barn find"
I believe:
mov $0000,DS
mov $0406,DX
mov 2,DS:DX
should do it (depending on the Intel standard register conventions of the assembler/compiler you are using).
Thank god you didn't ask me to convert the linear address to the segmented form! lol
Let me know if this works (or not) and I can tweak it accordingly.
mov $0000,DS
mov $0406,DX
mov 2,DS:DX
should do it (depending on the Intel standard register conventions of the assembler/compiler you are using).
Thank god you didn't ask me to convert the linear address to the segmented form! lol
Let me know if this works (or not) and I can tweak it accordingly.
- stephen_usher
- Posts: 5668
- Joined: Mon Nov 13, 2017 7:19 pm
- Location: Oxford, UK.
- Contact:
Re: New project: An ACT Apricot F1 "barn find"
Thanks. I'll see if I can get bcc (Bruce's C Compiler) to work under Linux and then see if it will accept that assembly!
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
- mrbombermillzy
- Posts: 1468
- Joined: Sun Jun 03, 2018 7:37 pm
Re: New project: An ACT Apricot F1 "barn find"
That compiler looks quite quirky!
It looks like you can set a preprocessor directive of: __AS386_16__ 1 then use the #asm keyword to include assembly.
It looks like you can set a preprocessor directive of: __AS386_16__ 1 then use the #asm keyword to include assembly.
- stephen_usher
- Posts: 5668
- Joined: Mon Nov 13, 2017 7:19 pm
- Location: Oxford, UK.
- Contact:
Re: New project: An ACT Apricot F1 "barn find"
Actually, I think this will do it. As you can only access 16 bit values I have to read the original, modify the first byte and then wrote the value back, I think.
Code: Select all
#include <stdio.h>
main()
{
printf("Apricot second floppy registration program.\n");
change_sysvar();
}
change_sysvar()
{
#asm
mov ax,$0000
mov ds,ax
mov bx,$0416
mov cx,[bx]
mov cl,2
mov [bx],cx
#endasm
}
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
- stephen_usher
- Posts: 5668
- Joined: Mon Nov 13, 2017 7:19 pm
- Location: Oxford, UK.
- Contact:
Re: New project: An ACT Apricot F1 "barn find"
Nope. Doesn't work.
Next I tried:
And that doesn't work either.
Next I tried:
Code: Select all
#include <stdio.h>
main()
{
printf("Apricot second floppy registration program.\n");
change_sysvar();
}
change_sysvar()
{
#asm
mov ax,$0000
mov ds,ax
mov bx,$0416
mov cl,2
mov byte ptr [bx],cl
#endasm
}
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
- mrbombermillzy
- Posts: 1468
- Joined: Sun Jun 03, 2018 7:37 pm
Re: New project: An ACT Apricot F1 "barn find"
Ok, so my version doesnt work either, I guess.
I realised the operands are the wrong way (too used to 68xxx asm!) but I suppose you tried them the proper way round.
Ok, so if you put them through a disassembler, you should be able to do it from a process of elimination
If you dont have a disassembler, you may like using the godbolt online one: https://godbolt.org/
I'm like totally busy with loads of kids to look after ATM, but I can get to the bottom of it with you at some point, if you are still stuck after the above!
I realised the operands are the wrong way (too used to 68xxx asm!) but I suppose you tried them the proper way round.
Ok, so if you put them through a disassembler, you should be able to do it from a process of elimination
If you dont have a disassembler, you may like using the godbolt online one: https://godbolt.org/
I'm like totally busy with loads of kids to look after ATM, but I can get to the bottom of it with you at some point, if you are still stuck after the above!
- mrbombermillzy
- Posts: 1468
- Joined: Sun Jun 03, 2018 7:37 pm
- stephen_usher
- Posts: 5668
- Joined: Mon Nov 13, 2017 7:19 pm
- Location: Oxford, UK.
- Contact:
Re: New project: An ACT Apricot F1 "barn find"
OK, got there. A lot of the problem was due to as86 using non-standard syntax.
Unlike all other 8086 assemblers it doesn't see a naked number as a literal value, instead it treats it as a pointer, e.g. '2' would be interpreted as '[2]'. To tell the assembler that it's a literal value you have to prepend a '*'.
Anyway, the code now works and is very much simplified:
The 'xor ax,ax' is a standard optimisation as it takes a lot fewer bytes than 'mov ax,0'
Something to note is the strange way that addressing works. As mentioned before the memory is logically segmented so to address a memory address you need to know the segment and the address. But it gets more complicated as the program may not have the whole segment to itself, so you have a second register, other than the DS (Data Segment) one, the DI, or Data Index register which provides the offset from the beginning of the segment where the program's data starts. There are a corresponding two registers for the code address so that the program and its data can live in separate segments, potentially allowing a 64K program with 64K of data memory.
This seems very strange if you come from the flat memory model that the 68000 has.
Unlike all other 8086 assemblers it doesn't see a naked number as a literal value, instead it treats it as a pointer, e.g. '2' would be interpreted as '[2]'. To tell the assembler that it's a literal value you have to prepend a '*'.
Anyway, the code now works and is very much simplified:
Code: Select all
#include <stdio.h>
main()
{
printf("Apricot second floppy registration program.\n");
change_sysvar();
}
change_sysvar()
{
#asm
push ax
push ds
push di
xor ax,ax
mov ds,ax
mov di,ax
mov byte ptr [0x0416],*0x2
pop di
pop ds
pop ax
#endasm
}
Something to note is the strange way that addressing works. As mentioned before the memory is logically segmented so to address a memory address you need to know the segment and the address. But it gets more complicated as the program may not have the whole segment to itself, so you have a second register, other than the DS (Data Segment) one, the DI, or Data Index register which provides the offset from the beginning of the segment where the program's data starts. There are a corresponding two registers for the code address so that the program and its data can live in separate segments, potentially allowing a 64K program with 64K of data memory.
This seems very strange if you come from the flat memory model that the 68000 has.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
- stephen_usher
- Posts: 5668
- Joined: Mon Nov 13, 2017 7:19 pm
- Location: Oxford, UK.
- Contact:
Re: New project: An ACT Apricot F1 "barn find"
Is anyone any good at Arduino Sketch programming?
If so, could someone check the sanity of this code for the ATTiny85.
Pin assignments are:
Anyway, here's the code:
If so, could someone check the sanity of this code for the ATTiny85.
Pin assignments are:
- PB0 - jumper to set the mode of the floppies to be DSKCHG (0) or /READY (1)
- PB1 - STEP output pin going to an OR gate so that either the disk controller or the ATTiny85 can enable the drive step signal
- PB2 - Output to the disk controller READY pin, high = drive is ready (disk in drive)
- PB3 - Input from the floppy drive, READY signal if in READY mode or /DSKCHG if not.
- PB4 - Drive selected, high if drive 0 and low if drive 1. Initially an output for the first 10 seconds and then an input.
Anyway, here's the code:
Code: Select all
#define DRVSELPIN 4
#define DRVRDYPIN 3
#define CTRLRDYPIN 2
#define RESETSTEPPIN 1
#define DSKCHGPIN 0
int dskchg;
void send_step() {
digitalWrite(RESETSTEPPIN, HIGH);
delay(1);
digitalWrite(RESETSTEPPIN, LOW);
}
void setup() {
// Set up the initial pin I/O states.
pinMode(DRVSELPIN, OUTPUT);
pinMode(DRVRDYPIN, INPUT);
pinMode(CTRLRDYPIN, OUTPUT);
pinMode(RESETSTEPPIN, OUTPUT);
pinMode(DSKCHGPIN, INPUT);
// Check to see if we are jumpered to be in DSKCHG mode or READY mode
dskchg = 1 - digitalRead(DSKCHGPIN);
// For the time being disable our STEP pin output.
digitalWrite(RESETSTEPPIN, LOW);
// Initially pull Drive 1 select line low to enable the drive. After 10 seconds we will release it and make it an input.
digitalWrite(DRVSELPIN, LOW);
delay(10000);
pinMode(DRVSELPIN, INPUT);
}
void loop() {
static int ready_status[2] = { 1, 1};
static int step_sent[2] = {0, 0};
int drive, rdyval;
// Echo the input from the READY line from the floppy drive to the controller READY line.
while(1)
{
drive = 1 - digitalRead(DRVSELPIN);
rdyval = digitalRead(DRVRDYPIN);
if (dskchg != 0)
{
digitalWrite(CTRLRDYPIN, rdyval);
}
else
{
if (rdyval == 1)
{
if (step_sent[drive] == 0)
{
send_step();
step_sent[drive] = 1;
}
ready_status[drive] = 0;
}
else
{
ready_status[drive] = 1;
step_sent[drive] = 0;
}
digitalWrite(CTRLRDYPIN, ready_status[drive]);
}
}
}
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
- stephen_usher
- Posts: 5668
- Joined: Mon Nov 13, 2017 7:19 pm
- Location: Oxford, UK.
- Contact:
Re: New project: An ACT Apricot F1 "barn find"
I'm back from my hols and on with the project.
After a bit of tweaking the basic version of the ATTiny85 code works. The delay() function seems to delay for 10 times as long as I expected and input pins don't go tri-state unless you "write" a HIGH value to them after setting them as inputs. I had to extend the time for the seek process up to 14 seconds from my initial guess of 10 seconds.
The FDC seek at start up doesn't always get the second floppy to track zero for the ROM drive detection to work but it usually does, which is an advance.
After a bit of tweaking the basic version of the ATTiny85 code works. The delay() function seems to delay for 10 times as long as I expected and input pins don't go tri-state unless you "write" a HIGH value to them after setting them as inputs. I had to extend the time for the seek process up to 14 seconds from my initial guess of 10 seconds.
The FDC seek at start up doesn't always get the second floppy to track zero for the ROM drive detection to work but it usually does, which is an advance.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.