THE PROGRAM NEEDS TO SUM ARRAY AND PRINT BUT IT CRASHES PRINT NOTHING
.data
array1 byte 10,20,30,40,50
.code
main proc
mov eax , 0
mov eCX , 5
mov bx , 0
l1:
ADD AL , array1[bx] I; IF I USE BYTE PTR AND AX INSTEAD OF AL IT GIVES ERROR
inc bx
inc bx ; IF I INCREMENT BX 1 TIME THEN ALSO CRASH
loop l1
MOVZX EAX,AL
printf("%d\n" , EAX)
ret
main endp
end main
AND WHERE CAN I FIND SOME GOOD ASSEMBLY LANGUAGE TUTORIALS THANKS
; --------------------------------------------------
; File Name : test.asm
; Compile using : nasm -felf32 -o test.o test.asm
; Link using : ld -o test -melf_i386 test.o
; --------------------------------------------------
global _start
[section .data]
array: db 10, 20, 30, 40, 50
[section .text]
_start:
xor ebx, ebx
mov esi, array
mov ecx, 5
.L0:
lodsb
add ebx, eax
loop .L0
; ebx contains the sum
_exit:
mov eax, 1
; Use the return code = sum of the values (8 bit)
int 0x80