• Please review our updated Terms and Rules here

CP/M assembly language programming

Mike_Z

Veteran Member
Joined
Dec 1, 2013
Messages
1,713
Location
Near Milwaukee Wisconsin
Well.. I have my 8080 machine working pretty well with CP/M 2.2. I want to learn how to use it better, especially the assembler. I understand assembly language pretty well, but don't know the format or directives of the CP/M assembler. I was looking for books on the internet and found one that I ordered by Ken Barbier, CP/M Assembly Language Programming. But didn't find any others that looked good. I'm not interested a basic level volume. Does anyone have any recommendations for paper book. I'm not much for reading on the computer. Mike
 
The ASM assembler is pretty basic and the thin reference manual for it that comes with CP/M is pretty much all one needs. It's a basic non-macro assembler after all. If you understand the machine language and syntax, I can't see why you'd need much more.

The later MAC and RMAC DRI assemblers have much thicker manuals.
 
I have bought several books from Amazon. Soul of CP/M, CP/M Bible, Mastering CP/M. The shipping to Europe was expensive though.
 
Well, sometimes a little help is all I need. From what I can tell, right now, is that CP/M is kinda similar to the assembler I'm using now. ORG is the same as *, DB and DW are the same, the fields are similar (there is a new one called DS), except my assembler requires the operands to be on the next line instead of inline. There are items called EQU and SET which are new. Labels can be longer, the error messages are different. I don't mind spending a little for some help. Arch, I'll look into the ones you have suggested. Chuck, I have the Command Summary you mentioned. It will be handy, but sometimes it is good to see examples etal. One other question, and I think I have the answer, Can I write the assembly language in Word and then save it as a text file then copy to my disks and assemble that instead of using ED.COM? Thanks Mike
 
Printed copies of David Cortesi's books are available at Amazon though since they are also available online (by the author) I would suggest glancing at the online edition before spending money. You may not like them as much as I did.
 
Well, sometimes a little help is all I need. From what I can tell, right now, is that CP/M is kinda similar to the assembler I'm using now. ORG is the same as *, DB and DW are the same, the fields are similar (there is a new one called DS), except my assembler requires the operands to be on the next line instead of inline. There are items called EQU and SET which are new. Labels can be longer, the error messages are different. I don't mind spending a little for some help. Arch, I'll look into the ones you have suggested. Chuck, I have the Command Summary you mentioned. It will be handy, but sometimes it is good to see examples etal. One other question, and I think I have the answer, Can I write the assembly language in Word and then save it as a text file then copy to my disks and assemble that instead of using ED.COM? Thanks Mike

Yes, you can do that--you can even assemble the stuff under an emulator and transfer the object files.

EQU and SET serve similar purposes--the first permanently assigns a value to a symbol; the second permits re-assignment of a value to a symbol. That's pretty much it--so for instance, you can assemble:

Code:
SYM1    SET     5
...
SYM1    SET    SYM1+1
With the result that SYM1 will have the value 6. Doing the same thing with EQU will result in an assembly error.

DS is like BSS in other assemblers--it reserves storage, but does not specify an initialization value. This is an important distinction when you have a system loader that allows for address specification, but CP/M loads memory images for execution, so the distinction is somewhat artificial. In practice, all DS does is advance the location counter by the specified number of positions.

The output of ASM is Intel HEX-format files which are not suitable for direct execution. You have to "absolutize" them with LOAD, which essentially constructs a memory image from the HEX file and writes it as a COM file.

So, you may well ask, why doesn't ASM output a memory image and skip the HEX thing? Compatibility for one. The Intel MDS understands this format, as do many other operating systems.


Ever wonder how MOVCPM works? Since the BDOS and CCP is in high memory, above the user application, addresses have to be changed every time the system memory size is changed. Now that requires relocating addresses in 8080 code, since relative addressing is not part of the hardware. Without implementing a full-blown relocating assembler and loader, how does one go about this?

It's actually pretty clever and MP/M even uses this scheme to construct its page-relocatable files. You simply assemble the source program twice with the second assembly origin 100H (256 bytes) higher than the first. The two binary images are then compared, byte for byte, and a map constructed of where pairs of bytes differ in value by exactly 100H. The result is a list of locations where the relocation value needs to be adjusted if the location of a program in memory is to be moved.

MP/M calls this sort of file PRL (page relocatable), but I don't know that CP/M 2.2 ever coined a name for it.
 
Last edited:
Back
Top