Reputation: 23
I have recently started to get into assembly, and I have been using NASM because I can easily find tutorials. Because of its difficulty, I decided I would start very small, by making a program to add 1 and 3 and output 4. I have worked it out enough that I do not receive error or warning messages, but it does not output anything aside from sh-4.3$.
segment .text
global _start
_start:
mov eax, '1'
sub eax, '0'
mov ecx, '3'
sub ecx, '0'
add ecx, eax
add ecx, '0'
mov edx, 1
mov ebx, 1
mov eax, 4
int 0x80
mov eax, 1
int 0x80
Upvotes: 0
Views: 213
Reputation: 10381
Move your result into a variable, then you display the variable :
section .data
result : db ' ',10 ◄■■ VARIABLE
segment .text
global _start
_start:
mov eax, '1'
sub eax, '0'
mov ecx, '3'
sub ecx, '0'
add ecx, eax
add ecx, '0'
mov [result], cl ◄■■ MOVE RESULT INTO THE VARIABLE.
mov ecx, result ◄■■ DISPLAY THIS VARIABLE.
mov edx, 1
mov ebx, 1
mov eax, 4
int 0x80
mov eax, 1
int 0x80
You have to store the address of the variable in ECX, not the value itself.
Upvotes: 1