Assembly Language eMagazine. Issue 8 now available.

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

Assembly Language eMagazine. Issue 8 now available.

Postby NormanDunbar » Wed Jan 13, 2021 2:57 pm

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 - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
Derek_Stewart
Font of All Knowledge
Posts: 2206
Joined: Mon Dec 20, 2010 11:40 am
Location: Runcorn, Cheshire, UK

Re: Assembly Language eMagazine. Issue 8 now available.

Postby Derek_Stewart » Wed Jan 13, 2021 3:57 pm

Hi Norm,

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


Regards,

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

Re: Assembly Language eMagazine. Issue 8 now available.

Postby NormanDunbar » Wed Jan 13, 2021 4:10 pm

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 - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
User avatar
NormanDunbar
Forum Moderator
Posts: 1382
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Assembly Language eMagazine. Issue 8 now available.

Postby NormanDunbar » Fri Jan 15, 2021 8:10 pm

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 - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
User avatar
mk79
Aurora
Posts: 858
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Assembly Language eMagazine. Issue 8 now available.

Postby mk79 » Sat Jan 16, 2021 3:09 pm

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

Re: Assembly Language eMagazine. Issue 8 now available.

Postby NormanDunbar » Sat Jan 16, 2021 3:35 pm

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 - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
User avatar
NormanDunbar
Forum Moderator
Posts: 1382
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Assembly Language eMagazine. Issue 8 now available.

Postby NormanDunbar » Sat Jan 16, 2021 4:07 pm

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 - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890

Who is online

Users browsing this forum: No registered users and 4 guests