Skip to content

Porting guide ​

Pick a machine you're porting from and one you're porting to, and this page tells you what needs to change. Read it inside the IDE with a program open and it specialises itself to that program.

If you're new to porting programs, read this first. The usage strings below are written in the argument notation the language references use.

Porting from
to

C64 → Spectrum: 22 commands to rewrite across 7 capability areas, 4 commands to rename and 34 commands whose usage differs. 13 language or hardware rules differ and Spectrum adds 4 capability areas.

Open your program in the Basically IDE to narrow this comparison to the commands and control codes it actually uses.

4 capability areas and 5 control-code categories Spectrum only adds to are hidden.

Language & hardware

C64Spectrum
BASIC dialectCommodore BASIC V248K Sinclair BASIC
NumbersFloating point, with an integer type marked by %.Floating point.
Free program RAM38,911 bytes41,472 bytes
Variable namesOnly the first two characters are significant; % suffix = integer, $ = string.Numeric names may be long; string and array names are a single letter with $.
LET on assignmentOptionalRequired (LET x=…)
Abbreviated entryShifted last letter (pO for POKE); ? for PRINTNone
CharactersNo \ ^ ` { | } ~No ^ `
AND, OR and NOTBitwise on integers; no exclusive-OR operatorValue logic - A AND B is A or 0, not a bit pattern
Comparisons yield-1 for true, 0 for false1 for true, 0 for false
Line numbers0–639991–9999
Screen40×25 text; bitmap 320×200.32×22 usable text; 256×176 pixel graphics via PLOT/DRAW/CIRCLE.
Colour16 colours and eight hardware sprites.8 colours with BRIGHT and FLASH; one ink/paper per 8×8 cell (attribute clash).
SoundThree-voice SID with filters, driven by POKE.BEEP duration,pitch (single channel).

Before you start: C64 → Spectrum

  • The jumps are spelled with a space: GOTO and GOSUB become GO TO and GO SUB, while CLR becomes CLEAR and CONT becomes CONTINUE.
  • Everything the Commodore did by POKEing the VIC and SID becomes real keywords — PLOT, DRAW, CIRCLE, INK, PAPER and BEEP — so those routines are rewritten, not translated.
  • LEFT$, MID$ and RIGHT$ have no equivalent: slice with A$(start TO end). Numeric names may now be long, but string and array names are a single letter with $.
  • LET is required. There is no ELSE, but everything after THEN — including further ':' statements — runs only when the test is true.
  • One ink and paper per 8×8 cell, so colours clash where shapes overlap — a routine drawing in several colours has to keep them a cell apart.
  • Control codes are brace directives inside strings, such as {INK 2} and {AT 5,3}.

Characters to replace (2)

Spectrum has no glyph for these characters, so they cannot appear anywhere in the program — not in a string, and not in a comment.

