• Please review our updated Terms and Rules here

CP/M 68K assembly language programming on the 68K-MBC

rwcooper

Member
Joined
Jan 17, 2023
Messages
23
I'm trying to get the demo hello world assembly language program working on the 68K-MBC under CP/M 68K. It assembles and links without any error messages. When I run it there is no output, and no errors, after a second or two I get the CP/M command line prompt. I have no prior experience with CP/M. I don't know if it is actually executing. I'm wondering if anyone has a simple 68K assembly language that displays output on the console and works with CP/M V1.3 on the 68K-MBC. I'm able to write and successfully run assembly language programs that use the getchar and putchar functions to do I/O. I want to eliminate the use of these C functions and read from and write to the serial port directly. These are the commands I've tried with and without -t400.

C>AS68 -L -U -S C: F:ASMDEMO.S

C>lo68 -r -i -t400 -o f:asmdemo.68k f:asmdemo.o

C>f:asmdemo

C>

Thanks for any help anyone is able to provide...Randy.
 
Could you share your assembly code? I don’t have 68K-MBC but I do have CPM68K running on my own 68K hardware. I like to try out your assembly.
Bill
 
Here is the example program for the 68K_MBC.

C>type f:asmdemo.s
* =================================================================================

* IOS equates
IOBASE EQU $FFFFC ; Address base for the I/O ports
EXCWR_PORT EQU IOBASE+0 ; Address of the EXECUTE WRITE OPCODE write port
EXCRD_PORT EQU IOBASE+0 ; Address of the EXECUTE READ OPCODE read port
STOPC_PORT EQU IOBASE+1 ; Address of the STORE OPCODE write port
SER1RX_PORT EQU IOBASE+1 ; Address of the SERIAL 1 RX read port
SYSFLG_PORT EQU IOBASE+2 ; Address of the SYSFLAGS read port
SER2RX_PORT EQU IOBASE+3 ; Address of the SERIAL 2 RX read port
USRLED_OPC EQU $00 ; USER LED opcode
SER1TX_OPC EQU $01 ; SERIAL 1 TX opcode
SELDISK_OPC EQU $09 ; SELDISK opcode
SELTRCK_OPC EQU $0A ; SELTRACK opcode
SELSECT_OPC EQU $0B ; SELSECT opcode
WRTSECT_OPC EQU $0C ; WRITESECT opcode
SER2TX_OPC EQU $10 ; SERIAL 2 TX opcode
ERRDSK_OPC EQU $85 ; ERRDISK opcode
RDSECT_OPC EQU $86 ; READSECT opcode
SDMOUNT_OPC EQU $87 ; SDMOUNT opcode
FLUSHBF_OPC EQU $88 ; FLUSHBUFF opcode

* Common ASCII codes
cr EQU 13
lf EQU 10
sp EQU 32
esc EQU $1B
eos EQU 0

.text
START:
lea MESSAGE,a1
bsr puts
rts

* =========================================================================== ;
*
* Send a string to the serial 1, A1 = pointer to the string.
* NOTE: Only D0.B and A1 are used
*
* =========================================================================== ;
puts:
move.b (a1)+,d0 ; D0.B = current char to print
cmp.b #eos,d0 ; Is it an eos?
beq puts_end ; Yes, jump
move.b #SER1TX_OPC,STOPC_PORT.l ; Write SERIAL 1 TX opcode to IOS
move.b d0,EXCWR_PORT.l ; Print current char
bra puts

puts_end:
rts

MESSAGE DC.B 'HELLO WORLD! ', cr, lf, eos

I have also attached the program as example.txt. I hope you are able to get it working. Thanks.
 

Attachments

  • example.txt
    2.2 KB · Views: 2
Last edited:
You are not using CP/M68K BDOS functions? Your program does I/O directly which won't work on my hardware because my I/O is different. Try this:

text
move.l #message,d1
move #9,d0
trap #2

data
message: dc.b 13,10,'Hello World!','$'
end



Assemble with:
as68 -l -u -s 0: filename.s
Link with:
lo68 -r -o filename.68k filename.o
 
You are not using CP/M68K BDOS functions? Your program does I/O directly which won't work on my hardware because my I/O is different. Try this:

text
move.l #message,d1
move #9,d0
trap #2

data
message: dc.b 13,10,'Hello World!','$'
end



Assemble with:
as68 -l -u -s 0: filename.s
Link with:
lo68 -r -o filename.68k filename.o
Thanks for your response. I thought as the example program came with the 68K_MBC it should work. I discovered the BDOS functions late last night and I have been playing around with them all day. They seem to do exactly what I want. I appreciate your help...Randy
 
I would have also thought that the example program should have worked - with the caveat that the hardware is identical. However, from the code, I don't see how it handles the serial port correctly.

As a CP/M example, however, it is extremely poor if it doesn't actually use the machine independent BDOS functions (as has already been stated)...

Now, if you want to program your board at the bare metal level, you can use CP/M to develop, load and run your program - whereupon you take over the machine. But now you have to drive the hardware yourself! I have done this for extreme speed with some bespoke software running on an Amiga (going back many years). Fun...

Dave
 
I would have also thought that the example program should have worked - with the caveat that the hardware is identical. However, from the code, I don't see how it handles the serial port correctly.

As a CP/M example, however, it is extremely poor if it doesn't actually use the machine independent BDOS functions (as has already been stated)...

Now, if you want to program your board at the bare metal level, you can use CP/M to develop, load and run your program - whereupon you take over the machine. But now you have to drive the hardware yourself! I have done this for extreme speed with some bespoke software running on an Amiga (going back many years). Fun...

Dave
I'm not planning on doing any bare metal programming on 68K-MBC. I've done that on various microcontrollers, raspberry pi zero and computers I've designed and built using the 6502, 6809 and 68008 (wire wrapping all the connections, no PCBs).
 
Back
Top