I'm using emu8086 to learn Assembly language. I have a question that says: Convert the following to code snippet to Assembly Language code: a = 0
Do i initialize the variable a as the decimal ascii code 48(which has a character value of 0)?
a db 48
Or do i initialize the variable a as the decimal ascii code 0 itself(which has a character value of NUL)?
a db 0
a = 0
means that the variable a
should be set to 0. You must distinguish between the ASCII characters and their values.
The value 48 = 0x30 = '0' represents the ASCII character for 0
but not the value 0
So if you want to set the value 0 you have to use
a db 0
If you want to have the character 0 you have to use
a db '0'
or alternativly
a db 48
a db 30h
which is all the same, but you should use the notation which fits the purpose. If you are using characters, you should use the characters and not their ASCII values. Technically it's the same, but the meaning conveyed to the reader is different.