1983 program listing

Discussions related to using the integrated assembler
colinhoad
Posts: 8
Joined: Sun 03 Feb 2019, 17:29

1983 program listing

Post by colinhoad »

Hi,

I've been attempting to run an old 1983 BBC Micro User program taken from a listing in said magazine. I've typed it all in, but it contains a PROC that jumps into assembly code (which I freely confess I don't understand). The problem I have is that the program is throwing up syntax errors when it gets to that PROC, but I don't know where to start in terms of debugging it. Is there anyone here who might be able to shed some light on (a) what this assembly language is doing and (b) what might be wrong with it and/or if there's a way to achieve the same goal but without having to go into assembly code?

(Apologies if this sounds like a dim-witted question, I'm still learning.)

The PROC in question is defined below:

Code: Select all

  780 DEFPROCAS : DIM ZZ%352 : FOR C%=0 TO 2 STEP 2 : P%=ZZ% : [OPT C%
  790 .RT LDA&71:CMP#3:BMIR1:BEQR2:RTS
  800 .R2 LDA&70:CMP#72:BMIR1:RTS
  810 .R1 LDA&70:CLC:ADC#20:STA&70:LDA&71:ADC#0:STA&71:LDA#128:STA&7F:JSRM1
  820 JSRG1:LDA#20:STA&7F:JSRM2:LDA#4:STA&7F:JSRM3:LDA#85:STA&7F:JSRM4
  830 LDA#88:STA&7F:JSRM1:LDA#18:JSR&FFEE:LDA#0:JSR&FFEE:LDA#0:JSR&FFEE:LDA#60
  840 STA&7F:JSRM2:LDA#4:STA&7F:JSRM3:LDA#40:STA&7F:JSRM2:LDA#85:STA&7F:JSRM3:RTS
  850 .LT LDA#1:CMP&71:BMIL1:BEQL2:RTS
  860 .L2 LDA#174:CMP&70:BMIL1:RTS
  870 .L1 LDA&70:SEC:SBC#20:STA&70:LDA&71:SBC#0:STA&71:LDA#88:STA&7F:JSRM1:JSRG1
  880 LDA#40:STA&7F:JSRM2:LDA#4:STA&7F:JSRM3:LDA#20:STA&7F:JSRM2:LDA#85:STA&7F
  890 JSRM3:JSRG1:LDA#128:STA&7F:JSRM1
  900 LDA#18:JSR&FFEE:LDA#0:JSR&FFEE:JSR&FFEE:LDA#4:STA&7F:JSRM4
  910 LDA&70:CLC:ADC#20:STA&80:LDA&71:ADC#0:STA&81:LDA#85:STA&7F:JSRM3:RTS
  920 .M1 LDA#25:JSR&FFEE:LDA#4:JSR&FFEE:LDA&7F:JSR&FFEE:LDA#2:JSR&FFEE:LDA#0:JSR&FFEE:JSR&FFEE:RTS
  930 .G1 LDA#18:JSR&FFEE:LDA#0:JSR&FFEE:LDA#15:JSR&FFEE:RTS
  940 .M2 LDA&70:SEC:SBC&7F:STA&B0:LDA&71:SBC#0:STA&81:RTS
  950 .M3 LDA#25:JSR&FFEE:LDA&7F:JSR&FFEE:LDA&80:JSR&FFEE:LDA&81:JSR&FFEE:LDA#160:JSR&FFEE:LDA#0:JSR&FFEE:RTS
  960 .M4 LDA#25:JSR&FFEE:LDA&7F:JSR&FFEE:LDA&70:JSR&FFEE:LDA&71:JSR&FFEE:LDA#160:JSR&FFEE:LDA#0:JSR&FFEE:RTS
  970 ] : NEXT : ENDPROC
 
David Williams

Re: 1983 program listing

Post by David Williams »

What version of BBC BASIC are you trying to run that program under?

If you are trying to run the program under 'BBC BASIC for Windows' or 'BBC BASIC for SDL 2.0' then it couldn't possibly work because their built-in assemblers don't understand 6502 assembly language (the BBC Micro is based on the 6502 CPU, whereas PCs and Macs are based on Intel or ARM processors which use entirely different, mutually incompatible instruction sets).

If you want that program to run on a PC or Mac, then you will need an BBC Micro emulator (my personal favourite is BeebEm, although B-em is also excellent).

BeebEm: http://www.mkw.me.uk/beebem/


David.
--
colinhoad
Posts: 8
Joined: Sun 03 Feb 2019, 17:29

Re: 1983 program listing

Post by colinhoad »

Thank you for clearing this up for me, David. I was indeed attempting to run the program under BB4W and so your explanation makes perfect sense. I'll try it using BeebEm (which I agree is a very good emulator) and see how I get on.

Thanks again.
Repton
Posts: 42
Joined: Tue 22 May 2018, 13:51

Re: 1983 program listing

Post by Repton »

Assembler was used for speed which could be replaced with basic code on BBC w.
Repton
Posts: 42
Joined: Tue 22 May 2018, 13:51

Re: 1983 program listing

Post by Repton »

could you in theory get Bbc basic sdl to translate 6502 assembler?
DDRM

Re: 1983 program listing

Post by DDRM »

Not sure what you are asking. As far as I'm aware there isn't a version of BBC4SDL with a 6502 assembler built in.

It's possible to write transcompilers (which take a program in one language and translate it into another language), so I guess you could write one which converted the 6502 assembler into (say) x86 code to run on a PC, but it wouldn't be easy! Since BBC4SDL is a good general purpose language it would be possible to do it in BBC4SDL, but I'm not sure it would be worth it unless you had a lot of programs you wanted to translate.

These days computers are so much faster it would probably be easier, and acceptably fast, simply to rewrite the assembler sections in BBC BASIC.

Happy to be corrected if anyone has a better opinion!

:-)

D
nvingo
Posts: 41
Joined: Sat 28 May 2022, 22:40

Re: 1983 program listing

Post by nvingo »

DDRM wrote: Tue 31 Aug 2021, 10:05...These days computers are so much faster it would probably be easier, and acceptably fast, simply to rewrite the assembler sections in BBC BASIC...
That might be simply automated - in BBC Basic.
IIRC the 6502 instruction set is simple compared to even the Z80, let alone the x86.
Started using BASIC circa 1981 with CP/M, Video Genie, Sinclair ZX81, Acorn Atom, and progressed with ZX Spectrum, BBC Micro and Sinclair QL, Cambridge Z88, DOS, Windows. Wrote A-level project using school's BBC Micro with dual 800K floppy drive.