section .text
global _start ;must be declared for using gcc
_start: ;tell linker entry point
mov eax, 1101b
mov ebx, 0111b
add eax, ebx
add eax, '0'
mov [sum], eax
mov ecx, msg
mov edx, len
mov ebx, 1 ;file descriptor (stdout)
mov eax, 4 ;system call number (sys_write)
int 0x80 ;call kernel
; convert binary to string
mov ebx, [sum] ; get our number
xor edx, edx ; make edx 0
mov edi, buffer ; someplace to put it
.top
mov al, '0'
shl ebx, 1
adc al, 0
stosb
inc edx
cmp edx, 8
jnz .top
mov ecx, buffer
; edx is 8
mov ebx, 1 ;file descriptor (stdout)
mov eax, 4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax, 1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db "The sum is: "
len equ $ - msg
segment .bss
sum resb 16 ; only need 4
buffer resb 8
Warning! Untested code. I should know better!
Best,
Frank