variabled in assembler - question
Posted on 2005-03-25
I have a question , about variables in masm.
I've coded the following program(attached). the program get 4 numbers from num1,num2,num3,num4 and print them on the screen at the corrdinate of dx.
anyway , I'm experiencing some wierd problems:
1) why can't I declare the variables in .data , the program doesnt work the same. why?
2) I cant debug my program if I decalre the variables at code segment. I see the machine code instead of my program. why?
3) how can I declare the variables in the data segment and that the program will run ok.
4) if I add another variables (for examples: num db 1) before the num1 variables then the program is running ok, why?
num1 db 5h
num2 db 3h
num3 db 8h
num4 db 2h
add num1,30h ;converting the number wanted to its ascii code
mov al,030h ; COLOR
mov dx,0000h ; CORDINATES "0000h" is considerred to be first line,first column
cmp dl,0 ;checks if x-axis is zero, no need in shifting inside the row
call x_pos ;else, calling the x-shifting procedure
yy:cmp dh,0 ;checks if y-axis is zero, no need in shifting rows
call y_pos ;else, calling the y-shifting procedure
zz: ; printing on the screen after going to the right cordinates
mov al,[num1] ;should be num1 insteed, and its value and not ascii code
mov al,[num2] ;should be num2 insteed, and its value and not ascii code
mov al,[num3] ;should be num3 insteed, and its value and not ascii code
mov al,[num4] ;should be num4 insteed, and its value and not ascii code
kkk: jmp kkk ; stuck the program, so we can see the result on the screen
loop1: add bx,2
loop2: add bx,0a0h
mov ah,4ch; Exit Code