Assembly eMagazine - What do you want to read about?

Anything QL Software or Programming Related.
User avatar
NormanDunbar
Forum Moderator
Posts: 2457
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Assembly eMagazine - What do you want to read about?

Post by NormanDunbar »

Right then, I have managed to get a couple of sections written (or contributed -- thanks Tofro) for issue 13 of the somewhat irregular Assembly Language eMagazine. I have written a brief introduction to configuration for Beginners' Corner, and Tofro has submitted an article on Sine Functions to generate images and animations very similar to his forum avatar.

What subjects would you like to read about and/or learn about in the magazine? Any suggestions that I'm familiar with will be seriously considered, otherwise, there will be another huge delay!

I also have an article started -- it's in the fooling around and finding out stage -- on the DBAS database system which I've only ever used from C68. The Quanta Library Guide conversion from Archive to DBAS was my application way way back in July 1992! (Is it still being used I wonder?)

Ok, enough waffle, let me know what you want to see in the eMagazine. Thanks.


Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
martyn_hill
QL Wafer Drive
Posts: 1062
Joined: Sat Oct 25, 2014 9:53 am

Re: Assembly eMagazine - What do you want to read about?

Post by martyn_hill »

Hi Norm!

A topic I still to this day struggle-with is the concept of 'SECTION's, relocatable directives, when I can and can't use DS blocks, LINKing and related features of QMAC and similar assemblers.

I also get confused from time to time with when to use LEA vs MOVEA, as well trying to remember the logic for signed/unsigned BRAnches after arithmetic or TST. I typically get it right, but I always second-guess myself...

If these topics have already been covered in one of your previous issues, please send me there :-)

M.


User avatar
NormanDunbar
Forum Moderator
Posts: 2457
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Assembly eMagazine - What do you want to read about?

Post by NormanDunbar »

I don't use QMAC so much these days, but I'll see what I can do on sections etc.

Regarding signed and unsigned comparisons and condition codes, issue 12 has this covered, I'm sure, in Beginners' Corner. (Attached.)

Assembly_Language_012.pdf
(564.33 KiB) Downloaded 35 times

LEA loads the address register with the address of a label in your code.

MOVEA loads a value into the address register.

But I will cover those. They are covered in the eBook I created from the years of articles in QL Today. Which is also attached.

AssemblyLanguage.pdf
(1.75 MiB) Downloaded 30 times

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
XorA
Site Admin
Posts: 1609
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: Assembly eMagazine - What do you want to read about?

Post by XorA »

From the Q-Liberator thread, it seems an article on how to properly flush caches is needed :-D


martyn_hill
QL Wafer Drive
Posts: 1062
Joined: Sat Oct 25, 2014 9:53 am

Re: Assembly eMagazine - What do you want to read about?

Post by martyn_hill »

Thank you Norm!

On the LEA vs MOVEA question, is there a difference between:

Code: Select all

addr_label    EQU    $28000
      LEA    addr_label,a0
versus:

Code: Select all

addr_label    EQU    $28000
      MOVEA.L    #addr_label,a0


User avatar
NormanDunbar
Forum Moderator
Posts: 2457
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Assembly eMagazine - What do you want to read about?

Post by NormanDunbar »

Edited as I didn't read your reply properly! My bad!

LEA will load the address of the label relative to the program counter. As Tofro pointed out, there's a "silent" (pc) added to the LEA to giv us "lea address(pc),...".

MOVEA will load the register with the absolute value $20000. You had a '#' in front which I didn't notice earlier, sorry. Also, if the size of the MOVEA is word, then the 16 bit value loaded into the register will be sign extended to 32 bits by copying bit 15 through all the bits 16--31.

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
NormanDunbar
Forum Moderator
Posts: 2457
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: Assembly eMagazine - What do you want to read about?

Post by NormanDunbar »

XorA wrote: Fri Jan 24, 2025 7:17 pm From the Q-Liberator thread, it seems an article on how to properly flush caches is needed :-D
I'm following that thread, but I know bugger all about the cache unfortunately.

:(

Cheers,
Norm


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
tofro
Font of All Knowledge
Posts: 3057
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Assembly eMagazine - What do you want to read about?

Post by tofro »

martyn_hill wrote: Fri Jan 24, 2025 8:04 pm Thank you Norm!

On the LEA vs MOVEA question, is there a difference between:

Code: Select all

addr_label    EQU    $28000
      LEA    addr_label,a0
versus:

Code: Select all

addr_label    EQU    $28000
      MOVEA.L    #addr_label,a0

Actually, that's a bit of a tricky one because it depends on what you have told your assembler to do:
For that example, if your code is in a SECTION on most QL assemblers, your code examples actually will assemble as

Code: Select all

Addr_label:
	LEA addr_label(pc),a0.          ; and
	MOVE.L #addr_label,a0
	
And for the second instruction, you will get a warning "Run-time relocation is needed for this expression".

That is because QL assembly programs tend to be PC-relative (first instruction) and fully relocatable (that is why you get a warning for the second one, because the assembler can't know the absolute address of addr_label - That would only be known after the program is loaded). For the first instruction, the assembler silently adds a "(pc)" to the instruction to make the reference relative to the instruction counter. And because now your code can run anywhere in memory without relocation, you don't get a warning. For the second instruction, it cannot do that (because "#addr_label(pc)" is an operand that doesn't exist in Motorola assembly).

If you add an "ORG $10000" somewhere before these instructions to locate your code to $10000, the assembler will not warn you in any way (because with the ORG you've told it you don't want PC-relative code), the two instructions will effectively do the same thing (load a0 with $10000), but will not produce a very useful QL program (Because it needs to be loaded to a fixed address which is not supported by QDOS outside ROMs very well.).

In your example, you have told the assembler the absolute address of addr_label with an EQU. Thus, both instructions will load a0 with $28000.
Last edited by tofro on Fri Jan 24, 2025 8:48 pm, edited 1 time in total.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
pjw
QL Wafer Drive
Posts: 1607
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Assembly eMagazine - What do you want to read about?

Post by pjw »

martyn_hill wrote: Fri Jan 24, 2025 8:04 pm Thank you Norm!

On the LEA vs MOVEA question, is there a difference between:

Code: Select all

addr_label    EQU    $28000
      LEA    addr_label,a0
versus:

Code: Select all

addr_label    EQU    $28000
      MOVEA.L    #addr_label,a0
Except that to get THAT PARTICULAR address into a0, the only correct way to do it is:

Code: Select all

	moveq #sms.info,d0
	trap #1 	; get pointer to system variables in A0
But you knew that, didnt you? ;) The reason is that it may, in fact, turn out to be another address..


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
User avatar
tofro
Font of All Knowledge
Posts: 3057
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Assembly eMagazine - What do you want to read about?

Post by tofro »

pjw wrote: Fri Jan 24, 2025 8:48 pm
But you knew that, didnt you? ;) The reason is that it may, in fact, turn out to be another address..
That doesn't happen. Ever. :)


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Post Reply