Assembly Language Lab #4
[Pages:11]Islamic University of Gaza Computer Engineering Department
2009
Assembly Language Lab #4
Eng. Tahani Z. Fourah
Islamic University of Gaza
Assembly Language Lab #4
Boolean Instructions and Conditional Structured
1. NOT Instruction: Performs a bitwise Boolean NOT operation on a single destination operand ? Syntax: (no flag affected) NOT destination ? Example: mov al, 11110000b not al
2. AND Instruction: Performs a bitwise Boolean AND operation between each pair of matching bits in two operands ? Syntax: (O=0,C=0,SZP)
AND destination, source ? Example:
mov al, 00111011b and al, 00001111b
3. OR Instruction : Performs a bitwise Boolean OR operation between each pair of matching bits in two operands ? Syntax: (O=0,C=0,SZP) OR destination, source ? Example: mov dl, 00111011b or dl, 00001111b
23
Assembly Language Lab #4
4. XOR Instruction : Performs a bitwise Boolean exclusive-OR operation between each pair of matching bits in two operands ? Syntax: (O=0,C=0,SZP) XOR destination, source ? Example: mov dl, 00111011b xor dl, 00001111b
5. Test Instruction : Performs a nondestructive AND operation between each pair of matching bits in two operands. ? No operands are modified, but the flags are affected. ? Example: jump to a label if either bit 0 or bit 1 in AL is set. test al,00000011b jnz ValueFound ? Example: jump to a label if neither bit 0 nor bit 1 in AL is set. test al,00000011b jz ValueNotFound
24
Assembly Language Lab #4 Applications:
Conditional structures:
Assembly language programmers can easily translate logical statements written in C++/Java into assembly language. For example:
25
Assembly Language Lab #4
Implement the following pseudocode in assembly language. All values are 32bit signed integers:
Compound expression with AND:
Compound Expression with OR:
26
Assembly Language Lab #4
Lab Work:
1. Write an assembly language program that allow user to input one digit number and determine if it is even or odd
Dosseg .model small .data msg1 db 'Enter a number: ','$' msg2 db 'the number is odd','$' msg3 db 'the number is even','$' .code main: mov ax,@data mov ds,ax mov ah,9 mov dx,offset msg1 int 21h mov ah,1 int 21h and al,01 cmp al,0 je EvenNum mov ah,2 mov dl,0AH int 21h mov dl,0DH int 21h mov ah,9 mov dx,offset msg2 int 21h jmp exit EvenNum: mov ah,2 mov dl,0AH int 21h mov dl,0DH int 21h mov ah,9 mov dx,offset msg3 int 21h exit: mov ah,4ch int 21h end main
27
Assembly Language Lab #4
Another version of the program
Dosseg .model small .data msg1 db 'Enter a number: ','$' msg2 db 'the number is odd','$' msg3 db 'the number is even','$' .code main: mov ax,@data mov ds,ax mov ah,9 mov dx,offset msg1 int 21h mov ah,1 int 21h L: cmp al,0 je EvenNum cmp al,1 je OddNum sub al,2 jmp L OddNum: mov ah,2 mov dl,0AH int 21h mov dl,0DH int 21h mov ah,9 mov dx,offset msg2 int 21h jmp exit EvenNum: mov ah,2 mov dl,0AH int 21h mov dl,0DH int 21h mov ah,9 mov dx,offset msg3 int 21h exit: mov ah,4ch int 21h end main
28
Assembly Language Lab #4
2. Write an assembly language program that determine number of ones in a byte( assume that # ones are stored in bl )
Dosseg .model small .code main: mov cx,8 mov al,0A4H X: rol al,1 jc L loop X jmp exit L: add bl,1 loop X exit: mov ah,4ch int 21h end main
29
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- modify the teensyduino code from one of these teensy 3 2
- cos 301 topics programming languages
- intcollector a high performance collector for in band
- python 2 7 quick reference
- cs 61c great ideas in computer architecture introduction
- s python program its output will instructables
- this tutorial
- assembly language lab 4
- writing python 2 3 compatible code
- byte array declaration in python
Related searches
- 100 free home assembly jobs
- 4 grade language arts worksheets
- work at home assembly jobs no fees
- top assembly at home companies
- grade 4 language arts assessment
- grade 4 language arts practice
- 2019 grade 4 language arts released
- 4 stages of language development
- 4 levels of language proficiency
- grade 4 language arts test
- 4 grade english language test
- daily language grade 4 pdf