English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 06 November 2021, 16:21   #1
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
BTST.B with memory

Just a quick sanity check. I'm disassembling parts of RSI MegaDemo and it contains this small function, that the author clearly intended to wait for the blitter to be finished (it's called before blitter registers are updated):
Code:
00000a6e 0839 000e 00df f002      btst.b #$000e,$00dff002
00000a76 66f6                     bne.b #$f6 == $00000a6e
00000a78 4e75                     rts
It actually checks BLTEN though, and things just happen to work regardless, right?


(The copper isn't touching any blitter registers/dmacon, so it doesn't look like a "clever" way to synchronize with that).
paraj is offline  
Old 06 November 2021, 16:34   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Only 3 bottom bits are used if <ea> is memory (so bit 6 is tested), so it checks bit 6 of $002.b, which is bit 14 of $002.w = bltbusy.
a/b is offline  
Old 06 November 2021, 16:38   #3
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
The bit number is encoded correctly by the Assembler. BTST memory accesses are 8-bit (.b). When the CPU encounters the $000e bit number, it ANDs it with 7.

Because of this, bit 6 is tested whether or not the bit number in the instruction is $e or $6.
Photon is offline  
Old 06 November 2021, 17:05   #4
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
Doh, thanks guys, too much work on little endian systems has corrupted me it seems
paraj is offline  
Old 14 November 2021, 17:45   #5
Rock'n Roll
German Translator
 
Rock'n Roll's Avatar
 
Join Date: Aug 2018
Location: Drübeck / Germany
Age: 49
Posts: 183
not btst.b, but bset.b with memory (test a bit and set)

I wondered how bset.b d2,(a0,d0.w) works.
where a0 is the bitplane, d0 is the offset byte to a
byte in the bitplane and d2 is a bit in that byte. (plot a point routine)

I found:
If a memory location is the destination, a byte is
read from that location, the bit operation performed using bit
number modulo 8, and the byte written back to the location.

e.g. d2.b=$fd

Code:
>?$fd
0x000000FD = %00000000000000000000000011111101 = 253 = 253
>?253/8
0x0000001F = %00000000000000000000000000011111 = 31 = 31
>?8*31
0x000000F8 = %00000000000000000000000011111000 = 248 = 248
>?253-248
0x00000005 = %00000000000000000000000000000101 = 5 = 5
>m ra0 1 ; where bit 5 is set	
0006EF80 2000 0000 0000 0000 0000 0000 0000 0000   ...............	
>? $20	 ; Bit 5	
0x00000020 = %00000000000000000000000000100000 = 32 = 32
very special...
I asked me, are there other interesting uses for this kind of bset with memory?
Rock'n Roll is offline  
Old 22 November 2021, 15:23   #6
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
All four bit operations to memory are byte-size.

bclr, bchg, and bset have a built-in btst, and can therefore be used for any kind of polling.
Photon is offline  
Old 22 November 2021, 21:23   #7
redblade
Zone Friend
 
redblade's Avatar
 
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,127
@paraj: This also puzzled me as I saw different calls on different example sources. I managed to find a post on amiga.org by Piru which explained it and then it made sense especially because btst.b #14,$dff002 used to bring up error on Devpac 3. I think it was accepted in Devpac 2.
redblade is offline  
Old 23 November 2021, 18:42   #8
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
Quote:
Originally Posted by redblade View Post
@paraj: This also puzzled me as I saw different calls on different example sources. I managed to find a post on amiga.org by Piru which explained it and then it made sense especially because btst.b #14,$dff002 used to bring up error on Devpac 3. I think it was accepted in Devpac 2.

Ah, makes sense. I guess it's technically "fine" and does what the author intended here. It just set off my code smell detector due to the "unconventional" encoding, and because I've been bitten by doing e.g.
BTST #INTB_VERTB, intreqr(a6)
.
paraj is offline  
Old 23 November 2021, 23:43   #9
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
All my old amiga code had btst #14 for blitwait. I got it from the Amiga System Programmer guide examples as I suspect many of us did - all the "BBUSY Test" commented lines were btst #14. Didn't realise it was wrong for a long time.
Antiriad_UK is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory watch point on blitter writing to memory? mcgeezer support.WinUAE 12 26 June 2019 22:12
WinUAE 3.2.1. memory dump for fake fast memory areas broken StingRay support.WinUAE 1 14 December 2015 20:39
Virtual Memory or Memory Compactor Leandro Jardim support.Apps 2 29 May 2012 23:12
Blizzard Turbo Memory - SMD memory chips doesn't work sanjyuubi Hardware mods 5 26 May 2010 15:40
[68000 ASM] Move memory to memory AmigaBoy Coders. General 7 08 December 2009 08:16

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:11.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07822 seconds with 13 queries