6502 Assembly on BBC B, what do I need?

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
Post Reply
evilcraftknife
Posts: 3
Joined: Sat Nov 30, 2019 2:27 pm
Contact:

6502 Assembly on BBC B, what do I need?

Post by evilcraftknife » Mon Dec 02, 2019 4:12 pm

Hi All

Is there a baseline of documentation and hardware I need to get started in 6502 programming for the beeb? I don't necessarily want to do the coding on the beeb but will be wanting to run it on the real thing. I have a BBC B with a 3.5" diskette drive and one diskette(not sure what kind) , that's it! Do I pipe binary data over a serial link to a file on disk or into memory somehow? Do I need a Gotek or MMC solution to manually transfer binaries? What interesting memory locations are available to me on the beeb? Is there an easily understood memory map online? Must read books, walk throughs, Youtube channels(most 6502 tutorials are for C64)? What should I pay for a Gotek/MMC solution?

I am starting from scratch here, I know nothing of this hardware but I did some BASIC and Z80 coding(by hand, looking up opcodes in a table and poking the decimals into RAM) in my teens on my speccy in the '80s.

Thanks for any advice

Kev

Coeus
Posts: 1402
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by Coeus » Mon Dec 02, 2019 5:33 pm

For 6502 programming in general there is the 6502.org website: http://6502.org/

For specifics to the BBC micro there is some information on how to use OS facilities in the User Guide and more in the Advanced User Guide and the revised version The New Advanced User Guide. There is loads of information on mdfs.net and BeebWiki.

As for how to run what you have written by far the easiest thing is to run initially in one of the Emulators: B-Em, BeebEm, b2 etc. If you use BeebAsm as the assembler it can write the output directly into an SSD file which the emulator can use as a disc image.

If you want to run on a real machine then an SD card solution would be good and there are a couple of threads on them here in the hardware forum. There are various serial solutions including one from Tom Seddon/Chris Morley.
Last edited by Coeus on Mon Dec 02, 2019 5:52 pm, edited 3 times in total.

User avatar
BigEd
Posts: 2691
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by BigEd » Mon Dec 02, 2019 5:36 pm

Welcome! I suspect MMC solutions are most popular, but I've used a serial link in the past to good effect.

You will find, I think, that the Beeb has a rather sophisticated OS: you are more likely to be making system calls than poking locations in memory. (The obvious exception being updating video memory in a game context, or maybe writing code to support novel hardware)

The original User Guide is essential, the Advanced User Guide also highly valuable. Both can readily be found as PDF, or bought second hand.

Edit: oops, redundant advice!

Coeus
Posts: 1402
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by Coeus » Mon Dec 02, 2019 5:46 pm

See: viewtopic.php?f=55&t=15476&hilit=hostfs for info on deploying from PC to BBC.

User avatar
sydney
Posts: 2459
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by sydney » Mon Dec 02, 2019 7:34 pm

Using mmc cards can be cumbersome as you need to add the ssd to the mmb file. A gotek would be the simplest solution. UPURS works well too, before I switched to a gotek my 'assemble' batch file would assemble using beebasm then send it straight to the beeb via UPURS.

User avatar
Lardo Boffin
Posts: 1708
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by Lardo Boffin » Mon Dec 02, 2019 9:09 pm

This book is pretty good. :oops: Sorry - shameless sales pitch there.

viewtopic.php?f=8&t=15176&start=60#p253176
Atom, issue 5
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
USA Model B
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA

webvivant
Posts: 30
Joined: Mon Apr 18, 2016 10:39 am
Location: France
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by webvivant » Tue Dec 03, 2019 10:55 am

Another vote for Beebasm. I'm currently following along with Ben Eater's 6502 project, but where he's using Vasm as the assembler software I decided to go with Beebasm because, ultimately, whatever I create I might also want to run on the Beeb.

I also find Beebem a good way to code in comfort on my Mac & then transfer to the real Beeb.

As for getting the code on to the Beeb, I use (and recommend) a DataCentre. I also have a TurboMMC device but find it less convenient than being able to chuck stuff on to a USB stick.

Coeus
Posts: 1402
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by Coeus » Tue Dec 03, 2019 1:13 pm

webvivant wrote:
Tue Dec 03, 2019 10:55 am
As for getting the code on to the Beeb, I use (and recommend) a DataCentre. I also have a TurboMMC device but find it less convenient than being able to chuck stuff on to a USB stick.
Mark (Retroclinic) is no longer supplying DataCentre and has open sourced the design in case anyone wants to port it to a more modern logic array. I am sure they will turn up second hand, though, either here or on eBay.

