Author |
Topic: Sad :( (Read 1048 times) |
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Sad :(
« Reply #3 on: Sep 4th, 2015, 12:53pm » |
|
on Sep 3rd, 2015, 9:04pm, Monkfish wrote:| In the old days I used to use Basic plus Assembly code for routines I needed to go really fast. Is that still possible? |
|
It's possible, with care, but I wouldn't say it's easy! Here's a program which uses some embedded assembler code; it can output over a million digits of PI (you would need to adapt it to write the output to a file to see that much):
Code: ' Program to output digits of PI
input "Enter number of digits required (multiple of 4): "; ndigits
m = int(ndigits / 4) * 14 or 0
!DIM P% 100, B%(m) : B%() = 20 : [OPT 2
!.pidig mov ebx,^B%(0) : mov ecx,[^c] : xor edx,edx : lea ebp,[ecx*2-1]
!.pi1 imul edx,ecx : mov eax,[ebx+ecx*4] : imul eax,100 : add eax,edx
!cdq : div ebp : mov [ebx+ecx*4],edx : mov edx,eax : sub ebp,2 : loop pi1
!mov eax,edx : ret :]
e = 0
l = 2
for c = m to 14 step -7
!d = USR(pidig)
select case
case d = 99: e = e * 100 + d : l += 2
case c = m: print int(d / 100) / 10; : e = d mod 100
case else:
print right$("00000000000";(e + int(d / 100)), l);
e = d MOD 100 : l = 2
end select
next
end Richard.
|
|
|
|
Monkfish
Full Member
member is offline


Gender: 
Posts: 104
|
 |
Re: Sad :(
« Reply #4 on: Sep 4th, 2015, 1:34pm » |
|
Thank you
|
| « Last Edit: Sep 4th, 2015, 1:35pm by Monkfish » |
Logged
|
|
|
|
Monkfish
Full Member
member is offline


Gender: 
Posts: 104
|
 |
Re: Sad :(
« Reply #5 on: Sep 4th, 2015, 7:17pm » |
|
If I want to use assembly in my LBB programs it looks like I will need to understand BBC Basic. Should I buy a copy of BBC Basic? I'm quite happy to do so, especially if you get the money
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Sad :(
« Reply #6 on: Sep 4th, 2015, 8:20pm » |
|
on Sep 4th, 2015, 7:17pm, Monkfish wrote:| If I want to use assembly in my LBB programs it looks like I will need to understand BBC Basic. Should I buy a copy of BBC Basic? |
|
I don't recommend it (and I certainly don't need the money). Download the free trial version if you want to, but really all you should need is the assembler documentation which is available online here.
Are you already reasonably familiar with IA-32 (x86) assembly language? If you are, the BBC BASIC assembler won't hold any surprises - the syntax it uses is very similar to others (more so to NASM than to MASM). If you aren't, then learning to code in assembly language will be far more important than knowing anything about BBC BASIC!
The power of having the assembler itself available at run-time, as it is in BBC BASIC (and LBB), is often not appreciated because it's so unusual. For example it allows you to code values known only at run time as 'constants' rather than 'variables', and thereby achieve a performance boost not normally available. It also allows code to be relocated to an address known only at run time, without the complication of a linker.
Richard.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline


Gender: 
Posts: 104
|
 |
Re: Sad :(
« Reply #7 on: Sep 4th, 2015, 9:25pm » |
|
Looks like I've got some study ahead. I only programmed assembly on 6502... Lol
I never want to do anything too demanding. Normally just fast data manipulations.... bit wise stuff.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Sad :(
« Reply #8 on: Sep 5th, 2015, 3:08pm » |
|
on Sep 4th, 2015, 9:25pm, Monkfish wrote:| Looks like I've got some study ahead. I only programmed assembly on 6502... Lol. |
|
That's not such a terrible background. The 8080/Z80 (which were my introduction to assembly language programming) would probably have been better, but at least the 6502 is little-endian and has a conventional stack.
You may be amused to learn that BBC BASIC for Windows still contains a residue of its 6502 ancestry. To read the 'dot pattern' of a character (assumed to be an 8 x 8 matrix, which it was on the BBC Microcomputer) you allocate an 8-byte block of memory and call an 'OS' routine. The character code is passed in the A% variable, the least-significant byte of the memory address in the X% variable and the most-significant byte of the memory address in the Y% variable; these correspond directly to the A, X and Y registers of the 6502! 
Richard.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline


Gender: 
Posts: 104
|
 |
Re: Sad :(
« Reply #9 on: Sep 5th, 2015, 5:58pm » |
|
Nice to know that despite the intervening years some links to the past still remain. The modern I.T. world must be riddled with artefacts like that.
|
|
Logged
|
|
|
|
|