I am learning for my exam and I am so confused by this assembly code. It is a program in which first user enters a string, than that string gets coded and printed, than decoded
Explained:
INC bx ; increment bx, skip this byte (why ?)
MOV cl, [bx] ; get number of characters of the string
XOR ch, ch ; quick way to set ch to zero, so cx == cl for the loop
coding:
INC bx ; next address
MOV dl, [bx] ; get character value
XOR dl, ah ; decode it with XOR key in ah
MOV [bx], dl ; store in the same memory value
LOOP coding ; decrement cl and goto coding if cx > 0
Format of the string seems "custom", certainly not NULL terminated but rather containing size first (is it Pascal? Ada uses this kind of system)
Note that in that case encoding and decoding are the same since XOR masking is used.