Vous êtes sur la page 1sur 2

PROGRAM 1: Prints 0 on the first line, then 1 on the second

a 100
mov AH,
mov DX,
int 21
mov DX,
int 21
mov DX,
int 21
int 20

2
30
A

;30 is ASCII for '0'


;prints character stored in DL if AH=02
;A is ASCII for newline

31

;31 is ASCII for newline


;terminates program

rcx
100
n test.com
w
q
PROGRAM 2: Jump-if-equal demo
mov AH,2
jmp address1
mov dx, 30
int 21
int 20
mov BX, 2
cmp BX, 2
je address2

;address2
;address1
;since BX=2, the ZF flag now equals 1
;jumps to address1 since ZF=1

Note that "cmp number, register" is not valid syntax. If we replace je with jl,
the jump will only happen if BX < 2
PROGRAM 3: Prints 1 through 9 on different lines, using a loop
mov AH, 2
mov BX, 30
inc BX
mov DX, BX
int 21
mov DX, a
int 21
cmp BX, 39
jl address1
int 20

;address1

PROGRAM 4: Clears the screen


This program uses int 10, which sets cursor position to (DL, DH) if AH=02, or co
pies it to (DL, DH) if AH=03. AH=0A writes character AL at current cursor posit
ion, but does not move cursor. Note that the AH=03 command resets AX to 00
mov AH, 03
int 10

;Makes DX store cursor position


;and AL=0

startOfLoop:
cmp DX, 00
je endOfLoop

;Run the loop while cursor is not in topleft


corner

mov AH, 0A
int 10
dec DX
mov AH, 02
int 10

;Writes character stored in AL to cursor pos


which is the null character

;Moves cursor one back

jmp startOfLoop
endOfLoop:
mov AH, 0A
int 10
int 20

;Writes character in topleft corner to null

Vous aimerez peut-être aussi