Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ARM Dis-assembler for GForth

112 views
Skip to first unread message

Brian Fox

unread,
Feb 2, 2023, 9:29:50 PM2/2/23
to
A question came up on Reddit /Forth by a person with an Apple M1.
They tried to use SEE but code words would not dis-assemble.
Is there anyone thinking about making one in Forth?
Could gFoRTH be made to interface to gbd in a workable way?

Asking for a friend.

Anton Ertl

unread,
Feb 3, 2023, 2:17:50 AM2/3/23
to
Gforth has had a gdb-based disassembler since 0.7. Some OSs
(e.g. Ubuntu) by default maim the ptrace system call and disasm-gdb
does not work there. On Ubuntu you can fix this with

sudo echo 0 >/proc/sys/kernel/yama/ptrace_scope

or (after the next reboot) by changing /etc/sysctl.d/10-ptrace.conf

The development version of Gforth also has Forth disassemblers for the
ARM A64 (aka Aarch64) and some 32-bit ARM instruction set:

Here's on a A64 Ubuntu system with the fix above, using gforth-fast in
either case:

Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit
see +
Code +
0x0000aaaae8bfa884 <gforth_engine+3220>: ldr x0, [x23, #8]!
0x0000aaaae8bfa888 <gforth_engine+3224>: add x25, x25, #0x8
0x0000aaaae8bfa88c <gforth_engine+3228>: add x24, x24, x0
0x0000aaaae8bfa890 <gforth_engine+3232>: ldur x2, [x25, #-8]
0x0000aaaae8bfa894 <gforth_engine+3236>: br x2
0x0000aaaae8bfa898 <gforth_engine+3240>: ldur x2, [x25, #-8]
0x0000aaaae8bfa89c <gforth_engine+3244>: br x2
0x0000aaaae8bfa8a0 <gforth_engine+3248>: br x2
0x0000aaaae8bfa8a4 <gforth_engine+3252>: mov x4, x25
0x0000aaaae8bfa8a8 <gforth_engine+3256>: ldr x0, [x4], #8
0x0000aaaae8bfa8ac <gforth_engine+3260>: add x24, x0, x24
0x0000aaaae8bfa8b0 <gforth_engine+3264>: add x25, x4, #0x8
0x0000aaaae8bfa8b4 <gforth_engine+3268>: ldur x2, [x25, #-8]
0x0000aaaae8bfa8b8 <gforth_engine+3272>: br x2
Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled off'.

end-code

Gforth 0.7.9_20230114
...
see +
Code +
AAAAADB6DF70: ldr x0, [x25,#0x8]!
AAAAADB6DF74: add x26, x26, #0x8
AAAAADB6DF78: add x27, x0, x27
AAAAADB6DF7C: ldur x1, [x26,#-0x8]
AAAAADB6DF80: br x1
end-code
ok
' disasm-gdb is discode ok
see +
Code +
0x0000aaaaadb6df70 <gforth_engine+2640>: ldr x0, [x25, #8]!
0x0000aaaaadb6df74 <gforth_engine+2644>: add x26, x26, #0x8
0x0000aaaaadb6df78 <gforth_engine+2648>: add x27, x0, x27
0x0000aaaaadb6df7c <gforth_engine+2652>: ldur x1, [x26, #-8]
0x0000aaaaadb6df80 <gforth_engine+2656>: br x1
Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled off'.

end-code

Development Gforth did not work on MacOS on Apple Silicon last time I
tried it.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2022: https://euro.theforth.net

none albert

unread,
Feb 3, 2023, 6:28:06 AM2/3/23
to
In article <2023Feb...@mips.complang.tuwien.ac.at>,
Anton Ertl <an...@mips.complang.tuwien.ac.at> wrote:
<SNIP>
>Development Gforth did not work on MacOS on Apple Silicon last time I
>tried it.

I heard that the newest apple have a change of type of processor.
Does gforth run on those already?

>
>- anton

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Anton Ertl

unread,
Feb 3, 2023, 7:35:55 AM2/3/23
to
albert@cherry.(none) (albert) writes:
>In article <2023Feb...@mips.complang.tuwien.ac.at>,
>Anton Ertl <an...@mips.complang.tuwien.ac.at> wrote:
><SNIP>
>>Development Gforth did not work on MacOS on Apple Silicon last time I
>>tried it.
>
>I heard that the newest apple have a change of type of processor.

It is unclear what you mean.

>Does gforth run on those already?

Gforth runs on the Apple M1 on Linux without problems. I expect that
it runs on the Apple M2 on Linux, too.

Brian Fox

unread,
Feb 3, 2023, 3:53:09 PM2/3/23
to
Thanks Anton
0 new messages