if you make me mad, i will

on-topic Acorn-related news and discussions not covered by the other forums
User avatar
hoglet
Posts: 6369
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: if you make me mad, i will

Postby hoglet » Tue Oct 10, 2017 3:31 pm

danielj wrote:(of which there are 2000 every second)!

Actually 2,000,000 every second!

crj
Posts: 145
Joined: Thu May 02, 2013 4:58 pm

Re: if you make me mad, i will

Postby crj » Tue Oct 10, 2017 3:43 pm

Who said anything about more concise?

Personally, though, I'd do:

Code: Select all

OSWRCH=&FFEE
DIM code 256
FOR A = 0 to 3 STEP 3
P%=code
[ OPT A
  LDX #end-start
.loop
  LDA start-1,X
  JSR OSWRCH
  DEX
  BNE loop
  RTS
.start
  EQUB 10
  EQUB 13
  EQUS "!dlroW ,olleH"
.end
]
NEXT


That's a little more concise, a little quicker and probably also a better illustration of how machine code works. The "start-1" and the string being stored reversed are the two slightly fiddly aspects.

To be clear: machine code is the collection of bytes the 6502 actually executes, the absolute lowest level software you can write on a BBC Micro. Assembly language is an at least slightly human-readable representation of that machine code.

When you run that BASIC program, it assembles a bit of machine code. You can CALL it immediately, but you could also store it away somewhere for later execution. The BASIC program is only needed to assemble it; you don't need it when you're running the machine code. You could, for example, assemble a sideways ROM, blow it into an EPROM, plug it into the computer then power-cycle.

So the assmbly code is verbose. But it produces 12 bytes of machine code, plus the string.

If, in BASIC, you write:

Code: Select all

10 PRINT "Hello, World!"

...that takes up 3 bytes for the line, 1 for PRINT, 1 for the space after PRINT, 2 for the open and close quotes. So 7 bytes. 12 bytes is still more than 7 bytes, but gives a rather more realistic impression of how relatively concise BASIC and machine code are.

In this particular case, the vast majority of the time is taken up in OSWRCH, the operating system code that displays a character on the screen. Whether it's called directly from machine code or indirectly by the BASIC interpreter. So don't expect the machine code to be much quicker. For a great many operations (including, for example, actually looking up the shape of the letter 'H', remembering which screen mode you're in, where the cursor is and what the current colours are, then printing that 'H' in red text on a blue background at position (4,2) in MODE 2) machine code will be many times faster than BASIC.

Plus it doesn't need the BASIC in order to run. This is especially important if what you're trying to write is the BASIC interpreter. (-8

Commie_User
Posts: 869
Joined: Wed Jan 27, 2016 12:50 am

Re: if you make me mad, i will

Postby Commie_User » Tue Oct 10, 2017 3:57 pm

I suppose it depends how serious you want to do it. (Or more exact, how serious I want to do it.)

I found my level in the past with BASIC compilers, though success was variable trying them on Commodore BASIC games apparently not meant to be compiled. They seemed to have a mixture of BASIC and machine code, which I understand the BBC does, as the games had proper graphics and they moved properly. Walls of DATA statements can fuel that task on the 64, I gather.

Though for my simple efforts, the latest QBASIC I found and BBC BASIC FOR WINDOWS suited the jobs I wanted to do on a PC for novelties and frolics. Pity the Commodore emulator hasn't got one.

User avatar
danielj
Posts: 5136
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester

Re: if you make me mad, i will

Postby danielj » Tue Oct 10, 2017 4:30 pm

hoglet wrote:
danielj wrote:(of which there are 2000 every second)!

Actually 2,000,000 every second!


Too right. I always kilo my megas... :oops:

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

Re: if you make me mad, i will

Postby tricky » Wed Oct 11, 2017 11:17 am

Having the assembler built in was what really drew me to the beeb and as you say, makes mixing ASM and BASIC easier.

I haven't read the full list of requirements from the BBC, but having a built in assembler makes sense for getting the country programming.

Commodore
Posts: 93
Joined: Wed Sep 20, 2017 4:56 pm

Re: if you make me mad, i will

Postby Commodore » Wed Oct 11, 2017 11:42 am

Ok, thanks everybody. I'll have a proper look at this later, and may even try it.

I must admit, at the moment though, it looks more like a magic spell than anything I can understand!

Commie_User
Posts: 869
Joined: Wed Jan 27, 2016 12:50 am

Re: if you make me mad, i will

Postby Commie_User » Wed Oct 11, 2017 12:12 pm

Too right!

I'm now having trouble working out how anybody would program anything via the 'monitor' on the Action Replay for the C64, along with the machine code monitor... or whatever all this (mostly) garbled mess was called.

SDC10136.JPG


All I know is that I could change a game's scrolling text with it to screendump the font. At least you could just put 'Hello' straight in there!



Normal machine code monitor:

Image

duikkie
Posts: 2658
Joined: Fri Feb 07, 2014 3:28 pm

Re: if you make me mad, i will

Postby duikkie » Wed Oct 11, 2017 5:47 pm

You are at the wrong forum :)

This is acorn no commodore

With acorn computers you use exmon :)

