how to assemble and link:
nasm -f elf32 -o <filename>.o <filename>.asm
ld -m elf_i386 -o <filename> <filename>.o
template code (hello world):
section .text
global _start
How to compile AT&T assembly syntax to binary (not as an ELF file) using GNU GAS assembler as
;; File example.s (MUST end in '.s' otherwise GAS assembler 'as' won't recognize)
.code32 ;; Not needed, still must compile asm w/ the 32 bit options regardless.
;; Only included as a reminder that this is 32 bit binary code.
.global _start
main ()
{
/* Are we little or big endian? Originally from Harbison and Steele. */
union {
long l;
char c[sizeof (long)];
} u;
u.l = 1;
exit (u.c[sizeof (long) -1] == 1);
Emacs isn't just an editor, it’s an entire Emacs Lisp interpreter and environment. We can use Emacs Lisp not only to extend and customize our beloved editor, but also to write entire programs and applications. Nic Ferrier’s [elnode][] server is the most ambitious Emacs Lisp application of this sort, but we can start at a smaller scale and try to write our shell scripts and tools with Emacs Lisp.
However, it turns out that writing programs in Emacs Lisp is more intricate than it looks at a first glance. Emacs decades-long history as interactive application have left deep marks in Emacs and Emacs Lisp, which make independent
#include "stdio.h" | |
#include "stdlib.h" | |
#include "string.h" | |
#include "stdint.h" | |
void print_bits(uintmax_t number) | |
{ | |
unsigned char* output = calloc (8*sizeof (uintmax_t), 1); | |
unsigned char* mov = output; |
Sets up clean organization inside user-emacs-directory
with a separate custom.el
file, a backup directory and a settings.org
file for a more literate emacs configuration that can be built upon.
Note that you may need to ”touch
” some of the initial files so no error appears on startup.
;; do not use `init.el` for `custom-*` code - use `custom-file.el`.
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
define endian=big;
define space ram type=ram_space size=4 default;
define space register type=register_space size=4;
define register offset=0 size=1 [ r0 r1 ];
define token instr(8)
op=(0,0) reg=(1,1) mode=(2,2) imm=(3,3)
;
attach variables [ reg ] [ r0 r1 ];
# This is David A. Wheeler's template for configure.ac, showing | |
# taken from https://dwheeler.com/autotools/ | |
# some suggested options and setups. | |
# Process this file with autoconf to produce a configure script. | |
# Initialize autoconf. | |
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS], | |
[TAR-NAME], [URL]) | |
# Force autoconf to be at least this version number: |