Minimum assembler program for CP / M 3.1 (z80)

I seem to be losing the battle against my stupidity.

This site explains system calls in different versions of CP / M.

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

I have the following code.

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

I read it here from memory. If there are typos, be sure that they were not in the original, since the file was compiled and I got a COM file.

I think the lines mean the following:

  • Make sure it loads at 100h (0h - FFh, which is the zero page).
  • Load ASCII 'a' into register E for system call 2.
  • Load integer 2 into register C for system call 2.
  • Make a system call (JMP for the system call is located at address 5 on the zero page).
  • The final program (the exit command is located at address 0 on the zero page).

The program starts and exits without problems. If I delete the last command, it hangs on the computer (which, it seems to me, is also expected, and shows that CALL 0 is working).

However, it does not print the ASCII character. (But he prints an extra new line, but the system could do that.)

How can I get CP / M to do what a system call should do? What am I doing wrong?

UPDATE: The problem was that all the assemblers I tried were expecting a specific source file format. This file worked with Microsoft macro assembler:

  .Z80 START: LD E,'a' LD C,2 CALL 5 JP 0 

I think (I guess) that asm.com (DR assembler) and m80.com (Microsoft macro assembler) are expecting the Intel 8080 Mnemon, and I need to say that they should expect me to need the z80 nominees, which apparently , different.

Anyway, I agree with the answer, because it is also correct, because it offers just to write the image itself, without worrying about asm.com.

+4
source share
1 answer

Obvious possibility: does your assembler accept "a" as a hexadecimal rather than an ASCII character? 0xa is ASCII for the new line. Maybe try g or check the hex dump of your assembler output?

Also, your code looks great, although RST 0 save a few bytes.

EDIT:

I passed your code:

 1e 61 0e 02 cd 05 00 cd 00 00 

I saved this to disk as mytest.com. Then I launched this CP / M emulator (warning: a direct link to downloading the file, the emulator seems to be called Joan Riff "Z80MU PROFESSIONAL", Z80 and CP / M 2.2 Emulator and it’s older than twenty years, so there seems to be no web pages) for DOS inside DOSBox and mytest.com is launched. It displays the letter "a". So your program chain or your CP / M is not working.

Image because it really happened:

enter image description here

+3
source

Source: https://habr.com/ru/post/1432039/


All Articles