Can someone please explain the functions of these three instructions?
ORG 1000H
MOV AX,CS
MOV DS,AX
I know what the code, data, and extra segments are in theory, but:
How they are implemented in this program?
Why is the entire segment moved into another? (
MOV AX,CS
andMOV DS,AX
)
What do these two instructions actually do?
I can understand the meaning of every other instruction in this code, except for the highlighted 3 instructions.
(The program works fine. It accepts input till 0 is hit -- there's a mov ah,01h
and an int 21h
, then it compares al
to '0'
and if al
is '0'
, it jumps to last
, otherwise it jumps into back
.)
ASSUME CS:CODE
CODE SEGMENT
ORG 1000H
MOV AX,CS
MOV DS,AX
BACK:
MOV AH,01H
INT 21H
CMP AL,'0'
JZ LAST
JMP BACK
LAST:
MOV AX,4C00H
INT 21H
CODE ENDS
END
(Editor's note: .com
programs are loaded at offset 100h
, with all segment registers set equal to each other. org 1000h
is likely a typo for org 100h
because this looks like a .com
program. This program doesn't break because it doesn't use any absolute addresses, only relative jumps.)