English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 29 September 2009, 17:27   #1
absence
Registered User
 
Join Date: Mar 2009
Location: moon
Posts: 373
Weird instructions

During disassembly I've gotten some invalid opcodes that seem to be BTST or BSET with memory address operand and bit number bigger than 7. Can anyone confirm that the bit number is simply anded by 7 or something?

There's also a read from address $bfe0ff. That's the CIA address range, but those registers end in $000 or $001. Are the extra bits ignored, causing the instruction to read from $bfe001?
absence is offline  
Old 29 September 2009, 17:51   #2
hitchhikr
Registered User
 
Join Date: Jun 2008
Location: somewhere else
Posts: 511
Quote:
During disassembly I've gotten some invalid opcodes that seem to be BTST or BSET with memory address operand and bit number bigger than 7. Can anyone confirm that the bit number is simply anded by 7 or something?
Bit instructions can access to 32 bits ([0..31]) with memory operands so if you got some thing like "btst #????14, $dff002" with resource, it's a bug from resource.

Quote:
There's also a read from address $bfe0ff. That's the CIA address range, but those registers end in $000 or $001. Are the extra bits ignored, causing the instruction to read from $bfe001?
$bfe0ff = bfe001. You're probably getting this from an older program where some wise guy thought it'll be fun to use uncommon addresses range.
hitchhikr is offline  
Old 29 September 2009, 17:53   #3
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Not sure about the CIA address range, but for the single-bit BSET, BCLR, BCHG and BTST with a memory address as destination you are correct.
Leffmann is offline  
Old 29 September 2009, 18:06   #4
hitchhikr
Registered User
 
Join Date: Jun 2008
Location: somewhere else
Posts: 511
Yes, internally it's "anded" by 7.
hitchhikr is offline  
Old 12 October 2009, 16:54   #5
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Quote:
Originally Posted by hitchhikr View Post
Bit instructions can access to 32 bits ([0..31]) with memory operands so if you got some thing like "btst #????14, $dff002" with resource, it's a bug from resource.



$bfe0ff = bfe001. You're probably getting this from an older program where some wise guy thought it'll be fun to use uncommon addresses range.
It's the completely other way around. When accessing a bit in a register, it's modulo 32 (bit number is ANDed with 31), but all memory access is byte-size (bit number is ANDed with 7).

So when a source says "btst #14,$dff002", the coder thinks he's accessing bit 14 of 16 in a word-size custom address. Which in fact he is, as he's accessing bit 6 in the byte at $dff002. Luckily, the bit number was >8, or it wouldn't work

There are actually a whopping 8 bits to store the bit number in the instruction word, so even btst #254,$dff002 should work (if your assembler doesn't say "You shall not pass!") So actually, any disassembler that shows higher numbers than 7 or 31 is showing the truth and hasn't manipulated the instruction words.


This means you can store data in the higher bits, if you feel like a cheeky devil


About the CIA registers, well without looking in HRM, in OCS there's 16 odd and 16 even registers spaced out $100 apart, but I guess any address that fits that description should make the custom chips happy.
Photon 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
Game appears to use weird JSR instructions MethodGit Coders. General 15 18 March 2011 16:26
Modifying instructions from the debugger? AmigaBoy support.WinUAE 1 23 June 2007 15:31
All asm instructions in one .s AGN Coders. General 0 15 September 2006 00:49
Instructions? Daz support.Hardware 8 12 July 2002 20:29
Game Instructions Ricky55 Retrogaming General Discussion 2 06 July 2002 20:10

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 09:16.

Top

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