I don't have much experience in 8086 assembly and I like to know what happens in the program if you don't write the starting label (start:
) and the end of that label
(end start
) (labels that surround the executing code)?
So my question is are this labels necessary for the execution, does the code access some addresses that is not supposed to when these labels are excluded and are these labels that surround the executing code the same as start(=='{') and the end(=='}') of main()
in java class?
*Additional information and results
I was writing a program for printing the numbers 1-5 which are contained in an array. I tried it with and without adding the labels and here is the results:
;assembly for printing an array of the integers 1-5
;data segment
data segment
NIZA db 1,2,3,4,5
ends
;code segment
code segment
start: ;the "start:" label
;setting ds and es
mov ax,data
mov ds,ax
mov es,ax
mov bx,OFFSET NIZA
mov cx,5
pecatenje_na_niza:
mov dl,[bx]
add dx,48d
mov ah,2
int 21h
inc bx
loop pecatenje_na_niza
mov ah,1
int 21h
mov ah,4ch
int 21h
end start ;the "end start" label
ends
1) start:
and end start
included:
- The program runs as it supposed to and the output is all the elements of the array printed.
2) start:
and end start
not included (the same code,but the labels excluded):
When the program starts there are these few lines that execute, that don't in the one where I include
start:
andend start
:
(I can't find a way to copy from the emulator, so I'm gonna paste a screenshot)
and here are the values of the array NIZA in the emulator before and after executing this lines of code:
And in the end the output is all zeros.
The printing is as it is because of this line add dx,48d
, so that's why all it prints is 00000
. By the way, the DX resets every time mov dl,[bx]
executes .
That's all I could understand and find for now.