
An IRC Bot in Arm Assembler - wyc
https://github.com/wyc/armbot
======
mattgodbolt
Assembly used to be all the rage. At Uni I couldn't afford a C compiler (and
there were no free versions for my platform, RISC OS) so I ended up writing a
whole IRC Client, GUI and scripting language all in ARM assembler.

A few tattered notes of it at:
[http://xania.org/200711/irbasic](http://xania.org/200711/irbasic) but sadly
most is lost to time.

~~~
pjmlp
I used to follow with joy of a kid that gets new toys, the release of each new
processor and the new set of available opcodes.

Nowadays even C++ is simple, compared to mastering all the opcodes and their
side effects in latest generation processors.

------
makmanalp

      socket_call: .long 281
      connect_call: .long 283
    

How does one get these numbers?

edit:
[https://github.com/wyc/armbot/blob/master/connect.s#L55](https://github.com/wyc/armbot/blob/master/connect.s#L55)

~~~
dima55
Those are linux system call IDs: [http://lxr.free-
electrons.com/source/arch/arm/include/uapi/a...](http://lxr.free-
electrons.com/source/arch/arm/include/uapi/asm/unistd.h#L309)

~~~
makmanalp
Thanks! Reading through the linux source is always funny if nothing else:

/* syscall to call a syscall! _/ [http://lxr.free-
electrons.com/source/arch/arm/include/uapi/a...](http://lxr.free-
electrons.com/source/arch/arm/include/uapi/asm/unistd.h#L141)

/_ 222 for tux */ [http://lxr.free-
electrons.com/source/arch/arm/include/uapi/a...](http://lxr.free-
electrons.com/source/arch/arm/include/uapi/asm/unistd.h#L250)

------
JetSpiegel
Can the mods change the title to ARM Assembly? Case matters, this has nothing
to do with a body part.

------
cturner
Last time I looked, the canonical manuals for the ARM architecture were quite
expensive. If anyone has advice on piecing the basics together please let me
know. I don't know much assembly, am currently playing with 6502 assembly, and
have been writing a 32-bit VM just by working it out as I go.

I do have a set of reference manuals, opportunity purchase, for acorn-era ARM
systems. What sort of consistency would I find between historic ARM
instruction set and the latest 32 and 64 bit versions?

~~~
JoachimSchipper
"ARM Architecture Reference Manual" yields quite a few hits for various ARM
systems, including ARMv8; the Raspberry Pi's ARMv6 instruction set is also
available.

One big change is that modern ARM processors tend to run mostly in Thumb
(16-bit instruction) mode. It's faster, but you lose all the fun condition
codes. High-performance code should take advantage of NEON.

If the above does not answer your question, please ask a more specific one.
;-)

------
cyorir
I see more good asm examples are being devoloped. This is a good, cool start
for connecting to IRC, but it would be even more cool to see the bot do
something beyond looking for a single line. What do you plan to do with it, if
I might ask? Your motivation is listed as "lol" ...

~~~
wyc
Support for modules written in C.

~~~
Alupis
This is truly a arm asm gem :)

------
Zelphyr
I love that I'm seeing more of these little apps written in Assembly on HN.

One request though: would someone be so kind as to take the time to annotate
them so noobs like me can know what's going on? I think these are great ways
to learn Assembly--something I've wanted to do for awhile. I've long felt that
understanding coding at that level would only strengthen my skills in higher-
level languages.

------
markb139
There seems to be a bug in the string compare function. If either string is
empty the function return 0 meaning success.

------
daveloyall
Question. Does this run in Linux on arm? Or does it run on the CPU (be it
hardware or emulated)?

Bonus question: How can I answer that question for myself in the future when
looking at similar source? Said differently: What am I looking at here? :)

~~~
vhost-
Oh my god, it would be so cool if you could boot to this. Raspberry Pi irc
bot. Literally.

~~~
Alupis
He uses Linux sys calls, which means the kernel needs to be there (and a libc
of some sorts)... but that's all that's needed. So, with the RPi, you could
essentially "boot" this code with pretty much a bare-metal system otherwise.

~~~
smorrow
Is Linux considered part of the machine itself now? Jesus.

------
L8D
If you think this is cool, go ahead and check out bfb, an IRC bot written in a
derivative of Brainfuck.

[https://github.com/billiob/bfb](https://github.com/billiob/bfb)

~~~
Alupis
The license the author of the BrainFuck example has chosen (or made up)
actually is pretty restrictive, if not immature.

Software licensing is not a joke.

The author's account on Github seems to have many projects were a license has
been either made up, or adapted. Perhaps out of lack of understanding current
licensing and available licenses.

They could check this site out for some help:
[https://tldrlegal.com/](https://tldrlegal.com/)

If the author intends to allow anyone to use the codebase for anything, they
should choose an existing license that permits this... such as the MIT,
Apache, BSD licenses, etc. Making one up is not an acceptable replacement and
would not hold up in court should it ever come to that. "But judge, the author
said I could do 'WHAT THE FUCK I WANT'!". :(

~~~
lloeki
FAQ #7:

    
    
        >> Can’t you change the wording? It’s inappropriate / childish / not corporate-compliant.
        > 
        > The WTFPL lets you relicense the work under any other license.
    

Also, see FAQ #6 and #8.

[0]: [http://www.wtfpl.net/faq/](http://www.wtfpl.net/faq/)

~~~
Alupis
What stops me from re-licencing under my company's proprietary license, then
suing the original author for copyright? (It appears this "license" allows
implicit re-assignment of copyright).

Not to mention, this "license" was not written by a lawyer, but rather a
software developer. I'm no lawyer, and I'm confident any license I can make up
would be shredded by real lawyers.

Furthermore -- the codebase in question above, does not include the optional
"No Warranty" clause, which means his software implicitly must be fit for
use... and if it breaks something, he can be held liable.

While I agree with the spirit and intent of this license, it really isn't a
real license and is easily mis-used by even those who do wish to treat it as
real.

So, this license appears to be really a joke-license... not a serious one...
and I still maintain the codebase's author should pick a real license if the
intentions are to allow universal use.

~~~
clarry
Relicensing is a weird term and easily leads to confusion. I guess you can
write your own terms and distribute copies under these new terms. But you
cannot revoke the rights the original license has granted to people who have
received the work under that license. Nor can you revoke the original author's
exclusive rights. The license text (which is about _the copying and performing
of the covered work_ ) does not grant you such powers.

~~~
belorn
A license is a permission granted by the author, and an extension of the
authors wishes.

This is why relicensing as a term indeed leads to confusion. People think the
license is inherently a part of the work, and thus can be as readily changed
as the software source itself. It is however not part of the work, but part of
the author. If you want to change the license, you need to get the author to
change his mind.

Some licenses allow people to add new licenses on-top of existing licenses.
That is not re-licensing, but simply the addition of more requirements. If you
remove the original license, you loose the permission needed to use/copy the
work created by the original author.

~~~
clarry
Thanks for expressing it so clearly. I'll quote you when the time comes.

The SFLC had a chance to set this straight in the aftermath of the
inflammatory 2007 episode around the Atheros driver. Instead they dodged the
entire relicensing question and released a set of guidelines which focus on
where and how to preserve the copyright notice, and that rather seems to only
have reinforced the idea that the permissive BSD style licenses are nothing
more than a decorative text you must lug around. So we still have a huge
number of people who think they can do anything (e.g. "relicense") as long as
the decoration is kept in place. It really is a shame.

------
deft
I love assembly, and ARM is pretty neat! Nice work man.

