News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_HAL6128

quick question regarding an OUT command

Started by HAL6128, 14:56, 19 April 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HAL6128

Is it correct that an OUT command on the CPC works different to other 8-Bit compuer with a Z80A processor? So it's not possible to use Block I/O transfers like the example below because an OUT command on the CPC is more a OUT(B),A than an regular OUT (C),A?

PORT EQU &FF10
LD B,100
LD A,0
.loop
OUT (PORT),A
DJNZ loop
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

keith56

#1
You are correct, B and C are used as the address on the Amstrad CPC, as it uses a 16 bit address bus for OUT commands... many devices on the CPC reply to whole ranges, so C often does not need to be set, but whatever the command says, eg OUT (&FF),A... B will be used as the top half of the port address.. making OTIR pretty unusable, and even OUTI problematic

It's not just the CPC, the Sam Coupe and ZX spectrum do it too, and it's actually in the Z80 documentation - I used to think it was just a CPC quirk, but it's not the case
Chibi Akumas: Comedy-Horror 8-bit Bullet Hell shooter!
Learn ARM, 8086, Z80, 6502 or 68000 with my tutorials: www.assemblytutorial.com
My Assembly programming book is available now on amazon!

gerald

Quote from: HAL 6128 on 14:56, 19 April 18
Is it correct that an OUT command on the CPC works different to other 8-Bit compuer with a Z80A processor? So it's not possible to use Block I/O transfers like the example below because an OUT command on the CPC is more a OUT(B),A than an regular OUT (C),A?

PORT EQU &FF10
LD B,100
LD A,0
.loop
OUT (PORT),A
DJNZ loop

The OUT works exactly as on other Z80 based system  :D
The difference is that amstrad decided to use the full 16bit address for IO instead of the more commonly used 8bit LSB mode.
And the OUTR/INR OUTI/INI only works with the 8bit LSB addressing mode.

andycadley

All Z80s put BC on the address bus when an OUT (C),x instruction occurs. The original intention of Zilog was that only the lower 8-bits would ever be considered significant, but this was widely ignored and so instructions, such as OTIR, designed around that principle are of very limited usage.

HAL6128

Ok, thank you.
I'm trying to convert a piece of code from a MSX to a CPC (example below).
So, first question is the MSX is doing this different?
Second question ist: I realized that some assembler (Maxam, WinApe or RASM) are truncating the constant PORT to &FF (MSB), so I have to load the PORT additionally with LD BC,PORT?
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

roudoudou

The OUT (im8),A is barely unusable with CPC for the reasons mentionned above. Anyway the instruction OUT (im16),A does not exists  :D

The INI, OUTI, IND, OUTD are used on a CPC but you have to put an INC B before each use to fix the pre-decrementation of this register.
My pronouns are RASM and ACE

keith56

It's very important too! My palette switching code was corrupting floppy disks at one point, because I was using OUTI, and not INC B!!!
Chibi Akumas: Comedy-Horror 8-bit Bullet Hell shooter!
Learn ARM, 8086, Z80, 6502 or 68000 with my tutorials: www.assemblytutorial.com
My Assembly programming book is available now on amazon!

GUNHED

Whatever values the MSX does sent to an port, it will be different on CPC side. The address is different and the data most likely too (except maybe the soundchip somewhat).

On CPC you usually do this:

LD BC,&XXXX
OUT (C),C

This will send the data (C) to the port (BC). In this case C doesn't matter in the port address. This works finde for CRTC, PIO, PSG.


For external hardware you can use:

LD BC,&XXXX
LD A,data
OUT (C),A

Sends data (A) to port (BC). This works for FDC and all other stuff.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Powered by SMFPacks Menu Editor Mod