Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: Munchor on December 28, 2010, 10:23:59 am
-
To help me with my disassembler which has lots of instructions working already, but a few not working, I decided to create this post in order to get help, otherwise I'd go :crazy:.
These are my Assembly and Hexadecimal Assembly questions.
QUESTION 1:According to the table here (http://davidgom.co.cc/z80table.html), [22] is:
ld (**),hl
In Assembly I'dd just:
ld (12),hl
But how should I do that in Hexadecimal?
QUESTION 2
ld hl,(**)
The same doubt as above but for [2A].
QUESTION 3
Since I'm coding a Disassembler, how should I handle bytes like [CB], [DD], [ED],[EF]? These link to other tables.
Thanks much for the help!
-
would say for the link to other tables it would be something like:
If (byte==[ab])
{
then do checks for other table
}
-
would say for the link to other tables it would be something like:
If (byte==[ab])
{
then do checks for other table
}
Yeah, I'll probably do that.
But the opcode [CB] is for the BIT Table. How would I know each one IN the other table?
-
not sure, but it appears that * = one byte value and ** = two byte value.
so ld (12), hl would be 22000C right?
edit: or maybe its 220C00, because z80 is little endian.
it'd be a good idea to compile an axe program with:
.TEST
12
and see what comes out with this (http://asmtools.omnimaga.org/)
-
ld (**),hl loads hl into a specific 2 byte address. Generally you would use it like ld (score),hl and that would copy your value in hl into your address with the label score.
$dd (ix) and $fd (iy) always precede $cb (bit) or $ed (ext) if present, followed by the index offset if needed, followed by the instruction. So first you should always check for a $dd or $fd and you would know that you were dealing with an index.
Tomorrow Ill give you the code for my disassembler and that should help you out a bit.
ret = $c9
ld ($9d95),hl = $22 $95 $9d
ld hl,($9d95) = $2a $95 $9d
sbc hl,bc = $ed $42
lbit 1,a,(ix+3) = $dd $cb $03 $4f (this is the way I have the mnemonic set up in my table but the opcode is the same.)
For bit instructions you can just multiply the bit by 8 and add it to the regular opcode.
bit 0,a = $cb $47
bit 1,a = $cb $4f ($47+bit*8 )
-
Thanks much AssemblyBandit. Are you like the Assembly bandit (literally?).
Anyways, my disassembler already has the primary instructions finished and half of the extended instructioons.
It looks like in some opcodes, the numbers are in the middle of it and some of them are in the end, that's wow confusing :S
bit 0,a = $cb $47
bit 1,a = $cb $4f ($47+bit*8 )
EDIT: Thank you Very much for this piece of code. I have finished Extended Instructions and am now including Bit Instructions, then off I go to IX and IY.
New Question...
inc (ix+*)
dec (ix+*)
ld (ix+*),*
How would these be used in Hexadecimal?
res 6,(ix+*),l
This one too xD
Thanks much, probably the last Hexadecimal question for my program :D
-
inc (hl)
$34
inc (ix+3)
$dd $34 $03
dec (hl)
$35
dec (ix+4)
$dd $35 $04
ld (hl),10
$36 $0a
ld (ix+2),10
$dd $36 $02 $0a
^ ^ ^ ^
| | | value to be loaded
| | ix index offset
| actual opcode
ix identifier
Notice youre basically just putting $dd or $fd in front of the equivalent instruction that uses hl and following the opcode with the index offset.
res 0,(ix+1)
$dd $cb $01 $86
^basically just like the other bit instructions, just use the opcode at 0, multiply the bit by 8 and add it to the opcode.
res 6,(ix+1)
$dd $cb $01 $b6
^$86 + 6 * 8 = $b6
One thing thats really useful in a disassembler is having it automatically label rom calls, ram locations, ports, flags, and restarts. Basically just try to have it match any address to one in a rom call table for instructions that use them and do something similar for the ports, ram locations, flags, and restarts.
This is an example of what mine puts into a text file:
0A3E LD A,$06
0A40 OUT ($04),A ;Power Mode Port
0A42 LD A,$11
0A44 OUT ($03),A ;Interrupt Mode Port
0A46 RES 3,(IY+$12) ;?indic,shift flags?
0A4A RES 3,(IY+$09) ;?on flags?
0A4E EX AF,AF'
0A4F EXX
0A50 EI
0A51 HALT
It puts the extra info into comments at the end of the instructions. Note that this is part of the ti-84's rom, but I made the disassembler for the ti-86 and I havent updated any of the tables. (Its still pretty close though.)
-
Woah your assembler even generates comments? O.O This is pretty cool actually. You should make it for the 83+/84+ and post it. :O
-
Woah your assembler even generates comments? O.O This is pretty cool actually. You should make it for the 83+/84+ and post it. :O
You can make comments on mine too :D
In my program, concerning Assembly and program itself (not GUI and extras), all that's left is add BCALLs:
http://brandonw.net/calcstuff/page0.txt (http://brandonw.net/calcstuff/page0.txt)
Any useful advice AssemblyBandit? Your code examples were really good, but I had already figured them out by the time I saw them.
Oh! There's another thing missing: Reading .8xp files data :S
-
Ill edit everything to work with the 83+/84+ but the code is pretty embarrassing, I should have it done by tonight. Ill post some code to read 8xp data in a little bit. I originally used VC++ but I might rewrite it in VB.
-
Cool :D
-
I have wrote this file with lots of BCall's, any idea if these will be enough?