Some people say that assembly language = machine language, just that we use mnemonics in assembly language.
After reading Petzold's "CODE", I can't still understand how some of the assembly codes are translated into machine code.
For example (from Tutorials Point's Assembly Course):
_start: ;tells linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
section .data
msg db 'Hello, world!', 0xa ;our dear string
What I understand is that msg contains "Hello, world!" and it's moved into ECX.
But as I know, in x86 the ECX can just store 32 bits.
Then how can we move "Hello, world!" - which is more than 32 bits - into ECX?
And what is the equivalence of that part
section .data
msg db 'Hello, world!', 0xa ;our dear string
in machine code?
With msg db
you define address containing the string sequence of bytes. With mov ecx, msg
you load just this address not its content. Then it's possible to load string by loading [ecx], [ecx+1] etc.
.data defines program section. .text usually contains machine code, .data modifiable program code. There can be more of them such as exception handling labels etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With