Assume I have a variable called Block_Size and without initialization.
Would
Block_Size db ? mov DS:Block_Size, 1 be equal to
Block_Size db 1 No, Block_Size db ? has to go in the BSS or data section, not mixed in with your code.
If you wrote
my_function: Block_Size db ? mov DS:Block_Size, 1 ... ret your code would crash. ? isn't really uninitialized, it's actually zeroed. So then the CPU decoded the instructions starting at my_function (e.g. after some other code ran call my_function), it would actually decode the 0 as code. (IIRC, opcode 0 is add, and then the opcode of the mov instruction would be decoded as the operand byte of add (ModR/M).)
Try assembling it, and then use a disassembler to show you how it would decode, along with the hex dump of the machine code.
db assembles a byte into the output file at the current position, just like add eax, 2 assembles 83 c0 02 into the output file.
You can't use db the way you declare variable in C
void foo() { unsigned char Block_size = 1; } A non-optimizing compiler would reserve space on the stack for Block_size. Look at compiler asm output if you're curious. (But it will be more readable if you enable optimization. You can use volatile to force the compiler to actually store to memory so you can see that part of the asm in optimized code.)
Maybe related: Assembly - .data, .code, and registers...?
If you wrote
.data Block_size db ? .code set_blocksize: mov [Block_size], 1 ret it would be somewhat like this C:
unsigned char Block_size; void set_blocksize(void) { Block_size = 1; } If you don't need something to live in memory, don't use db or dd for it. Keep it in registers. Or use Block_size equ 1 to define a constant, so you can do stuff like mov eax, Block_size + 4 instead of mov eax, 5.
Variables are a high-level concept that assembly doesn't really have. In asm, data you're working with can be in a register or in memory somewhere. Reserving static storage for it is usually unnecessary, especially for small programs. Use comments to keep track of what you put in which register.
db literally stands for "define byte" so it will put the byte there, where the move command can have you place a particular value in a register overwriting whatever else was there.
dbmeans 1 byte in space,mov ..., 1means set value to 1Block_Size = 1? The most direct meaning (changing the numeric value of the label at runtime) is nonsensical, and usually that wouldn't be the intended meaning but in the context of this question it sort of looks like that might be what you meant.