Assembly Code: Converting Hex contents of RAM to ASCII and storing back to RAM

NOTE: This program is going to be executed on an ATmega328P

.equ scrAddr = $100
.equ dstAddr = $110
.equ startAddr = $110
.equ destAddr = $120

.macro LDSW
	LDS @0, @2
	LDS @1, @2+1
.endmacro

;Store Word - Store Word Immediate
;  Usage: STWI addr16, Rt, data16	[addr:addr+1] <- data

.macro STBI ; addr16, Rt, data8
	LDI @1, @2
	STS @0, @1
.endmacro

.macro STWI
	STBI @0, @1, high(@2)
	STBI @0+1, @1, low(@2)
.endmacro

; *******************************************************************
; data space variable section
.dseg
.org SRAM_START
srcAddress:		.byte 2
numBytes:		.byte 1
dstAddress:		.byte 2

; *******************************************************************
; interrupt vector table
.cseg
.org 0x0000
jmp main
; *******************************************************************

;Load Word - Load Word from SRAM
;  Usage: LDSW [RegH], [RegL], [Addr]

.equ numbytesConst = 5

.org INT_VECTORS_SIZE

main:
	STWI srcAddr, R16, startAddr
	STWI dstAddr, R16, destAddr
	STS numbytesConst, R16
	
	LDI R16, 5

	LDS XH, srcAddr
	LDS XL, srcAddr+1

	LDS YH, dstAddr
	LDS YL, dstAddr+1

	LDS R5, numbytes
; main

So the objective to a program I am trying to do in assembly code is to run a program that converts hexadecimal contents of a block of RAM to an ASCII format (That part I already took care of in separate functions as I used some logical AND masking) and then store it back into RAM.

I tried running the program and it was not able to read srcAddr as a defined symbol.

Typo in the very first line: should be “src”, not “scr”

1 Like

Are you serious!? I spent hours looking at the code not knowing what’s wrong with it. And IT WAS A MISSPELLING!?

3 Likes

Happens to everyone :wink:
When you can’t find the bug just step away from the project for a few hours and the problem will often be obvious.

1 Like

Well, I am not out of the woods yet with my program, I will update this post on it when I bump into something else.

Tell me about it. Ugh.