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.
Assembly Syntax:
%%% 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
No comments:
Post a Comment