06 November 2021, 16:21 | #1 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,099
|
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 (The copper isn't touching any blitter registers/dmacon, so it doesn't look like a "clever" way to synchronize with that). |
06 November 2021, 16:34 | #2 |
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.
|
06 November 2021, 16:38 | #3 |
Moderator
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. |
06 November 2021, 17:05 | #4 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,099
|
Doh, thanks guys, too much work on little endian systems has corrupted me it seems
|
14 November 2021, 17:45 | #5 |
German Translator
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 I asked me, are there other interesting uses for this kind of bset with memory? |
22 November 2021, 15:23 | #6 |
Moderator
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. |
22 November 2021, 21:23 | #7 |
Zone Friend
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.
|
23 November 2021, 18:42 | #8 | |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,099
|
Quote:
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). |
|
23 November 2021, 23:43 | #9 |
OCS forever!
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.
|
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 |
|
|