Hi,
Can anyone explain to me why
org 0x10000 ; the file start at 1MB
why is 0x10000 = 1MB? 0x10000 = 65536 in decimal. isn't it be 1Kb
One more question is that
Its not variable declaration. so what this line means? it looks line a label but with value!
bpbBytesPerSector: DW 512
Thank you
Some silly Assembly question
Moderator:Moderators
Re: Some silly Assembly question
Yes. 1 MiB is 0x100000 which is 16 times more than 65536. Where is that line from? It is almost certainly a mistake.why is 0x10000 = 1MB? 0x10000 = 65536 in decimal.
Yes and no. It is a label declaration.Its not variable declaration. so what this line means? it looks line a label but with value!
In ASM, there is no concept of a variable as such. There are only bytes in memory and registers, with operations between the two. The line declares a label called 'bpbBytesPerSector' which is ultimatly a memory address. The 'dw 512' means "declare a word (16 bits) of data which has the value 512".
As a result, you have the label which is the memory address of a word of data with the value 512. This is the closest thing you can get to variables in asm. Do be careful not to execute data!
You will also see other declare tokens
db for byte,
dd for dword(32bits),
dq for qword(64bits),
dt for tword (10 bytes, 80bits - used for FPU stuff)
Does this help?
~Andrew

Re: Some silly Assembly question
Thanks for the reply,
the org 0x10000 is found in tutorial 11, the asm file of stage 3.
About bpbBytesPerSector,
why is there sometimes ":" for declaration, and sometime don't. (I know ":" is added at the end of a lablel)
ex:
why dont we have ":" for the someVariable or msg?
Thanks
the org 0x10000 is found in tutorial 11, the asm file of stage 3.
About bpbBytesPerSector,
why is there sometimes ":" for declaration, and sometime don't. (I know ":" is added at the end of a lablel)
ex:
Code: Select all
someVaraible db 10
msg db "message here"
bpbBytesPerSector: db 512
Thanks
Re: Some silly Assembly question
Strictly speaking, a colon is required to define a label.
However, NASM decides that if the text isnt an assembler instruction, it will treat it as a label and see what happens.
As a result, it doesnt actually matter whether you use a colon or not.
~Andrew
However, NASM decides that if the text isnt an assembler instruction, it will treat it as a label and see what happens.
As a result, it doesnt actually matter whether you use a colon or not.
~Andrew
