Im trying to understand what ORG does in 8086. Ive tried looking at the instruction lists without success.



The whole line is:

ORG 7C00h
Posted on 2009-05-07 14:27:12 by quddusaliquddus
With org you define where your code will be placed inside the executable. Reason why you couldn't find any info is that org isn't an instruction but an assembler directive.
Posted on 2009-05-07 14:57:46 by JimmyClif
Posted on 2009-05-07 15:52:20 by quddusaliquddus
All it does is that it tells the assembler to modify the ORIGIN of memory instructions from that specific point. So IIRC if you do ORG 0xDEAD, and then you try to read the contents of the memory address at location 0, that location is actually 0xDEADth byte of the memory.
Posted on 2009-05-07 15:53:20 by XCHG

Could I use ORG to point to the USB drive?
Posted on 2009-05-08 06:33:44 by quddusaliquddus
Or is that a stupid question? Maybe I need to read up more before asking this question?
Posted on 2009-05-08 14:25:17 by quddusaliquddus
Your mobo's BIOS handles the booting (chooses from where to load the first 512 bytes: from floppy, some of the HDD partitions, a DVD or USB). From there on, your code in those 512 bytes loads via BIOS API bigger chunks of code from storage onto RAM, and jumps to that bigger chunk of code (yields execution to it).
The first 76 or so bytes of those 512 are not code, but descriptor-data for BIOS to know this really is boot-code and what its environment is.
Posted on 2009-05-08 14:48:08 by Ultrano
You caught me off gaurd there with the 'mobo'. I'll go over what you said and try and understand it. Thanks.
Posted on 2009-05-08 15:18:26 by quddusaliquddus
Are you trying to write a bootloader or just read/write some data from/to a USB drive (and if yes then what OS you want it to work under)?
Posted on 2009-05-08 21:36:38 by ti_mo_n
I found this simple OS written in Assembly. I wanted to run it from a USB drive.

; directive to create BOOT file:

; Boot record is loaded at 0000:7C00,
; so inform compiler to make required
; corrections:
ORG 7C00h

PUSH    CS  ; make sure DS=CS

; load message address into SI register:
LEA SI, msg

; teletype function id:

print:  MOV AL,
        CMP AL, 0
        JZ done
        INT 10h  ; print using teletype.
        INC SI
        JMP print

; wait for 'any key':
done:      MOV AH, 0
          INT 16h

; store magic value at 0040h:0072h:
;  0000h - cold boot.
;  1234h - warm boot.
MOV    AX, 0040h
MOV    w.[0072h], 0000h ; cold boot.

JMP 0FFFFh:0000h ; reboot!

new_line EQU 13, 10

msg DB  'Hello This is My First Boot Program!'
    DB  new_line, 'Press any key to reboot', 0

Posted on 2009-05-09 12:18:23 by quddusaliquddus