So simple put away that strange machine
And joint the club with better stucture

Commodore is a playing computer

Acorn is a learning computer :)

Commodore
Posts: 93
Joined: Wed Sep 20, 2017 4:56 pm

Re: if you make me mad, i will

Postby Commodore » Wed Oct 11, 2017 5:56 pm

duikkie wrote:You are at the wrong forum :)

This is acorn no commodore

With acorn computers you use exmon :)

So simple put away that strange machine
And joint the club with better stucture

Commodore is a playing computer

Acorn is a learning computer :)


I think this is the truth.

User avatar
sweh
Posts: 1833
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: if you make me mad, i will

Postby sweh » Thu Oct 12, 2017 12:57 am

tricky wrote:Having the assembler built in was what really drew me to the beeb and as you say, makes mixing ASM and BASIC easier.

That was the reason I wanted a Beeb instead of a C64 for Christmas; that built-in assembler :-)
Rgds
Stephen

User avatar
yellowpig
Posts: 11
Joined: Sat Apr 08, 2006 6:28 pm
Location: Nottingham, UK
Contact:

Re: if you make me mad, i will

Postby yellowpig » Thu Oct 12, 2017 6:11 pm

Assembler is fun to learn, and the Beeb is a particularly convenient machine to learn on.

However, you have to start slowly, and accept that you may have to put in a lot of effort to do not very much, at least to begin with.

There are some concepts that you need to get your head round - obvious for those who have been doing this stuff for some time, but I can still remember that when I first tried using assembler (over 45 years ago now, on a DEC PDP8, not a Beeb) I found it confusing.

You need to separate in your mind "Assembler" from "Machine code". The computer runs machine code - it is very concise and very quick. However, machine code is practically unreadable by humans, so you need something else to create it. That is called "Assembler". When you run a piece of Assembler, all that happens is that it creates a piece of machine code. (On the Beeb you specify where the machine code is created using the P% variable.) Having created the machine code, you can then CALL it directly (or use the USR instruction), or alternatively save it as a machine-code program which you can later *RUN.

David

Commodore
Posts: 93
Joined: Wed Sep 20, 2017 4:56 pm

Re: if you make me mad, i will

Postby Commodore » Thu Oct 12, 2017 8:08 pm

For the first time, I think I understood something about Assembly language, thank you.

So the Beeb had a built in assembler, on Commodore machines, people had to write their own, or maybe use a propriety one (if they were available). Probably the same with Sinclair too. I can see why the Beeb was the tool of choice for schools/colleges and computer boffins generally then.

User avatar
davidb
Posts: 1831
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: if you make me mad, i will

Postby davidb » Thu Oct 12, 2017 9:35 pm

It would be interesting to see an Acorn-specific version of Easy 6502 that uses the MOS VDU routines for printing characters, changing colours, accepting input and so on.


Return to “general”

Who is online

Users browsing this forum: tricky and 2 guests