Minimal assembler program for CP/M 3.1 (z80)

Posted by Andrew J. Brehm on Stack Overflow See other posts from Stack Overflow or by Andrew J. Brehm
Published on 2012-09-03T09:36:14Z Indexed on 2012/09/03 9:37 UTC
Read the original article Hit count: 262

Filed under:
|

I seem to be losing the battle against my stupidity.

This site explains the system calls under various versions of CP/M.

However, when I try to use call 2 (C_WRITE, console output), nothing much happens.

I have the following code.

ORG 100h
LD E,'a'
LD C,2
CALL 5
CALL 0

I recite this here from memory. If there are typos, rest assured they were not in the original since the file did compile and I had a COM file to start.

I am thinking the lines mean the following:

  1. Make sure this gets loaded at address 100h (0h to FFh being the zero page).
  2. Load ASCII 'a' into E register for system call 2.
  3. Load integer 2 into C register for system call 2.
  4. Make system call (JMP to system call is at address 5 in zero page).
  5. End program (Exit command is at address 0 in zero page).

The program starts and exits with no problems. If I remove the last command, it hangs the computer (which I guess is also expected and shows that CALL 0 works).

However, it does not print the ASCII character. (But it does print an extra new line, but the system might have done that.)

How can I get my CP/M program to do what the system call is supposed to do? What am I doing wrong?

© Stack Overflow or respective owner

Related posts about z80

Related posts about cpm