‏إظهار الرسائل ذات التسميات Assembly. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات Assembly. إظهار كافة الرسائل
الاثنين، 5 مايو 2014

Q8: find even number from 1000 to 2000


org 100h

.data
dt1 dw 500 dup(0)

.code 

 mov ax,@data
 mov ds,ax

 mov si, offset dt1

 mov bx,1000
 mov cx,500
 label:
 mov [si],bx
 add bx,0002
 inc si
 inc si
 loop label

hlt

note: see in memory in two byte CE and 06 equal 1998 , so it down 1996 see cc,07


another way for find even number from 1000 to 1500:

org 100h

.data
dt1 db 250 dup(0)
.code
mov ax,@data
mov ds,ax
mov si,offset dt1
mov cx,1000
mov bx,02

new:
    mov [si],cx
    add cx,bx
    add si,bx
    cmp cx,1500
    jle new

ret
الخميس، 24 أبريل 2014

َQ6:datasheet to find y=x2-10+x in assembly

org 100h

.data
dt1 db 1,2,3,4,5,6,7,8,9,10
dt2 db 10 dup(0)
.code
mov ax,@data
mov ds,ax
mov si,offset dt1
mov di,offset dt2
mov cx,0ah
lable:
mov ax,[si] 
mov bx,2
mul bx
sub ax,10
add ax,[si]   
mov [di],ax
inc si
inc di
loop lable

ret

الاثنين، 7 أبريل 2014

Q9:datasheet find sum and average

org 100h

.data
dt1 db  1,2,3,4,5,6,7,8,9,10
dt2 db 2 DUP(0)
.code
mov ax,@data
mov ds,ax
mov si,offset dt1
mov di,offset dt2 
MOV CX,0aH
MOV Ax,0000H
MOV BX,0000H
label:
MOV Bl,[si]
ADD Ax,Bx
INC SI
LOOP label
MOV [DI],Ax
MOV BL,0ah
DIV BL
inc di
MOV [DI],Ax
hlt



Q4:datasheet


org 100h

.data
dt1 dB  55,45,10,64,96
dt2 db 1 DUP(0)
.code
mov ax,@data
mov ds,ax
mov si,offset dt1
mov di,offset dt2 
MOV CX,5H
MOV Ax,0000H
MOV BX,0000H
label:
MOV Bl,[si]
ADD Ax,Bx
INC SI
LOOP label
MOV BL,5H
DIV BL
MOV [DI],Ax
hlt

ret

Q1:datasheet find area of square

org 100h 

.data
dt1 db 1,2,3,4,5,6,7,8,9,10
dt2 db 10 cup(0)  // for put zero in 3 location at once

.code
mov si,offset dt1
mov di,offset dt2

mov ax,@data
mov ds,ax

mov cx,000ah
label:
mov ax,0000h
mov al,[si]
mul al 
mov [di],al
inc si
inc di 
loop label
ret

Q3: Convert capital Character to small Character (lowercase)

org 100h

.data
dt1 dB  'COMPUTER'
dt2 db 8 dup(0)
.code
mov ax,@data
mov ds,ax
mov si,offset dt1
mov di,offset dt2 
MOV BL,20H
MOV CX,08
label:

MOV AL,[si]
ADD AL,BL
MOV [DI],Al
INC SI
INC DI
LOOP label
hlt






another way :-
-to convert small Character  to capital Character only when find

org 100h

.DATA
DT1 DB 'University Of Technology' 
DT2 DB 24 DUP(0) 
.CODE 
 MOV AX,@DATA
 MOV DS,AX 
 MOV SI,OFFSET DT1 
 MOV DI,OFFSET DT2 
 MOV BX,0000H 
 MOV CX,18H 

 A:MOV AL,[SI+BX] 
 CMP AL,'a' 
 JGE L 
 JMP X 

 L:CMP AL,'z' 
 JLE L1 
 JMP X 

 L1:SUB AL,20H

 X:MOV [DI+BX],AL 
 INC BX 
 LOOP A

HLT

Q2:data sheet find area of rectangle

org 100h

.data
dt1 db 1,2,3,4,5,6,7,8,9,10
dt2 db 5 dup(0)

.code
mov si,offset dt1
mov di,offset dt2

mov ax,@data
mov ds,ax

mov cx,000ah   

label:
mov ax,0000h
mov al,[si] 
inc si
mov ah,[si]
mul ah
mov [di],al
inc si
inc di
loop label


ret
الاثنين، 24 مارس 2014

Define Data in assembly

mov value from location in dt1 to dt2:-
org 100h 

.data
dt1 db 10
dt2 db 0  

.code
mov si,offset dt1
mov di,offset dt2

mov ax,@data
mov ds,ax

mov al,[si]
mov [di],al 

ret

find area of square and put solution in dt2:-
org 100h 

.data
dt1 db 2,4,8
dt2 db 3 dup(0)  // for put zero in 3 location at once

.code
mov si,offset dt1
mov di,offset dt2

mov ax,@data
mov ds,ax

mov cx,0003h
label:
mov ax,0000h
mov al,[si]
mul al 
mov [di],al
inc si
inc di 
loop label
ret


add 20 to offset dt1(si) and put solution in dt2(di):-
org 100h 

.data
dt1 db 1,2,3,4,5,6,7,8,9,10
dt2 db 10 dup(0)  

.code
mov si,offset dt1
mov di,offset dt2

mov ax,@data
mov ds,ax

mov cx,000ah
label:
mov ax,0000h
mov al,[si]
add al,20h 
mov [di],al
inc si
inc di 
loop label
ret



الاثنين، 17 مارس 2014

string instruction with repeated(REP)

1- move from block to another by using string instruction with repeated(REP) :

org 100h
mov ax,0h
mov ds,ax
mov es,ax
mov si,2000h  
mov di,3000h
mov cx,20h    // 32 consecutive bytes in hex=20
cld

rep movsb

hlt

2-scan number if find replace with another number else by default found in last location :

org 100h  
cld 
mov ax,0h
mov es,ax
mov ds,ax  

mov di,00d0h  
mov [di],45h // for certain replace else put 29 in the last location 

mov cx,0046h // 70 bytes

mov al,45h
repne scasb
dec di
mov byte ptr[di],29h

hlt

string instruction : STOSB

org 100h
mov ax,0h
mov ds,ax // do not need because use (di with es)
mov es,ax
mov di,0a000h
mov al,05h
mov cx,0fh
cld            // do not need because only increment
again:
stosb            // di <-- al , inc di
loop again  // dec cx
hlt

new instruction : Call and push,pop

org 100h

mov al,01h
mov ah,01h
mov dl,02h

mov cx,0000h
mov bl,al
call square
add cx,bx
mov bl,ah
call square
add cx,bx
mov bl,dl
call square
add cx,bx
         

 square: 
push ax
mov al,bl
mul bl
mov bx,ax
pop ax
ret 

hlt


note : CX must be = 6 in this example