Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


cp_m_assembler_example

CP/M Assembler 2.0 hello world!

Hello World! Example.

Environment:

Edit new file with WordMaster

A>wm hellow.asm
        ORG     0100H           ; CP/M base of TPA (transient program area)
        MVI     C,09H           ; Print string function
        LXI     D,MESSAGE       ; Point
        CALL    0005H           ; Call bdos
        RET                     ; To cp/m
MESSAGE:DB      0DH,0AH,'Hello, World!',0DH,0AH,'$'
        END

Assemble program

The assembler produces 8080 machine language in Intel hex format. The PRN file contains an annotated listing.

A>asm hellow
CP/M ASSEMBLER - VER 2.0
011B
000H USE FACTOR
END OF ASSEMBLY

A>type hellow.hex
:100100000E09110901CD0500C90D0A48656C6C6F17
:0B0110002C20576F726C64210D0A2434
:0000000000

Create binary file (.COM)

A>load hellow

FIRST ADDRESS 0100
LAST  ADDRESS 011A
BYTES READ    001B
RECORDS WRITTEN 01

Run the program

A>hellow

Hello, World!

Dump hex / ascii

B>a:dump hellow.com

0000 0E 09 11 09 01 CD 05 00 C9 0D 0A 48 65 6C 6C 6F  ...........Hello
0010 2C 20 57 6F 72 6C 64 21 0D 0A 24 00 00 00 00 00  , World!..$.....
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
cp_m_assembler_example.txt · Last modified: 2021/10/09 15:14 by 127.0.0.1