^, `

Same command, different form

On both machines, but not written the same way — a search and replace for the first two, a look at each use for the rest.

4 commands spelled differently: CLR → CLEAR, CONT → CONTINUE, GOSUB → GO SUB, GOTO → GO TO

14 commands differing only in whether the argument is bracketed — write them as Spectrum does: ABS, ATN, CHR$, COS, EXP, INT, LEN, PEEK, SGN, SIN, SQR, STR$, TAN, VAL

  • <=Different argumentsC64: operator · <number> <= <number> | <string> <= <string>→Spectrum: operator · <number> <= <number>
  • <>Different argumentsC64: operator · <number> <> <number> | <string> <> <string>→Spectrum: operator · <number> <> <number>
  • >=Different argumentsC64: operator · <number> >= <number> | <string> >= <string>→Spectrum: operator · <number> >= <number>
  • FNDifferent argumentsC64: function · FN <name>(<number>)→Spectrum: function · FN <name>([<number>[, <number>]…])
  • IFDifferent argumentsC64: command · IF <number> THEN <line> | <statement>→Spectrum: command · IF <number> THEN <statement>
  • INPUTDifferent argumentsC64: command · INPUT [<prompt>;] <var>[, <var>]…→Spectrum: command · INPUT [<prompt>;] <var>
  • LETDifferent argumentsC64: command · LET <var> = <number> | <string>→Spectrum: command · LET <var> = <expr>
  • LISTDifferent argumentsC64: command · LIST [<line>][-[<line>]]→Spectrum: command · LIST [<line>]
  • LOADDifferent argumentsC64: command · LOAD [<filename> [, <device> [, <number>]]]→Spectrum: command · LOAD <filename>
  • NEXTDifferent argumentsC64: command · NEXT [<numvar>[, <numvar>]…]→Spectrum: command · NEXT <numvar>

What changes

22 commands to rewrite or remove, grouped by what they do, with what Spectrum offers in their place. The capabilities Spectrum has no equivalent of at all come first.

Colour key Partly covered Under other names

Control flow 4 only partly covered in Spectrum

DEF, END, GO, ON

No ELSE: put the negative case on the following line, or chain further ':' statements after THEN — they all run only when the test is true.

No ELSE: chain after THEN

10 IF X=0 THEN PRINT "ZERO": GO TO 30
20 PRINT "NONZERO"

Spectrum adds 2 here. IF…THEN, FOR…NEXT and GO TO/GO SUB cover jumps and loops, with everything after THEN running only when the test is true.

Strings 4 only partly covered in Spectrum

ASC, LEFT$, MID$, RIGHT$

No LEFT$/MID$/RIGHT$: slice a string with a$(start TO end) — e.g. a$(1 TO 3) for the first three characters.

Slice instead of LEFT$/MID$

10 LET a$="HELLO"
20 PRINT a$(1 TO 3)

Spectrum adds 2 here. VAL$, CODE, VAL, LEN, STR$ and CHR$ convert between strings and numbers.

Numbers 2

LOG, π

No base-only quirks: SIN/COS/TAN and the rest already take radians directly.

Spectrum adds 6 here. A full trig/log set plus <=, >= and <> covers real arithmetic and complete comparisons.

Text and screen 3

POS, SPC(, TAB(

No LOCATE-named command: AT row,column is the equivalent, written directly inside a PRINT statement.

Spectrum adds 6 here. AT positions text by row and column, TAB moves the column, and SCREEN$ reads a character back off the display.

Input 1

GET

No LINE INPUT-style raw read: INPUT already accepts a full expression or string, quoted or not.

Spectrum adds 1 here. INKEY$ polls the keyboard without waiting, INPUT reads a whole line or expression.

Storage 5

CLOSE, CMD, INPUT#, OPEN, PRINT#

No random-access record keyword in BASIC: structure tape data sequentially, since there is no direct-access file mode.

Spectrum adds 8 here. SAVE/LOAD/VERIFY/MERGE with CAT and FORMAT give full cassette (and +3 disk) file handling.

Memory and hardware 3

FRE, SYS, WAIT

No indirection operators: address every read/write with PEEK/POKE directly rather than ?addr/!addr-style shortcuts.

Spectrum adds 2 here. PEEK and POKE read and write memory, USR calls machine code, and IN/OUT reach I/O ports.

Control & escape codes (108 to replace)

Embedded colour and graphics control codes differ between the machines. Grouped by what they do, with the classes Spectrum has no way to express at all first; the C64 escape-code reference gives every code's meaning.

Colour key Nothing like it Partly covered Under other spellings

Function keys 8 nothing like it in Spectrum

{f1}, {f2}, {f3}, {f4}, {f5}, {f6}, {f7}, {f8}

No function keys and no code for one: read a key with INKEY$ and branch on what it returns.

Editing 5 only partly covered in Spectrum

{clr}, {cr}, {del}, {inst}, {shift-cr}

CLS clears the screen, but nothing deletes or inserts within a line. Re-print the line, or overwrite it with {AT r,c}.

Modes 6 only partly covered in Spectrum

{dishift}, {enshift}, {lower}, {rvoff}, {rvon}, {upper}

One screen mode, and both cases are always available, so a character-set switch is dropped. Reverse video is {INVERSE 1} rather than a mode.

Control 1 only partly covered in Spectrum

{stop}

The directives are {INK n}, {PAPER n}, {FLASH n}, {BRIGHT n}, {INVERSE n}, {OVER n}, {AT r,c} and {TAB n} — match the effect to one of those, or drop it.

Characters 2 only partly covered in Spectrum

{shift-space}, {space}

A lone backslash opens a UDG escape, so write \\ for a literal one. A second space character like the Commodore's shifted space becomes an ordinary space.

Key graphics 63 only partly covered in Spectrum

{CBM--}, {CBM-@}, {CBM-*}, {CBM-+}, {CBM-£}, {CBM-a}, {CBM-b}, {CBM-c}, {CBM-d}, {CBM-e}, {CBM-f}, {CBM-g}, {CBM-h}, {CBM-i}, {CBM-j}, {CBM-k}, {CBM-l}, {CBM-m}, {CBM-n}, {CBM-o}, {CBM-p}, {CBM-q}, {CBM-r}, {CBM-s}, {CBM-t}, {CBM-u}, {CBM-v}, {CBM-w}, {CBM-x}, {CBM-y}, {CBM-z}, {SHIFT--}, {SHIFT-@}, {SHIFT-*}, {SHIFT-↑}, {SHIFT-+}, {SHIFT-£}, {SHIFT-a}, {SHIFT-b}, {SHIFT-c}, {SHIFT-d}, {SHIFT-e}, {SHIFT-f}, {SHIFT-g}, {SHIFT-h}, {SHIFT-i}, {SHIFT-j}, {SHIFT-k}, {SHIFT-l}, {SHIFT-m}, {SHIFT-n}, {SHIFT-o}, {SHIFT-p}, {SHIFT-q}, {SHIFT-r}, {SHIFT-s}, {SHIFT-t}, {SHIFT-u}, {SHIFT-v}, {SHIFT-w}, {SHIFT-x}, {SHIFT-y}, {SHIFT-z}

The Spectrum draws 16 quadrant cells, typed as their block glyphs — redraw the shape on that 2x2 grid, or define a UDG (\a…\u) for it.

Colours 16Spectrum has these under its own spellings

{black}, {blue}, {brown}, {cyan}, {green}, {grey1}, {grey2}, {grey3}, {lblue}, {lgreen}, {orange}, {pink}, {purple}, {red}, {white}, {yellow}

The Spectrum carries colour in the string: {INK n} and {PAPER n} set it from that point, with {BRIGHT n} and {FLASH n} beside them.

Colour inside the string

10 PRINT "{INK 2}{PAPER 7}RED"

Cursor 5Spectrum has these under its own spellings

{down}, {home}, {left}, {right}, {up}

{AT r,c} positions inside the string and {TAB n} moves the column — or write PRINT AT row,column before the text.

Position with AT

10 PRINT AT 5,10;"HERE"

Raw bytes 2Spectrum has these under its own spellings

{$xx}, {nnn}

Respell the byte as {0xNN} — two hex digits.

Memory layout

Then what changes quietly. Left until here because it is checked against code that has stopped changing.

Same word, different meaning (3)

These exist on both machines, so they raise no error — they just do something else.

  • ANDC64: Bitwise on 16-bit integers: 5 AND 3 is 1.→Spectrum: Picks a value, not bits: a AND b is a when b is non-zero and 0 otherwise, so 5 AND 3 is 5.
  • ORC64: Bitwise on 16-bit integers: 5 OR 3 is 7.→Spectrum: Picks a value, not bits: a OR b is 1 when b is non-zero and a otherwise, so 5 OR 3 is 1.
  • USRC64: The argument is data: it calls the routine whose address is held in the USR vector at $0311, and returns that routine’s result.→Spectrum: The argument is the address: it calls machine code there and returns the BC register pair — unless it is a single-letter string, which gives that user-defined graphic’s address instead.

Released under GNU GPL v3.0. Some ROM images are third-party copyrighted works, separate to this project, strictly for personal/educational purposes.