แสดงบทความที่มีป้ายกำกับ Assembly แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ Assembly แสดงบทความทั้งหมด

วันพุธที่ 8 มีนาคม พ.ศ. 2560

Assembly code [ การคัดลอกข้อความจาก ข้อความต้นทางไปปลายทาง แบบกลับด้าน ]

Ex. 9 การคัดลอกข้อความจาก ข้อความต้นทางไปปลายทาง แบบกลับด้าน
data_s segment
str1 db 'daikyo'
str2 db 5 dup(?)
data_s ends
code_s segment
           
main    proc
            assume ds:data_s;cs:code_s
            mov ax,data_s
            mov ds,ax
            mov es,ax
            lea si,str1+6
            lea di,str2
            std
            mov cx,6
move:  
            movsb
            add di,2
            loop move
            mov str2[di],'$'
            lea dx,str2
            mov ah,09h
            int 21h
            mov ah,4ch      
            int 21h
main     endp
code_s ends
end main
x
x

Assembly code [การคัดลอกข้อความจาก ข้อความต้นทางไปปลายทาง]

Ex. 8 การคัดลอกข้อความจาก ข้อความต้นทางไปปลายทาง  

data_s segment
str1 db 'daikyo$'
str2 db 7 dup(?)
data_s ends
code_s segment
           
main    proc
            assume ds:data_s;cs:code_s
            mov ax,data_s
            mov ds,ax
            mov es,ax
            lea si,str1
            lea di,str2
            mov cx,7
move:  
            movsb
            loop move
            lea dx,str2
            mov ah,09h
            int 21h
            mov ah,4ch      
            int 21h
main     endp
code_s ends
end main
x

Assembly code [ แสดงข้อความที่พิมพ์เข้าไป ]

Ex. 7 แสดงข้อความที่พิมพ์เข้าไป
dseg     segment
;string buffer
maxlen  db        30                    ;29 chars + 1 return
msglen  db        ?
msg                  db        30 dup (?)        ;29 chars + 1 return
;newline string
newline db        10,13,'$'          
dseg     ends

sseg      segment            stack
            db        100h dup (?)
sseg      ends

cseg     segment
            assume             cs:cseg,ds:dseg,ss:sseg
start:
            mov      ax,dseg             ;set DS
            mov      ds,ax
           
            mov      ah,0Ah             ;read string
            mov      dx,offset maxlen
            int         21h
           
            mov      ah,09h                          ;newline
            mov      dx,offset newline
            int         21h
           
            mov      bl,msglen          ;get string length
            mov      bh,0
           
            mov      msg[bx],'$'       ;terminate string

            mov      ah,09h              ;display it
            mov      dx,offset msg
            int         21h
            mov      ax,4C00h         ;bye-bye
            int         21h
cseg     ends    
end       start

Assembly code [ แสดง * อยู่บริเวณกึ่งกลางจอ ]

Ex. 5 แสดง * อยู่บริเวณกึ่งกลางจอ 


.model small

.stack 100h
.data
m1 db "a$"
.code
main     proc

                                mov      ax,@data

                                mov      ds,ax
                                mov      ah,2
                                xor                   bh,bh
                                mov      dh,0CH
                                mov      dl,27H
                                int                     10h
                                sub                   dx,dx
                                ;lea                   dx,m1
                                ;mov     ah,9
                                mov      ah,2
                                mov      dl,'*'
                                int                     21h
                Mov     ah,2       
                Mov     dl,0dh
                Int        21h
                Mov     dl,0ah
                Int        21h
                                mov      ah,4ch
                                int                     21h
main     endp
end                   main
x

Assembly code [ แสดงสั่งกระโดด ]

Ex. 3 แสดงสั่งกระโดด
.model  small

.data
msg1 db 'AL more than CL','$'
msg2 db 'AL less than CL','$'

.code
start:
            mov ax,@data
            mov ds,ax
            mov al,5
            mov cl,0
            cmp al,cl
            jg  more
            lea dx,msg2
            mov ah,9
            int 21h
more:
            lea dx,msg1
            mov ah,9
            int 21h

        mov     ax,4C00h  ;exit
        int     21h
end     start






Assembly code [ การคูณ หาร ] Multiply Divide

Ex. 1 การคูณ  
.model small
.stack 100h
.data
X equ 3
Y equ 3           
Z equ 2
.code
;X+Y-2Z+1
Main                proc

            mov      al,X
            mov      bl,Y
            mul                   bl
            add      al,48
            ;mov     sum ,al
            mov      ah,2
                        mov      dl,al
            int         21h
            Mov     ah,2     
            Mov     dl,0dh
            Int        21h
            Mov     dl,0ah
            Int        21h
            Mov     ah,4ch
            Int 21h
Main    endp
            End main
*********************************************************************
Ex. 2 การหาร
.model small
.stack 100h
.data
X equ 3
Y equ 3           
Z equ 2
.code
;X+Y-2Z+1
Main                proc

            mov      al,X
            mov      bl,Y
            mul                   bl
            add      al,48
            ;mov     sum ,al
            mov      ah,2
                        mov      dl,al
            int         21h
            Mov     ah,2     
            Mov     dl,0dh
            Int        21h
            Mov     dl,0ah
            Int        21h
            Mov     ah,4ch
            Int 21h
Main    endp
            End main




Assembly code [ การใช้งาน macro ]

Ex. 10 การใช้งาน macro  
.model small

.data
msg      db 'test' ,'$'

.code
dspm    MACRO str
                        lea dx,str
                        mov      ah,9
                        int                     21h
                        ENDM
main     proc
                        mov      ax,@data
                        mov      ds,ax
                        dspm    msg
                        mov      ah,4ch
                        int         21h

main     endp
                        end main
Ex. 11 การใช้งาน macro 

dseg segment
org 100h
msg db 'this message is displayed on screen$'
dseg ends
cseg    segment
dspmsg  macro
                        lea dx,msg
                        mov ah,9
                        rept 10
                        int 21h
                        endm
                        endm

n_line   macro
            mov ah,2
            mov      dl,0ah
            int         21h
            mov      dl,0dh
            int         21h
            endm      
main     proc
             assume cs:cseg; ds:dseg
        dspmsg
             n_line

        mov          ax,4c00h       ;exit program
        int 21h
main     endp

cseg    ends
        end           main

Search Table Name of all database [ ค้นหาชือ Table ใน Database server ทั้งหมด ]

  -------------- -- Search Table Name inside database server -- 1. -------------- DECLARE @SearchTerm NVARCHAR ( 100 ) = '% TableN...