0% found this document useful (0 votes)
25 views5 pages

Output: Conclusion

fgfdghjfdghufdihfh

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)
25 views5 pages

Output: Conclusion

fgfdghjfdghufdihfh

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
You are on page 1/ 5

%macro dispmsg 2

mov Rax,1
mov Rdi,1
mov rsi,%1
mov rdx,%2
syscall
%endmacro

display:
mov rbx,rax ; store no in rbx
mov rdi,result ;point rdi to result variable
mov cx,16 ;load count of rotation in cl

up1:
rol rbx,04 ;rotate no of left by four bits
mov al,bl ; move lower byte in al
and al,0fh ;get only LSB
cmp al,09h ;compare with 39h
jg add_37 ;if greater than 39h skip add 37
add al,30h
jmp skip ;else add 30
add_37:
add al,37h
skip:
mov [rdi],al ;store ascii code in result variable
inc rdi ; point to next byte
dec cx ; decrement counter
jnz up1 ; if not zero jump to repeat
dispmsg result,16 ;call to macro
ret

OUTPUT:

CONCLUSION: In this practical session, we learnt how to display any number on monitor. (Convesion
of hex to ascii number in ALP program).

15
EXP NO: 03

AIM: Write an X86/64 ALP to find the largest of given Byte/Word/Dword/64-bit numbers

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:

Datatype in 80386:

Datatypes of 80386:
The 80386 supports the following data types they are

 Bit
 Bit Field: A group of at the most 32 bits (4bytes)
 Bit String: A string of contiguous bits of maximum 4Gbytes in length.
 Signed Byte: Signed byte data
 Unsigned Byte: Unsigned byte data.
 Integer word: Signed 16-bit data.
 Long Integer: 32-bit signed data represented in 2's complement form.
 Unsigned Integer Word: Unsigned 16-bit data
 Unsigned Long Integer: Unsigned 32-bit data
 Signed Quad Word: A signed 64-bit data or four word data.
 Unsigned Quad Word: An unsigned 64-bit data.
 Offset: 16/32-bit displacement that points a memory location using any of the addressing modes.
 Pointer: This consists of a pair of 16-bit selector and 16/32-bit offset.
 Character: An ASCII equivalent to any of the alphanumeric or control characters.
 Strings: These are the sequences of bytes, words or double words. A string may contain minimum one byte and maximum 4
Gigabytes.
 BCD: Decimal digits from 0-9 represented by unpacked bytes.
 Packed BCD: This represents two packed BCD digits using a byte, i.e. from 00 to 99.

16
Registers in 80386:

 General Purpose Register: EAX, EBX, ECX, EDX


 Pointer register: ESP, EBP
 Index register: ESI, EDI
 Segment Register: CS, FS, DS, GS, ES, SS
 Eflags register: EFLAGS
 System Address/Memory management Registers : GDTR, LDTR, IDTR
 Control Register: Cr0, Cr1, Cr2, Cr3
 Debug Register : DR0, DR,1 DR2, DR3, DR4, DR5, DR6, DR7
 Test Register: TR0, TR,1 TR2, TR3, TR4, TR5, TR6, TR7

EAX AX AH,AL
EBX BX BH,BL
ECX CX CH,CL
EDX DX DH,DL
EBP BP
EDI DI
ESI SI
ESP

Size of operands in an Intel assembler instruction

 Specifying the size of an operand in Intel


 The size of the operand (byte, word, double word) is conveyed by the operand itself
 EAX means: a 32 bit operand
 AX means: a 16 bit operand
 AL means: a 8 bit operand The size of the source operand and the destination operand must be equal

Addressing modes in 80386:

The purpose of using addressing modes is as follows:

17
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

You might also like