Add articles

This commit is contained in:
Tom Willemse 2014-12-27 21:44:45 +01:00
parent b3c89eda7c
commit 29075fd652
2 changed files with 120 additions and 0 deletions

View file

@ -0,0 +1,89 @@
#+TITLE:
#+STARTUP: showall
* Installing HLA on Archlinux :hla:archlinux:
:PROPERTIES:
:PUBDATE: <2014-12-27 Sat 21:43>
:END:
I recently started reading [[http://www.nostarch.com/assembly2.htm][The Art of Assembly Language, 2nd
Edition]]. It uses High-Level Assembly language in its code examples
and this requires a special compiler, or assembler, to turn your
code into machine code.
** Fixing the PKGBUILD
The compiler, ~hla~, is available on the Archlinux User Repository
[[https://aur.archlinux.org/packages/hla/][here]]. At the time of writing, though, that ~PKGBUILD~ doesn't work
entirely. By default pacman removes all static libraries from the
created packages, which took me a while to find out. Adding the
following line to the ~PKGBUILD~ fixes it:
#+BEGIN_SRC sh
options=(staticlibs)
#+END_SRC
I also placed a comment on the AUR page, but there has been no sign
of acknowledgment so far.
** Running on x86_64
After having installed the compiler I got a lot of errors compiling
my very simple hello world application, as typed over from the
book. The gist of them was that it couldn't create 64-bit
executables, which isn't very surprising as HLA seems to be only
for x86 (32-bit) architecture. Another comment on the AUR page
helped that though. One should add the ~-lmelf_i386~ switch to the
~hla~ command-line. So I put in my =~/.zshrc=:
#+BEGIN_SRC sh
alias hla="hla -lmelf_i386"
#+END_SRC
This discovery only came after a few other attempts to install HLA.
** Alternative: Using Vagrant
Before I'd read about the ~-lmelf_i386~ command-line switch I was
looking at ways to run a 32-bit operating system inside my
Archlinux installation. There are a few options I'm familiar with:
lxc, Docker and Vagrant.
At first I tried to create a 32-bit Archlinux container, but the
installation script failed, so I couldn't get that started. Then I
went on to Vagrant, which worked pretty quickly.
I used the ~ubuntu/trusty32~ box, which can be downloaded by calling:
: vagrant box add ubuntu/trusty32
A very short ~Vagrantfile~:
#+BEGIN_SRC ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty32"
config.vm.provision :shell, path: "vagrant.sh"
end
#+END_SRC
and then the provision in ~vagrant.sh~:
#+BEGIN_SRC sh
wget http://www.plantation-productions.com/Webster/HighLevelAsm/HLAv2.16/linux.hla.tar.gz
tar --directory / --extract --file linux.hla.tar.gz
cat > /etc/profile.d/hla.sh <<EOF
#!/usr/bin/bash
export hlalib=/usr/hla/hlalib
export hlainc=/usr/hla/include
export hlatemp=/tmp
export PATH="${PATH}:/usr/hla"
EOF
#+END_SRC
After that you can just call ~vagrant up~, wait a while and then have
fun playing around with HLA in an Ubuntu 14.04 environment.

View file

@ -0,0 +1,31 @@
#+TITLE:
#+STARTUP: showall
* Stop shr from using background color :emacs:elisp:config:
:PROPERTIES:
:PUBDATE: <2014-04-03 Thu 22:11>
:END:
Here's just one more example why Emacs is so awesome
Reading mail in Gnus is very nice, but shr has become a little too
good at its job. Add to this the many occasions when a background is
specified without specifying a foreground, plus a color theme that
is the inverse of what is usually expected, and you can get
hard-to-read HTML messages, gray foreground and gray background.
I've looked at the other possible renderers, but they don't look
very nice compared to shr. So just remove its ability to add
background colors.
#+BEGIN_SRC emacs-lisp
(defun oni:shr-colorize-remove-last-arg (args)
"If ARGS has more than 3 items, remove the last one."
(if (> (length args) 3)
(butlast args)
args))
(with-eval-after-load 'shr
(advice-add #'shr-colorize-region :filter-args
#'oni:shr-colorize-remove-last-arg))
#+END_SRC