There is an example, I will cite below. In general, understood, understood with memory, in general, everything is clear, but it is not clear how to do the task - so that the program processes an array of arbitrary length. There is such code:
.DSEG .ORG 0x60 arr: .BYTE 10 .CSEG ;ΡΠ΅Π³ΠΌΠ΅Π½Ρ ΠΊΠΎΠ΄Π° rjmp Reset ;Π²Π΅ΠΊΡΠΎΡ ΠΏΡΠ΅ΡΡΠ²Π°Π½ΠΈΡ, Π²ΡΠ·ΡΠ²Π°Π΅ΠΌΠΎΠ³ΠΎ ΠΏΠΎ ΡΠ±ΡΠΎΡΡ ΠΌΠΈΠΊΡΠΎΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ° Reset: ;Π½Π°ΡΠ°Π»ΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ ldi XH,HIGH(arr) ;ΡΠΊΠ°Π·Π°ΡΠ΅Π»Ρ X ΠΏΡΠΎΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΠΎΠ²Π°Π½ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ΠΌ ldi XL,LOW(arr) ;Π°Π΄ΡΠ΅ΡΠ° Π½Π°ΡΠ°Π»Π° ΠΌΠ°ΡΡΠΈΠ²Π° arr ldi YH,HIGH(arr+10) ;ΡΠΊΠ°Π·Π°ΡΠ΅Π»Ρ Y ΠΏΡΠΎΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΠΎΠ²Π°Π½ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ΠΌ ldi YL,LOW(arr+10) ;Π°Π΄ΡΠ΅ΡΠ° ΡΠ»Π΅Π΄ΡΡΡΠ΅Π³ΠΎ Π·Π° ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΌ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠΌ ΠΌΠ°ΡΡΠΈΠ²Π° arr ldi r16,5 ;Π·Π°Π³ΡΡΠ·ΠΊΠ° Π² ΡΡΠ΅ΡΡΠΈΠΊ ΡΠΈΠΊΠ»Π° r16 ΡΠΈΡΠ»Π° 5 cycle: ld r0,X ;ΠΊΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ Π² r0 ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ³ΠΎ ΡΡΠ΅ΠΉΠΊΠΈ ΠΠΠ£, Π½Π° ΠΊΠΎΡΠΎΡΡΡ ΡΠΊΠ°Π·ΡΠ²Π°Π΅Ρ X ld r1,-Y ;ΠΊΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ Π² r1 ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ³ΠΎ ΡΡΠ΅ΠΉΠΊΠΈ ΠΠΠ£, Π½Π° ΠΊΠΎΡΠΎΡΡΡ ;ΡΠΊΠ°Π·ΡΠ²Π°Π΅Ρ Y Ρ ΠΏΡΠ΅Π΄Π²Π°ΡΠΈΡΠ΅Π»ΡΠ½ΡΠΌ ΡΠΌΠ΅Π½ΡΡΠ΅Π½ΠΈΠ΅ΠΌ Y Π½Π° Π΅Π΄ΠΈΠ½ΠΈΡΡ st Y,r0 ;ΠΊΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ r0 Π² ΡΡΠ΅ΠΉΠΊΡ ΠΠΠ£, Π½Π° ΠΊΠΎΡΠΎΡΡΡ ΡΠΊΠ°Π·ΡΠ²Π°Π΅Ρ Y st X+,r1 ;ΠΊΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ r1 Π² ΡΡΠ΅ΠΉΠΊΡ ΠΠΠ£, Π½Π° ΠΊΠΎΡΠΎΡΡΡ ΡΠΊΠ°Π·ΡΠ²Π°Π΅Ρ X ;Ρ ΠΏΠΎΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΡΠ²Π΅Π»ΠΈΡΠ΅Π½ΠΈΠ΅ΠΌ X Π½Π° Π΅Π΄ΠΈΠ½ΠΈΡΡ dec r16 ;r16<-(r16-1) cpi r16,0x00 ;ΡΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ r16 Ρ Π½ΡΠ»Π΅ΠΌ brne cycle ;ΠΏΠΎΠ²ΡΠΎΡΠ΅Π½ΠΈΠ΅ ΡΠΈΠΊΠ»Π°, Π΅ΡΠ»ΠΈ Π½Π΅ 0 rjmp PC ;Π±Π΅ΡΠΊΠΎΠ½Π΅ΡΠ½ΡΠΉ ΡΠΈΠΊΠ»
As I understood, on the basis of the condition, I need to make it so that I can put any number in arr: .BYTE **** and it was handled normally. So, somehow, it is necessary for Y to know the end, and then with the counter it will be easier to do this so that Y knows the end of the array?
Or do not dig in the wrong direction and think wrong?
arr: .BYTE 10
and initialize YH / YL with the address of this label? - alexlz