Access low and high label bytes in Z80 assembler?

103 views
Skip to first unread message

Kande Laber

unread,
Jun 8, 2025, 3:59:16 AM6/8/25
to retro-comp
Hello,

This code works:

--------------------------
0000 ORG 01234H
1234 00 ABC: NOP
1235 21 34 12 LD HL,ABC
1238 7c LD A,H
1239 45 LD B,L  
---------------------------

But how could I assign the   low and high label bytes to 'A' and 'B' without using 'HL'?

Best regards

Steve Cousins

unread,
Jun 8, 2025, 5:28:10 AM6/8/25
to retro-comp
The assembler will probably have suitable directives, such as "lo" or "low" and "hi" or "high"
eg.   LD  A, LO(ABC)

ladislau szilagyi

unread,
Jun 8, 2025, 8:33:08 AM6/8/25
to retro-comp
Hi,

most assemblers have such operators...

E.g. in HighTech's ZAS:

LD A, .high. ABC
LD B, .low. ABC

Ladislau

Kande Laber

unread,
Jun 8, 2025, 9:08:14 AM6/8/25
to retro-comp
Thank you.

I am using the following on my Linux box

$ z80asm -V
Z80 assembler version 1.8
Copyright (C) 2002-2007 Bas Wijnen <she...@fmf.nl>.
Copyright (C) 2005 Jan Wilmans <j...@dds.nl>.

Generally I am quite happy with it, because it is a standard tool in my Linux distribution and it normally does the job.
Unfortunately, I have not found functions such as "LO()".

The next best thing, I found.

1234 00 ABC: NOP
1235 3a 12 00 LD A,(ABC>>8)  
1238 47         LD B,A
1239 3a 34 00 LD A,(ABC&000FFH) 

It works, but it is not clean code, adding NOPs.

ladislau szilagyi

unread,
Jun 8, 2025, 11:16:31 AM6/8/25
to retro-comp
You may try Z80AS. It has these operators... and more.


There is also an extensive manual.
It is 100% compatible with HiTech's ZAS, but has more extras...

Just download Z80AS.HEX, move-it to your Linux box, then, under CP/M:
>load z80as

...and you have your Z80AS.COM ready.

Ladislau



Kande Laber

unread,
Jun 9, 2025, 7:31:46 AM6/9/25
to retro-comp
Thank you for all your good advices!
In the end I decided to stick with the "HL" approach.
It is more portable. Generally I found that assembler directives tend to be not very standardized.
This time I actually cross-assemble on my Linux-Intel-Processor-Box.
The target is an old Microprofessor IP and there I have to setup the CTC in interrupt mode etc.

BTW: When I do stuff on my CP/M-Box (based on Steve Cousins kits) am I am quite happy the the Z80 assembler from SLR systems.

Reply all
Reply to author
Forward
0 new messages