• Please review our updated Terms and Rules here

MC68000 Basic68k Question(s)

Srathidai

Member
Joined
Feb 3, 2025
Messages
28
Location
Yuma, AZ
I am playing around with the Basic68k that you can find here on this page: https://philpem.me.uk/leeedavison/68k/ehbasic/index.html at the bottom called source.zip.

In it there is a section that sets up vectors to subroutine in the code. Here is the code I am looking at.

* BASIC cold start entry point

LAB_COLD
MOVE.l #ram_base,sp * set simulator stack for this prog
MOVE.w #$4EF9,d0 * JMP opcode
MOVEA.l sp,a0 * point to start of vector table

MOVE.w d0,(a0)+ * LAB_WARM
LEA (LAB_COLD,PC),a1 * initial warm start vector
MOVE.l a1,(a0)+ * set vector

MOVE.w d0,(a0)+ * Usrjmp
LEA (LAB_FCER,PC),a1 * initial user function vector
* "Function call" error
MOVE.l a1,(a0)+ * set vector

MOVE.w d0,(a0)+ * V_INPT JMP opcode
LEA (VEC_IN,PC),a1 * get byte from input device vector
MOVE.l a1,(a0)+ * set vector

MOVE.w d0,(a0)+ * V_OUTP JMP opcode
LEA (VEC_OUT,PC),a1 * send byte to output device vector
MOVE.l a1,(a0)+ * set vector

MOVE.w d0,(a0)+ * V_LOAD JMP opcode
LEA (VEC_LD,PC),a1 * load BASIC program vector
MOVE.l a1,(a0)+ * set vector

MOVE.w d0,(a0)+ * V_SAVE JMP opcode
LEA (VEC_SV,PC),a1 * save BASIC program vector
MOVE.l a1,(a0)+ * set vector

MOVE.w d0,(a0)+ * V_CTLC JMP opcode
LEA (VEC_CC,PC),a1 * save CTRL-C check vector
MOVE.l a1,(a0)+ * set vector

MOVE.l sp,(a0) * save entry stack value

* set-up start values

I see they put the JMP opcode into D0 and then they increment through the starting address called RAM_BASE. Why is this done? Is this code from the good ole days when we didn't have a compiler to find labels and replace with the address locations? Is this a speed hack for the slower designs?

I am still learning the wonderful world of 68k Assembly language.
 
It does look like a "brute force' way of setting up a few vector jump addresses in a block of RAM.

I would have got the assembler to have created the jump vector table in a block of program space, and then copied this block from program space into RAM space on start-up.

But there are only a few vectors to set-up, so that may be overkill...

Dave
 
It's been a long time since i've done any work on Basic68k.
I think the table is dynamically build to allow multiple copies of basic to run concurrently.
All memory is accessed using base registers. Each running copy has access to its own memory space. (no protection so play nice)
 
You could have all that in a pre made table that you'd copy, but then you'd anyways need code to relocate the addresses. Having PC as part of the address mode makes the address relative, and thus it will work no matter where in memory it is loaded.

Don't know when assemblers that could do simple maths when creating tables became common.
 
Back
Top