Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does assembler process "org 100h" directive?

I know, what this directive is do. As I know program-loader doesn't see this directive, so, how assembler process it?

like image 384
Mary Ryllo Avatar asked Oct 16 '25 10:10

Mary Ryllo


2 Answers

It sets the current address during assembly to be 100h. That's all it is. A simple assignment.

Elaboration:

The directive does not control where in the result image the following instructions will be placed, but rather where the instructions would be placed after being loaded into memory.

like image 87
Jens Björnhager Avatar answered Oct 19 '25 13:10

Jens Björnhager


"org <100h>" instructs the compiler with the to-be runtime information to evaluate addresses, as binary image will be loaded with offset (and first 100h bytes possibly to be used for PSP etc. in your context)

This comes in hand to access any data in the same segment (usually when DS=CS, especially true for com files when "you know nothing except your CS"), or when doing a JMP to absolute offset in rare cases.

In other words, it makes all further labels in a segment to account from the specific offset: just that.

like image 36
vzezin Avatar answered Oct 19 '25 12:10

vzezin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!