![]()
การทำงานแบบตามลำดับ Sequential Processing
| ![]() |
|
ปรับปรุง : 2562-02-01 (ปรับ template) |
| Digital logic | OS | คำสั่งดอส | Batch | Debug | Assembly | GWBasic | Docker | |
|
1. พิมพ์ a และ b บรรทัดละตัว แล้ว end
เป็นแนวการเขียนโปรแกรมแบบ .exe โปรแกรมที่ได้มีขนาด 548 Byte
; 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
เป็นแนวการเขียนโปรแกรมแบบ .exe โปรแกรมที่ได้มีขนาด 564 Byte
; 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
int 10, ah 06, bh : 0=ดำ 1=น้ำเงิน 2=เขียว 3=ฟ้า 4=แดง 5=ม่วง 6=ทอง 7=เทา
.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
|
|
4. การ clear screen และ move cursor แล้วพิมพ์อักษรบรรทัดละตัว
41h คือ A และ 61h คือ a
.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
; A
mov ah,02h
mov dl,41h
int 21h
; move cursor
mov ah,02h ; กำหนดตำแหน่ง cursor
mov bh,00 ; เลขหน้าเป็น 0 ถึงจะเริ่มบนสุด
mov dx,0310h ; เริ่มต้นบรรทัดที่ 3 และเริ่มต้นหลักที่ 16
int 10h
; a
mov ah,02h
mov dl,61h
int 21h
finish: ret
pmain endp
end pmain
|
|
| "Imagination is more important than knowledge" - Albert Einstein |