0% found this document useful (0 votes)
18 views6 pages

List of Interrrupts Used: List of Assembler Directives Used: List of Macros Used: List of Procedures Used: Algorithm: Flowchart

fhfdughfgfghfdg

Uploaded by

patyogendra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

List of Interrrupts Used: List of Assembler Directives Used: List of Macros Used: List of Procedures Used: Algorithm: Flowchart

fhfdughfgfghfdg

Uploaded by

patyogendra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. To give the programming versatility to the user.

2. To reduce the number of bits in addressing field of instruction.

1. Register addressing mode: MOV EAX, EDX


2. Immediate Addressing modes: MOV ECX, 20305060H
3. Direct Addressing mode: MOV AX, [1897 H]
4. Register Indirect Addressing mode MOV EBX, [ECX]
5. Based Mode MOV ESI, [EAX+23H]
6. Index Mode SUB COUNT [EDI], EAX
7. Scaled Index Mode MOV [ESI*8], ECX
8. Based Indexed Mode MOV ESI, [ECX][EBX]
9. Based Index Mode with displacement EA=EBX+EBP+1245678H
10. Based Scaled Index Mode with displacement MOV [EBX*8] [ECX+5678H], ECX
11. String Addressing modes:
12. Implied Addressing modes:

LIST OF INTERRRUPTS USED:

LIST OF ASSEMBLER DIRECTIVES USED:

LIST OF MACROS USED:

LIST OF PROCEDURES USED:

ALGORITHM:

FLOWCHART:

18
EXP NO: 04

AIM: Write a switch case driven X86/64 ALP to perform 64-bit hexadecimal arithmetic operations (+,-
,*, /) using suitable macros. Define procedure for each operation.
OBJECTIVES:

 To understand assembly language programming instruction set.


 To understand different assembler directives with example.
 To apply instruction set for implementing X86/64 bit assembly language programs

ENVIRONMENT:

 Operating System: 64-bit Open source Linux or its derivative.


 Programming Tools: Preferably using Linux equivalent or MASM/TASM/NASM/FASM.
 Text Editor: geditor

THEORY:

LIST OF INTERRRUPTS USED: 80h

LIST OF ASSEMBLER DIRECTIVES USED: equ, db

LIST OF MACROS USED: scall

LIST OF PROCEDURES USED: add_proc, sub_proc, mul_proc, div_proc, disp64num

ALGORITHM:

FLOWCHART:

PROGRAM:

section .data
menumsg db 10,'****** Menu ******',
db 10,'1: Addition'
db 10,'2: Subtraction'
db 10,'3: Multiplication'
db 10,'4: Division'
db 10,10,'Enter your choice:: '

menumsg_len: equ $-menumsg

19
addmsg db 10,'Welcome to additon',10
addmsg_len equ $-addmsg

submsg db 10,'Welcome to subtraction',10


submsg_len equ $-submsg

mulmsg db 10,'Welcome to Multiplication',10


mulmsg_len equ $-mulmsg

divmsg db 10,'Welcome to Division',10


divmsg_len equ $-divmsg

wrchmsg db 10,10,'You Entered a Wrong Choice....!',10


wrchmsg_len equ $-wrchmsg

no1 dq 08h
no2 dq 02h

nummsg db 10
result dq 0

resmsg db 10,'Result is:'


resmsg_len equ $-resmsg

qmsg db 10,'Quotient::'
qmsg_len equ $-qmsg

rmsg db 10,'Remainder::'
rmsg_len equ $-rmsg

nwmsg db 10
resh dq 0
resl dq 0

section .bss
choice resb 2
dispbuff resb 16

%macro scall 4
mov rax,%1
mov rdi,%2
mov rsi,%3
mov rdx,%4
syscall
%endmacro

section .text
global _start
_start:
up:
scall 1,1,menumsg,menumsg_len
scall 0,0,choice,2

case1:cmp byte[choice],'1'

20
jne case2
call add_proc
jmp up

case2:
cmp byte[choice],'2'
jne case3
call sub_proc
jmp up

