db 0xxh will be encoded as it is in binary so if db 0cch was issued
just one byte 0xcc will be encoded in the exact position db was issued
dw will encode one word
ie dw 0aa55h will be seen as AA 55 in the binary
dd = DWORD == 2 WORDS == 4 BYTES so dd 01337BABEh will be encoded as 13 37 ba be in binary
dq = qword == 2 dwords == 4 words == 8 bytes
contents of directory prior to assembling and linking
:\>dir /b
bootlo.asm
contents of asm file
:\>type bootlo.asm
.386
.model flat, stdcall
.code
ORG 337h
start:
jmp @F
db 0bh dup (0CCh)
@@:
dw 0AA55h
dd 01337babeh
dq 05D0DDEED1337BABEh
retn
end start
assembling the file
:\>ml /coff /nologo bootlo.asm /link /subsystem:windows /nologo
Assembling: bootlo.asm
contents of directory post assembly and link
:\>dir /b
bootlo.asm
bootlo.exe
bootlo.obj
mllink$.lnk
explanation follows
org 337 has become default start of code section + 337
ie 0x1000 + 0x337 so during runtime it would be entry point RVA + default base
ie 0x400000 + 0x1000 + 0x337 == 0x401337
at 401337 you have will have a jump encoded
whose size would be the differnce between the address of next label and current instruction
next label follows after
db 0bh
i encoded 0xcc
in example but 0xab
or 0xff
or 0x00
or any byte
can be encoded and assembler will emit exactly what was asked for
& how many times
it was asked for
so there will be a short jump viz eb 0b
(x86 opcode )
follwing the label dw 0AA55h is issued so at 400000 + 1000 + 337 + 0x0b
AA 55 or 55 AA should be seen at 401344 (beware endianness)
assembled binary can be dumped and checked if AA 55 exists
:\>echo. & dumpbin /ALL bootlo.exe | grep -i entry & echo. & dumpbin /all bootlo
.exe | grep -A 1 -B 1 -i 55
1337 RVA of entry point
00401330: 00 00 00 00 00 00 00 EB 0B CC CC CC CC CC CC CC .......δ.╠╠╠╠╠╠╠
00401340: CC CC CC CC 55 AA BE BA 37 13 BE BA 37 13 ED DE ╠╠╠╠U¬╛║7.╛║7.φ▐
00401350: 0D 5D C3 .]├
:\>
db
values are written into the executable file, and only when executing this file you can determine how they are used -- i.e., read, written to, or even executed. Thedb
command itself assumes nothing; and neither does an assembler. – Jongware Feb 9 '14 at 17:07