ORG isn't a variable its an assembler directive.
The command ORG is the ORiGinate command which sets the start of the assembled code. ORG 100h means originate this block of assembled code at the location 100 hexidecmal.
Note: the Origin point of the code block does not HAVE to be the execute point in asssembly language. Therefore you could ORG at 100 hex and exec the code at 150 Hex.
Chat with our AI personalities
org 100h L2: mov bh,x(si) mov ah, x(si) L1: cmp si,7 je L inc si cmp ah, x(si) jg L1 jl L2 L:ret x db 1,3,7,8,6,9,5
name "str2bin" ; convert string number to binary! ; this program written in 8086 assembly language to ; convert string value to binary form. ; this example is copied with major modifications ; from macro "scan_num" taken from c:\emu8086\inc\emu8086.inc ; ; the original "scan_num" not only converts the string number ; but also reads the string from the keyboard and supports ; backspace key, this example is a shorten version ; of original "scan_num" macro. ; here we assume that the string number is already given, ; and the string number does not contain non-digit chars ; and it cannot cause buffer overflow (number is in word range ; and/or has only 4 digits). ; negative values are allowed in this example. ; the original "scan_num" does not allow to enter non-digits ; and it also checks for buffer overflow. ; you can the original file with other macro definitions ; in c:\emu8086\inc\emu8086.inc org 100h jmp start ; text data: msg1 db 0Dh,0Ah, " enter any number from -32768 to 65535 inclusive, or zero to stop: $" msg2 db 0Dh,0Ah, " binary form: $" ; buffer for int 21h/0ah ; fist byte is buffer size, ; second byte is number of chars actually read (set by int 21h/0ah). buffer db 7,?, 5 dup (0), 0, 0 ; for result: binary dw ? start: ; print welcome message: mov dx, offset msg1
There should be a jump over the variables/array declaration:org 100hjmp codemyArray dw 2, 12, 8, 52, 108code: mov si, 0mov ax, myArray[si]retFor the computer all bytes look the same, it cannot determine if it's an instruction or a variable. Here is an example of MOV AL, 5 instruction that can be coded with simple variable declarations:org 100hbyte1 db 176byte2 db 5retWhen you run this program in emulator you can see that bytes 176 and 5 are actually assembled into:MOV AL, 5This is very typical for Von Neumann Architecture to keep data and instructions in the same memory, It's even possible to write complete program by using only DB (define byte) directive.org 100hdb 235 ; jump...db 6 ; 6 - six bytes forward (need to skip characters)db 72 ; ascii code of 'H'db 101 ; ascii code of 'e'db 108 ; ascii code of 'l'db 108 ; ascii code of 'l'db 111 ; ascii code of 'o'db 36 ; ascii code of '$' - DOS function prints until dollar.db 186 ; mov DX, .... - DX is word = two bytesdb 2 ; 02 - little enddb 1 ; 01 - big enddb 180 ; mov AH, ....db 9 ; 09db 205 ; int ...db 33 ; 21h - 33 is 21h (hexadecimal)db 195 ; ret - stop the program.8086 and all other Intel's microprocessors store the least significant byte at a lower address. 102h is the address of 'H' character = org 100h + 2 bytes (jmp instruction). The above assembly code produces identical machine code to this little program:org 100hjmp codemsg db 'Hello$'code: mov DX, offset msgmov AH, 9int 21hretIf you open the produced ".com" file in any hex editor you can see hexadecimal values, every byte takes two hexadecimal digits, for example 235 = EB, etc... memory window of the emulator shows both hexadecimal and decimal values.
org 100h .data str1 db "Computer" str2 db "computer" mes1 db "string are same $" mes2 db "string are different $" .code assume cs:code,ds:data start: mov ax,@data mov ds,ax mov es,ax mov si,offset str1 mov di,offset str2 cld mov cx,8 repe cmpsb mov ah,9 jz skip lea dx,mes2 jmp over skip: lea dx,mes1 over: int 21h mov ax,4c00h int 21h end start ret
; count_chars.asm ; counts the number of characters of a zero terminated string. name "counter" org 100h jmp start str1 db 'abcdefg hijklmnop qrstvuwxyz', 0 start: lea bx, str1 ; load address of string. mov ax, 0 ; reset counter. compare: cmp [bx], 0 ; is it end of string? je done ; if zero, then it's the end. inc ax ; count char. inc bx ; next memory position in string. jmp compare ; print result in binary: done: mov bx, ax mov cx, 8 print: mov ah, 2 ; print function. mov dl, '0' test bl, 10000000b ; test first bit. jz zero mov dl, '1' zero: int 21h shl bl, 1 loop print ; print binary suffix: mov dl, 'b' int 21h ; wait for any key press.... mov ah, 0 int 16h ret ; ; count_chars.asm ; counts the number of characters of a zero terminated string. name "counter" org 100h jmp start str1 db 'abcdefg hijklmnop qrstvuwxyz', 0 start: lea bx, str1 ; load address of string. mov ax, 0 ; reset counter. compare: cmp [bx], 0 ; is it end of string? je done ; if zero, then it's the end. inc ax ; count char. inc bx ; next memory position in string. jmp compare ; print result in binary: done: mov bx, ax mov cx, 8 print: mov ah, 2 ; print function. mov dl, '0' test bl, 10000000b ; test first bit. jz zero mov dl, '1' zero: int 21h shl bl, 1 loop print ; print binary suffix: mov dl, 'b' int 21h ; wait for any key press.... mov ah, 0 int 16h ret ;