How to resolve the algorithm Array concatenation step by step in the Z80 Assembly programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Array concatenation step by step in the Z80 Assembly programming language

Table of Contents

Problem Statement

Show how to concatenate two arrays in your language.

If this is as simple as array1 + array2, so be it.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Array concatenation step by step in the Z80 Assembly programming language

Source code in the z80 programming language

	org $8000

	ld hl,TestArray1		; pointer to first array
	ld de,ArrayRam			; pointer to ram area
	ld bc,6			        ; size of first array
	ldir
	
	; DE is already adjusted past the last entry
	;	of the first array
	
	ld hl,TestArray2		; pointer to second array
	ld bc,4				; size of second array
	ldir
	
	call Monitor_MemDump
	db 32				; hexdump 32 bytes (only the bytes from the arrays will be shown in the output for clarity)
	dw ArrayRam			; start dumping from ArrayRam
	
	ret				; return to basic

ArrayRam:
	ds 24,0	                        ;24 bytes of ram initialized to zero

	org $9000
TestArray2:
	byte $23,$45,$67,$89
	; just to prove that this doesn't rely on the arrays
	;	being "already concatenated" I've stored them
	;	in the reverse order.
TestArray1:
	byte $aa,$bb,$cc,$dd,$ee,$ff

  

You may also check:How to resolve the algorithm Averages/Root mean square step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Hello world/Web server step by step in the Standard ML programming language
You may also check:How to resolve the algorithm One of n lines in a file step by step in the Go programming language
You may also check:How to resolve the algorithm Empty string step by step in the i programming language
You may also check:How to resolve the algorithm Kronecker product step by step in the Rust programming language