Page 1 of 1

Assembly Language eMagazine. Issue 8 now available.

Posted: Wed Jan 13, 2021 2:57 pm
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.

Re: Assembly Language eMagazine. Issue 8 now available.

Posted: Wed Jan 13, 2021 3:57 pm
by Derek_Stewart
Hi Norm,

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

Re: Assembly Language eMagazine. Issue 8 now available.

Posted: Wed Jan 13, 2021 4:10 pm
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.

Re: Assembly Language eMagazine. Issue 8 now available.

Posted: Fri Jan 15, 2021 8:10 pm
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.

Re: Assembly Language eMagazine. Issue 8 now available.

Posted: Sat Jan 16, 2021 3:09 pm
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:

Re: Assembly Language eMagazine. Issue 8 now available.

Posted: Sat Jan 16, 2021 3:35 pm
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.

Re: Assembly Language eMagazine. Issue 8 now available.

Posted: Sat Jan 16, 2021 4:07 pm
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.