On the inconvenience mentioned above at having to insert an SSD disc image into an MMB file for use of most of the SD/MMC card solutions it is worth noting that MMFS V2 does away with this layer. Instead it stores the SSD images directly as files within the FAT filesytem on the card. That means once you have an SSD (for example from BeebASM) a simple file copy is all that is needed, i.e. Windows Explorer or even automated via a batch file etc. and likewise for Linux.

User avatar
tricky
Posts: 3815
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by tricky » Tue Dec 03, 2019 1:19 pm

beebasm :)
We have a frozen sister site http://www.retrosoftware.co.uk/wiki/index.php/Main_Page which has some useful content.
There are some (converted from z80) video tutorials https://www.youtube.com/playlist?list=P ... gDgsIaySwU.

User avatar
lurkio
Posts: 2212
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by lurkio » Tue Dec 03, 2019 1:31 pm

Coeus wrote:
Tue Dec 03, 2019 1:13 pm
On the inconvenience mentioned above at having to insert an SSD disc image into an MMB file for use of most of the SD/MMC card solutions it is worth noting that MMFS V2 does away with this layer.
Is MMFS v2 available for use yet?

:?:

evilcraftknife
Posts: 3
Joined: Sat Nov 30, 2019 2:27 pm
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by evilcraftknife » Tue Dec 03, 2019 1:58 pm

Aw brilliant! Thank you all for the advice. I think I'll be going for the UPURS solution, it seems a lot less fiddly than swapping USB/MMC drives around. I did a bit of Googling and the User Guide seems to be highly recommended.

Could anybody tell me how I identify what flavour of 3.5" floppy disks to use?

User avatar
Ricardo
Posts: 14
Joined: Sun Jan 28, 2018 4:52 pm
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by Ricardo » Tue Dec 03, 2019 2:24 pm

If you have a working Beeb with monitor and disk drive then as an initial learning tool to get into 6502 I would keep it simple and write some code using BBC Basic on the Beeb as its got a nice built in 6502 assembler. The Advanced User Guide is the book you really need (the black/blue/yellow one).

User avatar
1024MAK
Posts: 9393
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by 1024MAK » Tue Dec 03, 2019 5:24 pm

evilcraftknife wrote:
Tue Dec 03, 2019 1:58 pm
Aw brilliant! Thank you all for the advice. I think I'll be going for the UPURS solution, it seems a lot less fiddly than swapping USB/MMC drives around. I did a bit of Googling and the User Guide seems to be highly recommended.

Could anybody tell me how I identify what flavour of 3.5" floppy disks to use?
For 3.5” you need double density disks.

Mark

User avatar
jms2
Posts: 2313
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by jms2 » Tue Dec 03, 2019 6:05 pm

Ricardo wrote:
Tue Dec 03, 2019 2:24 pm
If you have a working Beeb with monitor and disk drive then as an initial learning tool to get into 6502 I would keep it simple and write some code using BBC Basic on the Beeb as its got a nice built in 6502 assembler. The Advanced User Guide is the book you really need (the black/blue/yellow one).
I think this is a really good point - for the initial learning stage you should really use the Beeb (or an emulator). The following short example should be helpful:

Code: Select all

