zapman2003
April 28th, 2009, 04:45 PM
Hello,
I've had trouble with an assignment. The purpose of the program is to take two hardcoded hex values, output them as a string, and perform an exor operation and output the result in hex also.
Example run of program
Given:
MLB: .equate 8 ; multi-length bytes
A: .word 0x0123
.word 0xABCD
.word 0x5678
.word 0xCDEF
B: .word 0x0010
.word 0xaaaa
.word 0x8765
.word 0x2323
Program output is
0123abcd5678cdef
exor 0010aaaa87652323
= 01330167d11deecc
The code I have written to output the hex is:
hex: ldx 0,i
ldbytea A,d
top: cpx MLB,i
brge endit
asla
asla
asla
asla
stbytea -2,s
anda 0xF,i
charo A,x
ldbytea -2,s
addx 1,i
br top
endit: stop
It works fine when outputting a basic string, such as ascii: "0123456789abcdef", but only outputs garbage when applied to a hex number. I am severely stumped as to how to proceed, as I can only assume it's outputting ascii codes as opposed to the actual hex value and I don't know how to get it to output correctly. Any help would be much appreciated!
I've had trouble with an assignment. The purpose of the program is to take two hardcoded hex values, output them as a string, and perform an exor operation and output the result in hex also.
Example run of program
Given:
MLB: .equate 8 ; multi-length bytes
A: .word 0x0123
.word 0xABCD
.word 0x5678
.word 0xCDEF
B: .word 0x0010
.word 0xaaaa
.word 0x8765
.word 0x2323
Program output is
0123abcd5678cdef
exor 0010aaaa87652323
= 01330167d11deecc
The code I have written to output the hex is:
hex: ldx 0,i
ldbytea A,d
top: cpx MLB,i
brge endit
asla
asla
asla
asla
stbytea -2,s
anda 0xF,i
charo A,x
ldbytea -2,s
addx 1,i
br top
endit: stop
It works fine when outputting a basic string, such as ascii: "0123456789abcdef", but only outputs garbage when applied to a hex number. I am severely stumped as to how to proceed, as I can only assume it's outputting ascii codes as opposed to the actual hex value and I don't know how to get it to output correctly. Any help would be much appreciated!