Posts

Showing posts from February, 2021

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

 %macro disp 2     mov rax,01h mov rdi,01h mov rsi,%1 mov rdx,%2 syscall %endmacro %macro inp 2 mov rax,00h mov rdi,00h mov rsi,%1 mov rdx,%2 syscall %endmacro section .data msg1 db "enter first 8 bit hex no:",10 len1: equ $-msg1 msg2 db "enter second 8 bit hex no:",10 len2: equ $-msg2 msg3 db "Addition result is:",10 len3: equ $-msg3 section .bss   num1 resb 3 num2 resb 3   res resb 02 section .text global _start _start: disp msg1,len1 inp num1,03 disp msg2,len2 inp num2,03 mov rsi,num1 mov cl,04 xor bx,bx mov ch,02 up: cmp byte[rsi],39h jng sk sub byte[rsi],07h sk: sub byte[rsi],30h shl bx,cl add  bl,[rsi] inc rsi dec ch jnz up xor dx,dx mov rsi,num2 mov cl,04 mov ch,02 up1: cmp byte[rsi],39h jng sk1 sub byte[rsi],07h sk1: sub byte[rsi],30h shl dx,cl add dl,[rsi] inc rsi dec ch jnz up1 add bl,dl mov al,bl mov rsi,res mov ch,02 mov cl,04 again1: rol al,cl mov bl,al and bl,0fh cmp bl,09h jng skip2 add bl,07h skip2: add bl,30h mov [rsi],bl inc rsi ...

Write an X86/64 ALP to accept five 64 bit Hexadecimal numbers from user and store them in an array and display the accepted numbers.

Image
 

Write an X86/64 ALP to accept a string and to display its length.

 ;String length in Assembly Lanuguage ;macros begin %macro write 2    ;will be used to write on the screen mov rax,01h mov rdi,0h mov rsi,%1 mov rdx,%2 syscall %endmacro %macro read 2    ;will be used to read from the screen mov rax,0h mov rdi,1h mov rsi,%1 mov rdx,%2 syscall %endmacro ;macros end section .data len1: equ $-msg1 msg2: db "Enter the string ",10 len2: equ $-msg2 msg3 : db "The length of the string is " len3: equ $-msg3 section .bss orgstr resb 50  ;original string wordlen resb 1  ;length of the string ascii resb 2  ;len in ascii count resb 1 section .text global _start: _start: write msg2,len2   ;display message length:   ;the length option mov al,0  ;initialize al with zero read orgstr,50 mov byte[wordlen],al dec byte[wordlen] ;now len has the length of the string without the null character mov esi,wordlen mov edi,ascii mov byte[count],2 mov al,byte[esi] loop: rol al,04 mov bl,al and bl,0Fh cmp bl,09h jbe no...

Control Transfer Instructions

Image
 

Shift and Rotate Instructions

Image
 

Logical Instructions

Image
 

Binary Arithmatic Instructions

Image