can i ask something whats the used of .org 100h in assembly language...,

and why it is 100h why can/t it be 60,70,80 or 90h?

tnx :)

Recommended Answers

All 15 Replies

I assume you mean for a PC based 80x86 processor running DOS?

Actual firmware uses a reset vector for code startup.
Lookup a *.com file.

ORG (abbr. for ORiGin) is an assembly directive (not an instruction). It defines where the machine code (translated assembly program) is to place in memory. As for ORG 100H this deals with 80x86 COM program format (COMMAND) which consist of only one segment of max. 64k bytes. 100H says that the machine code starts from address (offset) 100h in this segment, effective address is CS:100H. For com format the offset is always 100H. I suppose that addresses 0 to 100H could be used by bios, but I am not that sure. Another example is ORG 7C00H for intel exe program format.

%%% Example for small assembly program using org 100h
%%% mycom.asm
ORG   100h        ; offset for com programs
mov   ax, cs      ; only one segment contains code+data
mov   ds, ax      ; data segemt address is equal to code segment adress
mov   dx, hel     ; Offset of hello world text
mov   ah, 09h     ; DOS function to output $-terminated string on screen
int   21h         ; Call DOS to execute 09H
mov   ax, 4C00h   ; DOS function 4CH to finish this progam, return code 0
int   21h         ; Call DOS
%%%
%%% here is good place for data 
hel: db "Hello World$"; Text to output on screen
%%%
%%% translate this assembly program with NASM:
NASM mycom.asm -f bin -o mycom.com

-- tesu

So, Simple answer...
We usually write [org 100h] because windows loads every .com software at offset 100h. So we have to include org 100h at start of program if we write org 60h or 80h or etc. then our all calls to our functions will jmp at wrong address..
for example I write a program:

   org 60h ; we gave direction to compiler that our first instruction (i.e. jmp main is at
   jmp main ; 60h. So, compiler is assuming (jmp main) is at 60h
   main:     ; and label (main:) is at 63h.
   ret

Now look at these lines when windows loaded this program then this was at:

    000h: ;raw 
       .: ;raw
       .: ;raw
       .: ;raw
       .: ;raw
       63h: ;raw
       . ;raw
       . ;raw
       . ; raw
       . ;raw
       . ;raw
       100h: jmp main     ; according to compiler (main:) is at 60h so compiler will
       103h: main:        ; jmp at 63h so any raw data present at 60h will executed,
       104h: ret          ; which can causes fatal errs.

Org 100h, Jmp strat V db 0,1,2,3,4 Strat: Mov cl,5 Mov al, 0 Mov si, 0 Next: Add al, v[bx] Inc bx Dec cl Cmp cl, o Jnz next ret i need output of above script code,,

Back in the days of MS-DOS, when a program was loaded into memory a structure called a "program segment prefix" was always prepended to it, and that structure was 100h bytes long. Therefore the actual code began at 100h, and the directive "org 100h" instructs the assembler to assemble code with 100h as the starting address.

The orogram segment prefix contained all sorts of stuff, some of it documented, some not. The most useful item to be found in it was the command line typed in by the user at offset 80h.

.EXE program files had a header which told the operating system where the first line of code would be in the loaded program, but .COM files did not. For that reason, .EXE programs didn't need the org 100h.

what will be the output of org 100h ?

commented: Too lazy to read the answer already posted here. -3
  1. It doesn't produce any output.
  2. Please don't revive old threads.

No i didn't review any old threads, actully this question came in my recent assignment but i dont know about this language,,,please help me out if you have some idea.
(Question are attached in JPEG file)

commented: And argumentative. +0

The thread was started 6 years ago.

The last post (before yours) was 11 months ago.

The question was answered in this thread already but you didn't bother to read it.

Googling "assembler org directive" would easily have given you several sources for an answer but you were too bloody lazy to look it up yourself or even read the answer up above in this thread.

well i read all above training Q&A but didn't found answer except org 100h, secondly you showed yourself in above wording that how much you are fast in stupidity...keep it up it will improve you a lot.

Dont think that you are a big champ, you even didn't know how many quations i shared in that JPEG file, you are still repliying for one instruction Org which was under discussion in above conversation.

commented: I have no idea what that means. +0

Stack Overflow

Tech Tools

Dewkumar

All from my suggested google search. They all explain the ORG directive and it should be obvious that it produces no output. Obvious, that is, if you had bothered to actually read any of them.

you even didn't know how many quations i shared in that JPEG file

@ Abottonion : By "quations", do you mean questions? Where is you JPEG file?

org 100h

mov ah,9
int 21h

mov bl,al
mov ah,1
int 21h
mov bh,al
cmp bl,bh
greater :
mov dl,bl
jmp print

not_greater:
mov dl,bh
jmp print

print:

mov ah,2
int 21h

ret

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.