Assembly Language eMagazine. Issue 8 now available.

Anything QL Software or Programming Related.
Post Reply
User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Assembly Language eMagazine. Issue 8 now available.

Post by NormanDunbar »

Greetings everyone. After a delay of a year and a bit, Issue 8 of the irregular eMagazine on QL Assembly Language is now available for download.

This (exciting?) edition covers:
  • Some more UTF8 stuff -- Wolfgang Lenerz has suggested some improvements to the code in Issue 7, and this has been implemented.
  • Reversing the bits in a register.
  • Finding the next power of two.
  • Some stuff on randomisation and generating random integers.
The download is at https://github.com/NormanDunbar/QLAssem ... ag/Issue_8.


Enjoy.


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.
Derek_Stewart
Font of All Knowledge
Posts: 3928
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Assembly Language eMagazine. Issue 8 now available.

Post by Derek_Stewart »

Hi Norm,

Nice magazine, came at the right time, as my interest was waning a little.


Regards,

Derek
User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Assembly Language eMagazine. Issue 8 now available.

Post by NormanDunbar »

Thanks Derek.

Hopefully, the next issue will be a bit sooner! If I can figure out stuff to write about that is. All hints gratefully received everyone!


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: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Assembly Language eMagazine. Issue 8 now available.

Post by NormanDunbar »

B*gger, b*gger, b*gger!

It comes to mind that in one of the comments, in one of the code sections, in Issue 8, there is a glaring bug. The comment describes an operation but the comment is wrong. Can you spot the problem?

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
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Assembly Language eMagazine. Issue 8 now available.

Post by mk79 »

Good that me being a pedantic ass made the cut ;)

Code: Select all

61 move.l   myRandSeed(a6),d0
62 move.w   d0,d4     ; Copy low word LLLL
63 swap     d0        ; LLLL HHHH
64 mulu     #$c12d,d0 ; HHHH * 49453
65 mulu     #$712d,d4 ; LLLL * 28973
66 swap     d0        ; HHHH LLLL
67 clr.w    d0        ; HHHH 0000 (Divide by 65536)
68 add.l    d0,d4     ; I have no idea!!!
59 addq.l   #1,d4     ; New seed
70 move.l   d4,myRandSeed(a6) ; Save seed
Basically what you see here is a simple 32x16 bit multiplication with one change. Normally you multiply both 16-bit halves with the same factor and add the results after shifting back the upper word. So the the clr.w in line 67 is there to remove any overflow, not to divide by 65536. The code is basically

Code: Select all

myRandSeed = myRandSeed * $712d + 1
if it wasn't for the fact that he upper factor is slightly different. I think the real formula is

Code: Select all

myRandSeed = myRandSeed * $712d + ((myRandSeed & $F0000) * $5000) + 1
Not sure why, maybe a typo, maybe to make it more "random" :lol:


User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Assembly Language eMagazine. Issue 8 now available.

Post by NormanDunbar »

Thanks Marcel, you spotted the error and explained what is going on.

Funnily enough, I was just reading about 32 * 24 bit multiplications on Arduino's, in assembly, just last night. I need to get out more!

Much obliged, 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.
User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Assembly Language eMagazine. Issue 8 now available.

Post by NormanDunbar »

I have uploaded a new version of the Issue with Marcel's explanation attached to the chapter of randomisation.

https://github.com/NormanDunbar/QLAssem ... ag/Issue_8

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.
Post Reply