• Please review our updated Terms and Rules here

Multi module CP/M assembly programming question.

whartung

Veteran Member
Joined
Apr 23, 2020
Messages
737
I have a couple simple routines.

HELLO.MAC
Code:
.z80
extrn print

start: ld hl, msg
    call print
    ld c, 0
    call 5
    halt

msg: db 'Hello',0
end start

And PRINT.MAC
Code:
.z80

public print

print: ld a, (hl)
    cp 0
    ret z
    inc hl
    push hl
    ld e, a
    ld c, 2
    call 5
    pop hl
    jr print

end

The editor butchers this a bit.

I assemble and link them using M80:
Code:
m80 =hello/l
m80 =print/l
l80 hello/n,print/n,hello/e

Link-80 3.44 09-Dec-81 Copyright (c) 1981 Microsoft

Data 0103 0215 < 274>

-PRINT 0207

1 Undefined Global(s)

48927 Bytes Free

[0203 0215 2]

I don't understand why it can't find PRINT.

Also, how does it know to start at 100 with no ORG statement?
 
Why the "/n" after the object files in the L80 invocation? You're essentially telling L80 to produce hello.com and print.com, not link them.

Try this:
Code:
[/FONT]
Link-80 Release 3.36 29-Feb-80
*hello,print
Data 0103 0124



*hello/n/e

Data 0103 0124

[0103 0124 1]
 
Last edited:
Why the "/n" after the object files in the L80 invocation?

Because I don't know what I'm doing. :)

Try this:
Code:
[/FONT]
Link-80 Release 3.36 29-Feb-80
*hello,print
Data 0103 0124



*hello/n/e

Data 0103 0124

[0103 0124 1]


Yes, this worked a peach. Thank you.

How do you find how much "free" memory you have after you load the program?

Specifically, how do you know where memory starts after your code and how far you can go?

I've seen folks grab the address from BDOS call to find "top of memory". But what about the end of my code?

In a simple assembly program, you just have a label at the "end" and that's the start of memory.

But how does that work when you have several modules? How do you order that?

Also, is there a way to get a symbol table out of L80?

Thanks for the help.
 
Look at location 5--that's a jump to BDOS. Zero out the low byte of that jump address and you have the beginning of BDOS. That gives you the limit to high memory. You can overwrite CCP with no problems as BDOS will reload it at program termination.

As far as the end of your code, that's up to you to determine. You can define a symbol at the end of the last module loaded, for example.

You can get a rudimentary symbol table from l80 with the /m switch. But really, l80 is pretty primitive--DRI Link80 is far more powerful.
 
Last edited:
Back
Top