case3:
cmp byte[choice],'3'
jne case4
call mul_proc
jmp up
case4:
cmp byte[choice],'4'
jne caseinv
call div_proc
jmp up
caseinv:
scall 1,1, wrchmsg,wrchmsg_len

exit:
mov eax,01
mov ebx,0
int 80h

add_proc:
mov rax,[no1]
adc rax,[no2]
mov [result],rax
scall 1,1,resmsg,resmsg_len
mov rbx,[result]
call disp64num
scall 1,1,nummsg,1
ret

sub_proc:

mov rax,[no1]
subb rax,[no2]
mov [result],rax
scall 1,1,resmsg,resmsg_len
mov rbx,[result]
call disp64num
scall 1,1,nummsg,1
ret

mul_proc:
scall 1,1,mulmsg,mulmsg_len
mov rax,[no1]
mov rbx,[no2]

21
mul rbx
mov [resh],rdx
mov [resl],rax
scall 1,1, resmsg,resmsg_len
mov rbx,[resh]
call disp64num
mov rbx,[resl]
call disp64num
scall 1,1,nwmsg,1
ret
div_proc:
scall 1,1,divmsg,divmsg_len
mov rax,[no1]
mov rdx,0
mov rbx,[no2]
div rbx
mov [resh],rdx ;Remainder
mov [resl],rax ;Quotient
scall 1,1, rmsg,rmsg_len
mov rbx,[resh]
call disp64num
scall 1,1, qmsg,qmsg_len
mov rbx,[resl]
call disp64num
scall 1,1, nwmsg,1
ret
disp64num:
mov ecx,16
mov edi,dispbuff
dup1:
rol rbx,4
mov al,bl
and al,0fh
cmp al,09
jbe dskip
add al,07h
dskip: add al,30h
mov [edi],al
inc edi
loop dup1
scall 1,1,dispbuff,16
ret

CONCLUSION:

22
EXP NO: 05

AIM: Write an X86/64 ALP to count number of positive and negative numbers from the array.

OBJECTIVES:

 To understand assembly language programming instruction set.


 To understand different assembler directives with example.
 To apply instruction set for implementing X86/64 bit assembly language programs

ENVIRONMENT:

 Operating System: 64-bit Open source Linux or its derivative.


 Programming Tools: Preferably using Linux equivalent or MASM/TASM/NASM/FASM.
 Text Editor: geditor

THEORY:

Mathematical numbers are generally made up of a sign and a value (magnitude) in which the sign
indicates whether the number is positive, ( + ) or negative, ( – ) with the value indicating the size of the
number, for example 23, +156 or -274. Presenting numbers is this fashion is called “sign-magnitude”
representation since the left most digit can be used to indicate the sign and the remaining digits the
magnitude or value of the number.
Sign-magnitude notation is the simplest and one of the most common methods of representing positive
and negative numbers either side of zero, (0). Thus negative numbers are obtained simply by changing
the sign of the corresponding positive number as each positive or unsigned number will have a signed
opposite, for example, +2 and -2, +10 and -10, etc.
But how do we represent signed binary numbers if all we have is a bunch of one’s and zero’s. We know
that binary digits, or bits only have two values, either a “1” or a “0” and conveniently for us, a sign also
has only two values, being a “+” or a “–“.
Then we can use a single bit to identify the sign of a signed binary number as being positive or negative
in value. So to represent a positive binary number (+n) and a negative (-n) binary number, we can use
them with the addition of a sign.
For signed binary numbers the most significant bit (MSB) is used as the sign bit. If the sign bit is “0”,
this means the number is positive in value. If the sign bit is “1”, then the number is negative in value.
The remaining bits in the number are used to represent the magnitude of the binary number in the usual
unsigned binary number format way.
Then we can see that the Sign-and-Magnitude (SM) notation stores positive and negative values by
dividing the “n” total bits into two parts: 1 bit for the sign and n–1 bits for the value which is a pure
binary number. For example, the decimal number 53 can be expressed as an 8-bit signed binary number
as follows.

23

You might also like