برنامه های برنامه نویسی اسمبلی از تمام تمرینات فصل 5

stacksg segment stack
db 32 dup("stack----")
stacksg ends
datasg segment para 'data'
byte1 db 80h
byte2 db 40h
word1 dw 8000h
word2 dw 2000h
dword1 dd 80000000
dword2 dd 20000000
datasg ends
codesg segment para 'code'
main proc far
assume ss:stacksg,ds:datasg,cs:codesg
push ds
push 0
mov ax,datasg
mov ds,ax

mov al,byte1
mul byte2 ;byte1*byte2 in ax
mov ax,word1
mul word2 ;word1*word2 in dx:ax
mov al,byte1
sub ah,ah
mul word1 ;byte1*word1 in dx:ax

mul dword2 ;doubleword*doubleword

mov al,byte1
imul byte2
mov ax,word1
imul word2
mov al,byte1
cbw
imul word1

imul dword2
mov ax,4c00h
int 21h
main endp
codesg ends
end main

////////////////////////////////////////////////////////////////////////

stksg segment stack
db 64 dup("stack")
stksg ends
datasg segment para 'data'
byte1 db 64h
byte2 db 40h
byte3 db 16h
word1 dw 4000h
word2 dw 2000h
word3 dw 1000h
datasg ends
codesg segment para 'code'
main proc far
assume ds:datasg,cs:codesg
mov al,byte1
mov bl,byte2
add al,bl ;register to register
add al,byte3 ;memory to register
add byte1,bl ;register to memory
add bl,10h ;immediata to register
add byte1,25h ;immedata to memory

mov ax,word1
mov bx,word2
sub ax,bx ;register from register
sub ax,word3 ;memory from register
sub word1,bx ;register from memory
sub bx,1000h ;immediata from register
sub word1,256h ;immediata from memory

mov ax,4c00h
int 21h
main endp
codesg ends
end main

/////////////////////////////////////////////////////////////////////////////

.model small
.stack 64
.data
word1a dw 0bc62h
word1b dw 0123h
word2a dw 553ah
word2b dw 0012h
word3a dw ?
word3b dw ?

.code
main proc far
mov ax,@data
mov ds,ax
mov ax,word1a ;add leftmost word
add ax,word2a
mov word3a,ax
mov ax,word1b ;add reightmost word
add ax,word2b ;with carry
mov word3b,ax

mov ax,4c00h
int 21h
main endp
end main

//////////////////////////////////////////////////////////////////////////////////

.model small
.stack 64
cr equ 0dh
lf equ 0ah
.data
msg db 'evaluation of expression',cr,lf
db '<<-(x+y-2z+1)>> completed',"$"
x dw 5
y dw 10
z dw 6
.code
main proc far
mov ax,@data
mov ds,ax
mov dx,x ;dx=x
add ax,y ;dx=x+y
mov ax,z ;ax=z
add ax,ax ;ax=2z
sub dx,ax ;dx-ax=x+y-2z
inc dx ;dx=x+y-2z+1
neg dx ;dx=-(x+y-2z+1)

mov dx,offset msg
mov ah,9h
int 21h

mov ax,4c00h
int 21h
main endp
end main

//////////////////////////////////////////////////////////////////////////////////

.model small
.stack 64
.data
multcan dw 2521h
dw 3206h
multplr dw 0a26h
dw 6400h
product dw 0
dw 0
dw 0
dw 0

.code
main proc far
mov ax,@data
mov ds,ax

mov ax,multcan ;multiply heft word of
mul multplr+2 ;multiplication
mov product,ax ;store product
mov product+2,dx
mov ax,multcan+2 ;multiply right word of
mul multplr+2 ;multiplicad
add product+2,ax ;add to stored product
adc product+4,dx

mov product,0000
mov product+2,0000
mov product+4,0000
mov product+6,0000

mov ax,multcan ;multipcand word 1
mul multplr ;*multiplier word 1
mov product+0,ax ;store product
mov product+2,ax
mov ax,multcan ;multicand word 1
mul multplr+2 ;*multiplier word 2
add product+2,ax ;add to stored product
adc product+4,dx
adc product+6,00 ;add any carry
mov ax,multcan+2 ;multcand word 2
mul multplr ;*muliplier word 1
add product+2,ax;add to stored product
adc product+4,ax
adc product+6,0 ;add any carry
mov ax,multcan+2;multicand word 2
mul multplr+2 ;*multiplier word 2
adc product+4,ax;add to product
adc product+6,dx
mov ax,4c00h
int 21h
main endp
end main

///////////////////////////////////////////////////////////////////

.model small
.stack 64
.data
byte1 db 80h
byte3 db 16h
word1 dw 2000h
word2 dw 0010h
word3 dw 1000h

.code
main proc far
mov ax,@data
mov dx,ax

mov ax,word1 ;word/byte
div byte1 ;reminder:quote in ah:al
mov al,byte1 ;byte/byte
sub ah,ah ;exended dividend in ah
div byte3 ;reminder:quote in ah:al
mov dx,word2 ;doubiewrd/word
mov ax,word3 ;dividend in dx:ax
div word1 ;reminder:quoto in dx:ax
mov ax,word1 ;word/word
sub dx,ax ;exended dividend in dx
div word3 ;reminder:quote in dx:ax

mov ax,word1 ;word/byte
idiv byte1
mov al,byte1
cbw
idiv byte3
mov dx,word2
mov ax,word3
idiv word1
mov ax,word1
cwd
idiv word3
mov ax,4c00h
int 21h
main endp
end main

1 نظر

  1. نیلوفرنیلوفرsays:

    زندگی کنید برای رویاهایی که منتظر حقیقی شدن به دست شما هستند. کافی است لحظات گذشته را رها کرده و برای ثانیه های آینده زندگی کنید. چون رویاهایتان آنجاست و شما فقط و فقط یکبار فرصت زندگی کردن دارید . top700.com