From: "Michael Chapman" <Michael.Chapman@synopsys.com>
To: <cgen@sources.redhat.com>
Subject: Disassembly of instruction with 4 bit opcode
Date: Mon, 04 Nov 2002 04:23:00 -0000 [thread overview]
Message-ID: <NEBBIAJILEHBJOLKLAGOAECICJAA.michaelc@synopsys.com> (raw)
I have now got the assembler working. However I still have a
little problem with disassembly which I do not understand.
The problem is with the "call" instructions which use only 4 bits
of the opcode using the remained for the address. Everything is
strictly little endian with the opcode always appearing in the
least significant 8 bits (or 4 bits in the case of call) of the
instruction.
When I dissassemble the following (listing output from the
assembler)
Dw32 GAS test1.asm page 1
1
2 0000 06100010 start: mov r1, #0x1000
3
4 0004 06302800 mov r3, #low(msg)
5 0008 56230000 l1: ldsb r2, (r3)0x0
6 000c 4120 cmp r2, #0
7 000e 8A0B beq finish
8 0010 CC000000 call putc
9 0014 2131 add r3, #1
10 0016 FAF8 bra l1
11
12 0018 A62000F0 putc: st r2, (r0)0xf000
13 001c 0620FFFF mov r2, #0xffff
I get
$ od -d test1.o
test1.o: file format elf32-dw32
Disassembly of section .text:
00000000 <start>:
0: 06 10 00 10 mov r1,#0x1000
4: 06 30 30 00 mov r3,#0x30
00000008 <l1>:
8: 56 23 00 00 ldsb r2,(r3)0x0
c: 41 20 cmp r2,#0x0
e: 8a 0f beq.s 2e <finish>
10: cc 00 *unknown*
12: 00 00 mov r0,r0
14: 21 31 add r3,#0x1
16: fa f8 bra.s 8 <l1>
00000018 <putc>:
18: a6 20 00 f0 st r2,(r0)0xf000
1c: 06 20 ff ff mov r2,#0xffff
The relevant bits of my cgen .cpu file are
(define-arch
(name dw32)
(comment "DW32")
(insn-lsb0? #t)
(machs dw32)
(isas dw32)
)
\f
; Attributes
\f
; Instruction set parameters.
(define-isa
; Name of the ISA.
(name dw32)
(comment "Basic DW32 instruction set")
; (Size of unknown instructions)
(default-insn-word-bitsize 16)
; Shortest instruction is 16 bits
(default-insn-bitsize 32)
(base-insn-bitsize 32)
)
\f
; CPU family definitions.
(define-cpu
; CPU names must be distinct from the architecture name and machine names.
; The "b" suffix stands for "base" and is the convention.
; The "f" suffix stands for "family" and is the convention.
(name dw32bf)
(comment "DW32 generic cpu")
(endian little)
(word-bitsize 32)
)
; Opcode fields
(dnf f-opcode "opcode" () 7 8)
(dnf f-call-opcode "call opcode" () 3 4)
; absolute, 28-bit (shifted 1 bit to right)
(df f-abs28 "abs28" (ABS-ADDR)
31 28 UINT
((value pc) (sra WI value (const 1)))
((value pc) (sll WI value (const 1))))
(dni call-abs28 "call abs28"
(UNCOND-CTI)
"call $abs28"
(+ (f-call-opcode #xc) abs28)
(set pc abs28)
()
)
Any ideas as to what my problem is?
Thanks for any help,
Mike Chapman
next reply other threads:[~2002-11-04 12:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-04 4:23 Michael Chapman [this message]
2002-11-04 4:42 ` Ben Elliston
2002-11-04 6:24 ` Michael Chapman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=NEBBIAJILEHBJOLKLAGOAECICJAA.michaelc@synopsys.com \
--to=michael.chapman@synopsys.com \
--cc=cgen@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).