Assembly Question, CX counter issue.

Kanecnc

n00b
Joined
May 16, 2007
Messages
56
I am having a problem, I am re-writing my Memory Dump program because I need to truly learn assembly, but that is besides the point. The deal is I ask the user to enter a number for a block size, which will be used to control the number of bytes that are dumped to the screen.

Any who, the read function I have made works fine I tested it and it reads in the segment address and offset perfectly and when outputted they are correct. The function reads in four characters so if the user enters 1234h for the seg address then the value stored is 1234 and not the ascii values for each character. So I am for now using that for reading in the block size such as 0001 for example. However when i do mov cx,var_blocksize it loops more than 1 time. I tried clearing both cx and the variable. Is there an issue with loading variables into the cx register? Because I even tried moving the variable data into ax and then into cx with not luck.

I did a little debugging and did a AND var_blocksize,0Fh and it would output two bytes i.e. 1A 89. So I know that definitely their is something wrong with that variable blocksize. Also it is defined just like i did my seg and offset variables:

var_segment dw ?
var_offset dw ?
var_blocksize dw ?

My guess was the read function is wrong, but it works for the other two variables. So any ideas? Sorry for the drawn out question.
 
When I output the contents of var_blocksize right after I store it, it is 0001 but when I go to another proc such as memdump proc and output the contents it is no longer 0001 but jibberish?
 
Well that was quick figured it out. Since I was messing with si and ds to load the memory at the seg/offset address it was messing up the pointers causing the variables to be nonsense so I just pushed the blocksize on the stack before hand and then pop it onto ax then loading cx with ax.
 
Back
Top