Skip to content

Instantly share code, notes, and snippets.

@elnx
Created May 30, 2020 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elnx/a932186a6c4a11e506888aa1ca30f948 to your computer and use it in GitHub Desktop.
Save elnx/a932186a6c4a11e506888aa1ca30f948 to your computer and use it in GitHub Desktop.
GNU as assembler (binutils-2.25) type sizes for x86 and x86_64

TL;DR

Integer types

  • .octa 16 bytes on x86_64 and x86
  • .quad 8 bytes on x86_64 and x86
  • .long and .int 4 bytes on x86_64 and x86
  • .word, .short and .hword 2 bytes on x86_64 and x86
  • .byte is, of course, 1 byte on x86_64 and x86

Floating-point types

  • .tfloat 10 bytes on x86_64 and x86
  • .double 8 bytes on x86_64 and x86
  • .single and .float 4 bytes on x86_64 and x86

Official Docs - Pseudo Ops

.PHONY: info build clean build
DUMMY_FILES = byte.32 byte.64 short.32 short.64 hword.32 hword.64 int.32 int.64 word.32 word.64 long.32 long.64 quad.32 quad.64 octa.32 octa.64 double.32 double.64 single.32 single.64 float.32 float.64 tfloat.32 tfloat.64
DUMMY_BINARIES = byte.32.bin byte.64.bin short.32.bin short.64.bin hword.32.bin hword.64.bin int.32.bin int.64.bin word.32.bin word.64.bin long.32.bin long.64.bin quad.32.bin quad.64.bin octa.32.bin octa.64.bin double.32.bin double.64.bin single.32.bin single.64.bin float.32.bin float.64.bin tfloat.32.bin tfloat.64.bin
info: build
nm -S $(DUMMY_BINARIES)
build: $(DUMMY_BINARIES)
%.64:
sed "s/{{TYPE}}/$$(echo $@ | sed 's/\.64//')/g" < template.64 > $@
%.32:
sed "s/{{TYPE}}/$$(echo $@ | sed 's/\.32//')/g" < template.32 > $@
%.64.bin: %.64
$(AS) --64 -o $@ $^
%.32.bin: %.32
$(AS) --32 -o $@ $^
rebuild: clean build
clean:
rm -f $(DUMMY_FILES) $(DUMMY_BINARIES)
byte.32.bin:
00000000 00000001 t byte32
byte.64.bin:
0000000000000000 0000000000000001 t byte64
short.32.bin:
00000000 00000002 t short32
short.64.bin:
0000000000000000 0000000000000002 t short64
hword.32.bin:
00000000 00000002 t hword32
hword.64.bin:
0000000000000000 0000000000000002 t hword64
int.32.bin:
00000000 00000004 t int32
int.64.bin:
0000000000000000 0000000000000004 t int64
word.32.bin:
00000000 00000002 t word32
word.64.bin:
0000000000000000 0000000000000002 t word64
long.32.bin:
00000000 00000004 t long32
long.64.bin:
0000000000000000 0000000000000004 t long64
quad.32.bin:
00000000 00000008 t quad32
quad.64.bin:
0000000000000000 0000000000000008 t quad64
octa.32.bin:
00000000 00000010 t octa32
octa.64.bin:
0000000000000000 0000000000000010 t octa64
double.32.bin:
00000000 00000008 t double32
double.64.bin:
0000000000000000 0000000000000008 t double64
single.32.bin:
00000000 00000004 t single32
single.64.bin:
0000000000000000 0000000000000004 t single64
float.32.bin:
00000000 00000004 t float32
float.64.bin:
0000000000000000 0000000000000004 t float64
tfloat.32.bin:
00000000 0000000a t tfloat32
tfloat.64.bin:
0000000000000000 000000000000000a t tfloat64
.code32
{{TYPE}}32: .{{TYPE}} 0
.size {{TYPE}}32, . - {{TYPE}}32
.code64
{{TYPE}}64: .{{TYPE}} 0
.size {{TYPE}}64, . - {{TYPE}}64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment