• Please review our updated Terms and Rules here

LD instruction not assembled CP/M 2.2

rwcooper

Member
Joined
Jan 17, 2023
Messages
23
Hi I have a simple program named leds.asm as shown below:
ORG 0100h
LD A,3
OUT (0),A
RET
END
When I do ASM LEDS it does not assemble the LD A,3 instruction. leds.prn contains:
0100 ORG 0100h
S LD A,3
S0100 D300 OUT (0),A
0102 C9 RET
0103 END
When I dump leds.hex I get:
0000 3A 30 33 30 31 30 30 30 30 44 33 30 30 43 39 36
0010 30 0D 0A 3A 30 30 30 30 30 30 30 30 30 30 0D 0A
0020 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A
There is only 3 bytes of object code, but there should be 5. The 2 bytes for the LD A,3 instruction are missing. Needless to say if I do LOAD LEDS and then run the program it does no work. I'm very new to ASM on CP/M. If I use z80asm under linux the program compiles correctly. I'd really appreciate it if someone would tell me what I am doing wrong. Thanks,
 
Are you sure you are not using an 8080 assembler which would not support LD A, 3?
I have no idea. It's the assembler that came with the copy of CP/M that was recommended for the SC720 Z80 computer kit. Is there some way I can check this (or maybe I already have)?
 
The Digital Research ASM does only emit 8080 machine language. What copyright information, if any, does the assembler emit when run?

Try changing the LD A,3 to MVI A, 3. I think that would be the 8080 equivalent. It has been a long time since I did any 8080 work so trust a manual over me.
 
Well, the S error code means syntax error, so that line has been ignored for some reason. I am not an expert on CP/M nor its assembler.
 
The Digital Research ASM does only emit 8080 machine language. What copyright information, if any, does the assembler emit when run?

Try changing the LD A,3 to MVI A, 3. I think that would be the 8080 equivalent. It has been a long time since I did any 8080 work so trust a manual over me.
Thanks for the suggestion. That will be my next step.
 
Well, the S error code means syntax error, so that line has been ignored for some reason. I am not an expert on CP/M nor its assembler.
Thanks for the info. I didn't know that the S was an error message. I guess I need to find a Z80 assembler for CP/M 2.2.
 
(MicroSoft) M80 will accept Zilog mnemonics (when z80 mode selected). You should be able to find the manuals out there, too. You will also need L80 into order to link into a COM file. Not as easy to use as DRI tools in that respect, but if you must use Zilog mnemonics then probably the way to go.
 
CP/M was designed to run on an 8080 CPU. It will also run on most processors that are 8080 object code compatible (including the Z80).

However, the supplied tools (especially the assembler) would only assemble Intel 8080 mnemonics.

As stated previously, if you want to develop source code using Zilog Z80 mnemonics, use the Microsoft M80/L80 tools.

Dave
 
ZSM.COM is a very easy to use Z80 assembler from back-in-the-day, which directly creates an Intel Hex file without the need for a linker.
Its there for download from my "CP/M Files" page on http://philg.uk
You may have to do right click, save as, and 'Keep' because I dont have an SSL cert.
Read page 1 of the txt file, thats all you need: Name your source "myprog.ZSM" and assemble it using ZSM myprog.PQR where P is the drive containing the source file, Q is the drive where you'd like the Hex file, and R is the drive where you want the PRN file. If you want everything on the current drive, just use ZSM myprog.@@@ as the @ character means 'default'. I mostly use .@@@ as its easier.
M80 is more flexible & hence more complex, more to think about. Below is a simple M80 demo I did:
Another option is Richard Russell's BBC Basic, which has an inline Z80 assembler.
By the way, dont 'dump' hex files, they are ascii text, so you can 'type' them :)
Cheers
Phil_G


Here's a quick ZSM demo I did for Roland:

 
Last edited:
There are "swings and roundabouts" depending upon the tools.

M80 is a macro assembler and you can assemble separate modules and link them together using L80 (along with pulling in library code).

If you want to write a simple test program (or a debug monitor) then a simple, single file is probably all that is required and you just want a fast edit, assemble, test cycle.

If you are doing more complex software development (although I would ask why these days of course) then M80/L80 is a brilliant tool.

Dave
 
ZSM.COM is a very easy to use Z80 assembler from back-in-the-day, which directly creates an Intel Hex file without the need for a linker.
Its there for download from my "CP/M Files" page on http://philg.uk
You may have to do right click, save as, and 'Keep' because I dont have an SSL cert.
Read page 1 of the txt file, thats all you need: Name your source "myprog.ZSM" and assemble it using ZSM myprog.PQR where P is the drive containing the source file, Q is the drive where you'd like the Hex file, and R is the drive where you want the PRN file. If you want everything on the current drive, just use ZSM myprog.@@@ as the @ character means 'default'. I mostly use .@@@ as its easier.
M80 is more flexible & hence more complex, more to think about. Below is a simple M80 demo I did:
Another option is Richard Russell's BBC Basic, which has an inline Z80 assembler.
By the way, dont 'dump' hex files, they are ascii text, so you can 'type' them :)
Cheers
Phil_G


Here's a quick ZSM demo I did for Roland:

Thanks for your response. I have loaded ZSM onto my SC720 ZSDOS system and used it to assemble a simple program. Worked like a charm.
 
Back
Top