CPCWiki forum

General Category => Programming => Topic started by: Neurox66 on 07:29, 03 June 23

Title: Mistake with registers
Post by: Neurox66 on 07:29, 03 June 23
Hello everyone, 
I use Pasmo as my compiler and I have a problem with the allocation between registers. 
If I write : 
ld bc, hl 
Pasmo returns an error because it expects a value instead of hl. 
Is there an alternative?
Thanks,
Paolo
Title: Re: Mistake with registers
Post by: trocoloco on 08:58, 03 June 23
Hi Paolo, "ld bc,hl" is not a z80 instruction. If you want to assign hl to bc, you can use the stack like this

push hl
pop bc

or this option which is faster for the same amount of bytes

ld b,h
ld c,l
Title: Re: Mistake with registers
Post by: Neurox66 on 16:11, 03 June 23
Hi,
How silly of me :doh:
Thanks for the tip, it obviously works great.

Paolo
Title: Re: Mistake with registers
Post by: andycadley on 18:20, 03 June 23
Easy mistake to make, especially because a lot of assemblers will accept pseudo opcodes like this.
Title: Re: Mistake with registers
Post by: asertus on 21:49, 03 June 23
I always use this table to be sure about "accepted" instructions..

https://clrhome.org/table/

Powered by SMFPacks Menu Editor Mod