10DIM code% 100
15oswrch%=&FFEE
20FOR pass%=0 TO 3 STEP 3
30P%=code%
40[OPT pass%
50LDA #ASC"A"
60JSR oswrch
70RTS
80]
90NEXT
Line 10: This uses DIM to reserve an amount of memory and sets the variable "code%" to point to the start of it.
Line 15: Defines one of the OS entry points. The routine at &FFEE is called WRite CHaracter (wrch) and will display the ASCII character in the accumulator
Line 20: This FOR..NEXT loop ensures the assembly is done in two passes. For the first pass, a value of 0 is used which means errors are ignored. This enables forward references to be used - these are then resolved correctly in the second pass (this example doesn't need this two-pass assembly but it is always wise to do it anyway). In the second pass, error checking is done and also the assembled code is printed on the screen.
Line 30: P% is a variable which sets the location at which assembly takes place. (Its a standard variable, but has special meaning in this context)
Line 40: "[" means start the assembler. OPT is a directive which sets the assembler options.
Line 50: Normal 6502 assembly, but note the BASIC function ASC can be used to find the ASCII code for A
Line 60: Print character
Line 70: Normal 6502
Line 80: Stop assembling
Line 90: Do the second pass.

After running this you will get a display showing what has been assembled, and where.
Typing CALL code% will run the machine code.

User avatar
1024MAK
Posts: 9393
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by 1024MAK » Tue Dec 03, 2019 9:50 pm

evilcraftknife wrote:
Mon Dec 02, 2019 4:12 pm
I have a BBC B with a 3.5" diskette drive and one diskette(not sure what kind)
Hi Kev

Welcome :D

Most BBC B machines back in the early 1980s were fitted with a disk system that used 5¼” disk drives. Indeed, the floppy disk controller chip (an Intel 8271) that was required (and which fitted on the main board) and Acorn’s DFS (disk filing system) were designed primarily for 5¼” disk drives. As such, this disk system will not work correctly with most 3½” drives.

In order to use 3½” drives, you either need the later 1770 floppy disk controller (a plug in module on a BBC B) complete with a 1770 DFS, a 3½” drive that has been modified specially for use with the Intel 8271 or a modified Acorn DFS.

Later Acorn machines (BBC B+, Master 128, Master Compact, Electron and Plus 3) can however use 3½” drives without any problems, as they all use the 1770 or sister disk controller chip.

The Intel 8271 is limited to single density operation because it only uses FM encoding. Although double density 5¼” disks are normally used. See this Wikipedia entry for more information.

1770 floppy disk controllers can also use MFM which allows double density 3½” disks to be used. When using the later Acorn ADFS (see here) this has some advantages (increased disk data capacity) but at the cost of using more main RAM in the computer.

You may want to introduce yourself in the introduce yourself section :wink:

Mark

rharper
Posts: 425
Joined: Sat Sep 01, 2012 5:19 pm
Location: Dunstable
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by rharper » Wed Dec 04, 2019 11:24 am

I think it is Acorn DFS 1.21 that works OK with the 8271 and 3.5" floppy drives.
Ray
Raycomp

User avatar
MartinB
Posts: 5252
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by MartinB » Wed Dec 04, 2019 3:41 pm

If your Beeb has a 177x FDC and you're handy with a soldering iron, you can build a little two chip project which will allow you to use HD 3.5" floppies which are still abundant and freely available.... :)

evilcraftknife
Posts: 3
Joined: Sat Nov 30, 2019 2:27 pm
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by evilcraftknife » Thu Dec 05, 2019 9:37 am

jms2 wrote:
Tue Dec 03, 2019 6:05 pm
Ricardo wrote:
Tue Dec 03, 2019 2:24 pm
If you have a working Beeb with monitor and disk drive then as an initial learning tool to get into 6502 I would keep it simple and write some code using BBC Basic on the Beeb as its got a nice built in 6502 assembler. The Advanced User Guide is the book you really need (the black/blue/yellow one).
I think this is a really good point - for the initial learning stage you should really use the Beeb (or an emulator).
Thanks for the reply and I get what you're saying but my eyes aren't what they used to be and using a portable TV set from the 80s as a monitor is far from ideal.

User avatar
BigEd
Posts: 2691
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by BigEd » Thu Dec 05, 2019 9:59 am

If you want to use a CRT for retro authenticity, look for a TAXAN or KAGA 12" green-screen monitor, that's really clear.

But an LCD display, driven preferably from the RGB out, should be pretty clear.

User avatar
jms2
Posts: 2313
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by jms2 » Thu Dec 05, 2019 12:18 pm

You could always use an emulator. The point is that for very small test programs you avoid any fiddling about with getting the code from the PC side into the BBC.

User avatar
1024MAK
Posts: 9393
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by 1024MAK » Thu Dec 05, 2019 12:28 pm

BigEd wrote:
Thu Dec 05, 2019 9:59 am
But an LCD display, driven preferably from the RGB out, should be pretty clear.
Good quality monochrome CRT displays (monitors) or LCD TVs connected via the composite video BNC connector (as long as the computer has not been modified to add colour to this output) should also provide a nice clear image in MODEs 0 to 6. MODE 7 should also be okay (slightly increased possibility of vertical flicker on a CRT due to the interlace).

Standard resolution colour CRT TVs and monitors are of limited use in the 80 column MODEs, even when connected via RGB or monochrome composite video due to the pitch of the shadow mask and size of the three different coloured phosphors.

Mark

User avatar
BigEd
Posts: 2691
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: 6502 Assembly on BBC B, what do I need?

Post by BigEd » Thu Dec 05, 2019 12:30 pm

I've relatively often used a Beeb headless - there's just a couple of things to type in blindly at boot which redirects input from the serial port. Once that's done, you can type at the command line over serial, including setting up the redirection of output to the serial port. Here are my notes, which apply to a 19200 connection - if you connect (initially) at 9600 you only need to type a single line at the Beeb's keyboard:
On boot, from the keyboard, at minimum we must set the baud rate:
*fx7,8
and then direct the input from serial:
*fx2,1

Then from the serial session we set the output speed:
*fx8,8
and send output to serial:
*fx3,5
and set escape handling:
*fx181
and set an early stop-sending to prevent overrun:
*FX 203,50,0

Post Reply