##Assembly languages are scored by the compiled/assembled size
Assembly languages are scored by the compiled/assembled size
For example, take this x86 program to reverse the bit order of a number:
xor eax, eax inc eax myloop: shr ecx, 1 adc eax, eax jnc short myloop This compiles into:
33 C0 40 D1 E9 13 C0 73 FA (a series of hex bytes)
Thus, this is 9 bytes.
Another example, in a different assembly dialect:
# reverse bits of a 32 bit word .text .globl rbit .type rbit,@function rbit: push $32 # prepare loop counter pop %ecx 0: shrl 4(%esp) # shift lsb of argument into carry flag adc %eax,%eax # shift carry flag into lsb loop 0b # decrement %ecx and jump until ecx = 0 ret # return This compiles/assembles to these 12 hex bytes:
6a 20 59 d1 6c 24 04 11 c0 e2 f8 c3 So to get your score, simply compile/assemble the assembly and get the size of the resulting file.
On Mac, this can be done as follows: (different flags may be needed for different assembly dialects)
If test.asm is the file containing the assembly (not compiled/assembled though), then run this:
nasm -f elf test.asm This makes an object file. Next, run either:
ld test.o -o test or:
gcc test.o -o test Then you can run test as ./test. Which of ld and gcc depends on the format of the assembly. If it has a main function, use gcc. If it has a defined start point, use ld.