![]() | การทำงานแบบตามลำดับ | ![]() |
1. พิมพ์ a และ b บรรทัดละตัว แล้ว end
; Memory using : tiny, small, medium, compact, large, huge
.model small
.data
x1 db "a",0dh,0ah,'$'
x2 db "b",0dh,0ah,'$'
.code
pmain proc far
; for .exe
push ds ; 1 of 5 line required for end .exe
mov ax,0 ; 2 clear ax by xor ax,ax
push ax ; 3 send ax to stack
mov ax,@data
mov ds,ax
; display 2 character
mov ah,09h
lea dx,x1
int 21h
mov ah,09h
lea dx,x2
int 21h
; bye
ret ; Can not use int 20h
pmain endp
.stack 200h ; not required
end pmain
|
2. พิมพ์ตัวอักษร a และ CF ด้วยวิธีบวกค่าเพิ่มผ่านคำสั่ง add ให้ตัวแปร x2
; Result of this program is a and CF in difference line
.model small
.data
x1 db "a",0dh,0ah,'$'
x2 db "A",'$'
.code
pmain proc far ; can not change far to near because error on execute
; for .exe
push ds ; 1 of 5 line required for end .exe
mov ax,0 ; 2 clear ax by xor ax,ax
push ax ; 3 send ax to stack
mov ax,@data
mov ds,ax
; display 3 character
mov ah,09h
lea dx,x1 ; get a with line feed
int 21h
mov ah,09h
add x2,2 ; add A to C
lea dx,x2 ; get C
int 21h
mov ah,09h
add x2,3 ; add C to F
lea dx,x2 ; get F
int 21h
; bye
ret ; Can not use int 20h
pmain endp
.stack 200h ; not required
end pmain
|
3. การ clear screen และ move cursor
.model small
.data
x1 db "type e or E to Exit",0dh,0ah,'$'
.code
pmain proc far ; can not change far to near
push ds ; 1 of 5 line required for end .exe
mov ax,0 ; 2 clear ax by xor ax,ax
push ax ; 3 send ax to stack
mov ax,@data
mov ds,ax
; clear screen
mov ax,0600h ; al หมายถึงจำนวนบรรทัดที่ว่าง
mov bh,71h ; สีของพื้น และตัวอักษร
; 0=ดำ 1=น้ำเงิน 2=เขียว 3=ฟ้า 4=แดง 5=ม่วง 6=ทอง 7=เทา
mov cx,0000h ; มุมบนซ้าย
mov dx,103fh ; มุมล่างขวา
int 10h
; move cursor
mov ah,02h ; กำหนดตำแหน่ง cursor
mov bh,00 ; เลขหน้าเป็น 0 ถึงจะเริ่มบนสุด
mov dh,02h ; เริ่มต้นบรรทัดที่ 2
mov dl,10h ; เริ่มต้นหลักที่ 16 ( mov dx,0210h )
int 10h
finish: ret
pmain endp
end pmain
|