Added unchecked assignment, untested codes, README & old git commit file.
This commit is contained in:
parent
757d1dc81c
commit
b81b0e30c1
BIN
Assignments/Assignment-01.old.pdf
Normal file
BIN
Assignments/Assignment-01.old.pdf
Normal file
Binary file not shown.
229
Codes/Practical-5.asm
Normal file
229
Codes/Practical-5.asm
Normal file
@ -0,0 +1,229 @@
|
||||
; THIS CODE HAS NOT BEEN TESTED AND IS NOT FULLY OPERATIONAL.
|
||||
|
||||
; Problem Statement: Write X86/64 ALP to perform multiplication of two 8-bit hexadecimal numbers. Using successive addition and add-and-shift methods. (Use of 64-bit registers is expected).
|
||||
|
||||
; Code from Microprocessor (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/Microprocessor/
|
||||
|
||||
;------------------------------
|
||||
|
||||
%macro print 2
|
||||
mov rax,1
|
||||
mov rdi,1
|
||||
mov rsi,%1
|
||||
mov rdx,%2
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro accept 2
|
||||
mov rax,0
|
||||
mov rdi,0
|
||||
mov rsi,%1
|
||||
mov rdx,%2
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro dispmsg 2 ;macro for display
|
||||
mov rax,1 ;standard ouput
|
||||
mov rdi,1 ;system for write
|
||||
mov rsi,%1 ;display message address
|
||||
mov rdx,%2 ;display message length
|
||||
syscall ;interrupt for 64-bit
|
||||
%endmacro
|
||||
|
||||
%macro exitprog 0 ;macro for exit
|
||||
mov rax,60 ;system for exit
|
||||
mov rdx,0
|
||||
syscall ;interrupt for 64-bit
|
||||
%endmacro
|
||||
|
||||
%macro gtch 1 ;macro for accept
|
||||
mov rax,0 ;standard input
|
||||
mov rdi,0 ;system for read
|
||||
mov rsi,%1 ;input the message
|
||||
mov rdx,1 ;message length
|
||||
syscall ;interrupt for 64-bit
|
||||
%endmacro
|
||||
|
||||
section .data
|
||||
nwline db 10
|
||||
m0 db 10,10,"Program to multiply two numbers using successive addition and add-and-shift method"
|
||||
l0 equ $-m0
|
||||
m1 db 10,"1. Successive Addition Method",10,"2. Add-and-Shift Method",10,"3. Exit",10,10, "Choose an option (1/2/3 <ENTER>): "
|
||||
l1 equ $-m1
|
||||
m2 db 10,"Enter the multiplicand (2 digit HEX no): "
|
||||
l2 equ $-m2
|
||||
m3 db 10,"Enter the multiplier (2 digit HEX no): "
|
||||
l3 equ $-m3
|
||||
m4 db 10,"Multiplication using Successive Addition Method: "
|
||||
l4 equ $-m4
|
||||
m5 db 10,"Multiplication using Add-and-Shift Method: "
|
||||
l5 equ $-m5
|
||||
|
||||
section .bss
|
||||
mcand resq 1 ;reserve 1 quad for multiplicand
|
||||
mplier resq 1 ;reserve 1 quad for multiplier
|
||||
input resb 1 ;reserve 1 byte for input
|
||||
output resb 1 ;reserve 1 byte for output
|
||||
choice resb 1 ;reserve 1 byte for choice
|
||||
|
||||
section .text
|
||||
global _start ;starting of main program
|
||||
_start :
|
||||
|
||||
dispmsg m0,l0 ;displaying the menu
|
||||
|
||||
back:
|
||||
dispmsg m1,l1 ;displaying the first message
|
||||
gtch input ;to read and discard ENTER key pressed.
|
||||
|
||||
mov al, byte[input] ;get choice
|
||||
mov byte[choice],al
|
||||
|
||||
gtch input ;to read and discard ENTER key pressed.
|
||||
|
||||
mov al, byte[choice]
|
||||
|
||||
cmp al, '1' ;compare contents of al with 1
|
||||
je succ_add ;if equal the jump to succ_add procedure
|
||||
|
||||
cmp al, '2' ;compare the contents of al with 2
|
||||
je add_shift ;if equal then jump to add_shift procedure
|
||||
|
||||
cmp al, '3' ;compare the contents of al with 3
|
||||
jnz back ;if not zero then jump to back
|
||||
exitprog ;exit program
|
||||
|
||||
;-------- SUCCESSIVE ADDITION METHOD ---------
|
||||
succ_add: ;successive addition procedure
|
||||
dispmsg m2,l2 ;Displaying the second message
|
||||
call getnum ;call getnum procedure
|
||||
mov [mcand],rax ;mov contents of rax(multiplicand) into mcand buffer
|
||||
gtch input ;to read and discard ENTER key pressed
|
||||
|
||||
dispmsg m3,l3 ;Displaying the third message
|
||||
call getnum ;call getnum procedure
|
||||
mov [mplier],rax ;mov contents of rax(multiplier) into mplier buffer
|
||||
gtch input ;to read and discard ENTER key pressed
|
||||
|
||||
mov rax,0 ;clearing the rax register
|
||||
dispmsg m4,l4 ;displaying the fourth message
|
||||
call succ_addition ;call the successive addition method
|
||||
jmp back ;jump to back
|
||||
|
||||
;-------- ADD AND SHIFT METHOD ---------
|
||||
add_shift: ;add and shift procedure
|
||||
dispmsg m2,l2 ;Displaying the second message
|
||||
call getnum ;call getnum procedure
|
||||
mov [mcand],rax ;mov contents of rax(multiplicand) into mcand buffer
|
||||
gtch input ;to read and discard ENTER key pressed
|
||||
|
||||
dispmsg m3,l3 ;Displaying the third message
|
||||
call getnum ;call getnum procedure
|
||||
mov [mplier],rax ;mov contents of rax(multiplier) into mplier buffer
|
||||
gtch input ;to read and discard ENTER key pressed
|
||||
|
||||
mov rax,0 ;clearing the rax register
|
||||
dispmsg m5,l5 ;displaying the fifth message
|
||||
call add_and_shift ;call the add-and-shift method
|
||||
jmp back ;jump to back
|
||||
|
||||
getnum: ;procedure to get a 2 digit hex no from user
|
||||
; number returned in rax
|
||||
|
||||
mov cx,0204h ;02 digits to display and 04 count to rotate
|
||||
mov rbx,0 ;clearing rbx register
|
||||
|
||||
ll2: ;loop 2
|
||||
push rcx ;syscall destroys rcx.Rest all regs are preserved
|
||||
gtch input ;to read and discard ENTER key pressed
|
||||
pop rcx ;pop the contents of rcx
|
||||
|
||||
mov rax,0 ;clearing the contents of rax
|
||||
mov al,byte[input] ;get choice
|
||||
sub rax,30h ;subtract 30h from contents of rax
|
||||
cmp rax,09h ;compare the contents of rax register with 09h
|
||||
jbe skip1 ;if equal then jump below to skip1 label
|
||||
sub rax,7 ;subtract 7 from contents of rax register
|
||||
|
||||
skip1: ;skip1 label
|
||||
shl rbx,cl ;shift multiplicand and count to the left
|
||||
add rbx,rax ;add contents of rax register to the contents of rbx register
|
||||
dec ch ;decrement the contents of ch register
|
||||
jnz ll2 ;if not zero then jump to loop 2
|
||||
mov rax,rbx ;mov contents of rbx register into rax register
|
||||
ret ;return
|
||||
|
||||
succ_addition: ;procedure for successive addition
|
||||
mov rax,0 ;clearing rax register
|
||||
mov rcx,8 ;taking count of 8 in rcx register
|
||||
mov dl,[mplier] ;multiplier is 8 bits so it occupies dl
|
||||
mov bl,[mcand] ;multiplicand is 8 bits so it occupies bl
|
||||
|
||||
;we will put Q in higher 8 bits of ax (i.e. ah)
|
||||
;and multiplier in lower 8 bits of ax (i.e. al)
|
||||
|
||||
mov ah,0 ;clearing ah register
|
||||
mov al,dl ;ah already 0 and al now contains multiplier
|
||||
|
||||
ll3: ;loop 3 (s3)
|
||||
mov dh,al ;mov contents of al into dh as dh is used as temporary
|
||||
and dh,1 ;check d0 bit of multiplier
|
||||
jz ll8 ;if d0 bit was zero, Z flag will be set (s2)(if zero jmp to loop 8)
|
||||
add ah, bl ;d0 bit of multiplier is set
|
||||
;so add multiplicand to Q(add bl into ah)
|
||||
|
||||
ll8: ;loop 8 (s2)
|
||||
shr ax,1 ;shift both Q (ah) and multiplier (al) right 1 bit
|
||||
dec rcx ;decrement contents of rcx
|
||||
jnz ll3 ;if not zero then jump to loop 3 (s3)
|
||||
call dispnum ;call procedure dispnum
|
||||
ret ;return
|
||||
|
||||
add_and_shift: ;procedure for add-and-shift method
|
||||
mov rax,0 ;clearing rax register
|
||||
mov rcx,8 ;taking count of 8 in rcx register
|
||||
mov dl,[mplier] ;multiplier is 8 bits so it occupies dl
|
||||
mov bl,[mcand] ;multiplicand is 8 bits so it occupies bl
|
||||
|
||||
;we will put Q in higher 8 bits of ax (i.e. ah)
|
||||
;and multiplier in lower 8 bits of ax (i.e. al)
|
||||
|
||||
mov ah,0 ;clearing ah register
|
||||
mov al,dl ;ah already 0 and al now contains multiplier
|
||||
|
||||
ll3_shift: ;loop 3 (s3) for add-and-shift
|
||||
mov dh,al ;mov contents of al into dh as dh is used as temporary
|
||||
and dh,1 ;check d0 bit of multiplier
|
||||
jz ll8_shift ;if d0 bit was zero, Z flag will be set (s2)(if zero jmp to loop 8)
|
||||
add ah, bl ;d0 bit of multiplier is set
|
||||
;so add multiplicand to Q(add bl into ah)
|
||||
|
||||
ll8_shift: ;loop 8 (s2) for add-and-shift
|
||||
shl ax,1 ;shift both Q (ah) and multiplier (al) left 1 bit
|
||||
dec rcx ;decrement contents of rcx
|
||||
jnz ll3_shift ;if not zero then jump to loop 3 (s3) for add-and-shift
|
||||
call dispnum ;call procedure dispnum
|
||||
ret ;return
|
||||
|
||||
dispnum: ;procedure to display the result
|
||||
mov rbx,rax ;move contents of rax register into rbx register
|
||||
mov rcx,1004h ;16 digits to display and 04 count to rotate
|
||||
|
||||
ll6: ;loop 6
|
||||
rol rbx,cl ;rotate multiplicand and count to the left
|
||||
mov rdx,rbx ;mov contents of rbx register into rdx register
|
||||
and rdx,0fh ;anding contents of rdx register with 0fh
|
||||
add rdx,30h ;adding contents of rdx register with 30h
|
||||
cmp rdx,039h ;comparing the contents of rdx register with 39h
|
||||
jbe skip4 ;if equal then jump below to skip4 label
|
||||
add rdx,7 ;add 7 to the contents of rdx register
|
||||
|
||||
skip4: ;skip4 label
|
||||
mov byte[output],dl ;mov contents of dl register into output buffer in bytes
|
||||
push rcx ;push the contents of rcx register
|
||||
dispmsg output,1 ;displaying the output
|
||||
pop rcx ;pop the contents of rcx
|
||||
dec ch ;decrement the count(contents of ch)
|
||||
jnz ll6 ;if not zero the jump to loop 6
|
||||
ret ;return
|
||||
|
157
Codes/Practical-6.asm
Normal file
157
Codes/Practical-6.asm
Normal file
@ -0,0 +1,157 @@
|
||||
; THIS CODE HAS NOT BEEN TESTED AND IS NOT FULLY OPERATIONAL.
|
||||
|
||||
; Problem Statement: Write X86/64 ALP to convert 4-digit Hex number into its equivalent BCD number and 5-digit BCD number into its equivalent HEX number.
|
||||
; Make your program user friendly to accept the choice from user for: (a) HEX to BCD b) BCD to HEX (c) EXIT.
|
||||
; Display proper strings to prompt the user while accepting the input and displaying the result. (wherever necessary, use 64-bit registers.)
|
||||
|
||||
; Code from Microprocessor (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/Microprocessor/
|
||||
|
||||
; BEGINNING OF CODE
|
||||
%macro print 2
|
||||
mov rax,1
|
||||
mov rdi,1
|
||||
mov rsi,%1
|
||||
mov rdx,%2
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro accept 2
|
||||
mov rax,0
|
||||
mov rdi,0
|
||||
mov rsi,%1
|
||||
mov rdx,%2
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
section .data
|
||||
|
||||
title db 10,"An ALP to convert BCD to HEX and vise-versa.",10
|
||||
title_len equ $-title
|
||||
|
||||
menu db 10,"------ Select an option ------",10,"1 -> HEX to BCD",10,"2 -> BCD to HEX",10,"3 -> Exit",10
|
||||
menu_len equ $-menu
|
||||
|
||||
hex_in db 10,"Enter your 4 digit HEX number: ",10
|
||||
hex_inlen equ $-hex_in
|
||||
|
||||
bcd_out db 10,"The equivalent BCD number is: ",10
|
||||
bcd_out_len equ $-bcd_out
|
||||
|
||||
bcd_in db 10,"Enter your BCD number: ",10
|
||||
bcd_inlen equ $-bcd_in
|
||||
|
||||
hex_out db 10,"The equivalent HEX number is: ",10
|
||||
hex_out_len equ $-hex_out
|
||||
|
||||
section .bss
|
||||
numascii resb 6 ;for input
|
||||
opbuff resb 5 ;to
|
||||
dnumbuff resb 08
|
||||
|
||||
section .txt
|
||||
global _start:
|
||||
_start:
|
||||
|
||||
print title,title_len
|
||||
print menu,menu_len
|
||||
accept numascii,2 ;input user choice using accept macro(2 bytes-1 for choice and 1 for enter)
|
||||
cmp byte[numascii],'1' ;ascii of 1 is 31
|
||||
jne case2
|
||||
call hextobcd
|
||||
|
||||
case2:
|
||||
cmp byte[numascii],'2'
|
||||
jne case3
|
||||
call bcdtohex
|
||||
|
||||
case3:
|
||||
cmp byte[numascii],'3'
|
||||
je exit
|
||||
|
||||
exit:
|
||||
mov rax,60
|
||||
mov rdx,0
|
||||
syscall
|
||||
|
||||
hextobcd:
|
||||
print hex_in,hex_inlen
|
||||
accept numascii,5
|
||||
call packnum
|
||||
mov rcx,0
|
||||
mov ax,bx
|
||||
mov bx,0Ah
|
||||
|
||||
h2bup1:
|
||||
mov rax, 0 ; Clear rax before each division
|
||||
div bx
|
||||
push rdx
|
||||
inc rcx
|
||||
cmp ax,0
|
||||
jne h2bup1
|
||||
|
||||
h2bup2:
|
||||
pop rdx
|
||||
add dl,30h
|
||||
mov [rdi],dl
|
||||
inc rdi
|
||||
dec rcx
|
||||
jnz h2bup2
|
||||
|
||||
packnum:
|
||||
mov bx,0
|
||||
mov rcx,4
|
||||
mov rsi,numascii
|
||||
|
||||
up1:
|
||||
rol bx,04
|
||||
mov al,[rsi]
|
||||
cmp al,39h
|
||||
jbe skip1
|
||||
sub al,07h
|
||||
|
||||
skip1:
|
||||
sub al,30h
|
||||
add bl,al
|
||||
inc rsi
|
||||
loop up1
|
||||
ret
|
||||
|
||||
bcdtohex:
|
||||
print bcd_in,bcd_inlen
|
||||
accept numascii ,6
|
||||
print hex_out,hex_out_len
|
||||
mov rcx,05
|
||||
mov rsi,numascii
|
||||
mov rax,0
|
||||
mov rbx,0Ah
|
||||
|
||||
again1:
|
||||
mov rdx,0
|
||||
mul rbx
|
||||
mov dl,[rsi]
|
||||
sub dl,30h
|
||||
add rax,rdx
|
||||
inc rsi
|
||||
loop again1
|
||||
mov rbx,rax
|
||||
call dispnum_32
|
||||
ret
|
||||
|
||||
dispnum_32:
|
||||
mov rdi,dnumbuff
|
||||
mov rcx,16
|
||||
up2:
|
||||
rol rbx,04
|
||||
mov dl,bl
|
||||
and dl,0Fh
|
||||
add dl,30h
|
||||
cmp dl,39h
|
||||
jbe dskip1
|
||||
add dl,07h
|
||||
dskip1:
|
||||
mov [rdi],dl
|
||||
inc rdi
|
||||
loop up2
|
||||
print dnumbuff,16
|
||||
ret
|
||||
; END OF CODE
|
313
Codes/Practical-7.asm
Normal file
313
Codes/Practical-7.asm
Normal file
@ -0,0 +1,313 @@
|
||||
; THIS CODE HAS NOT BEEN TESTED AND IS NOT FULLY OPERATIONAL.
|
||||
|
||||
; Problem Statement: Write X86 Assembly Language Program (ALP) to implement following OS commands: i. TYPE, ii. COPY and iii. DELETE
|
||||
; Using file operations. User is supposed to provide command line arguments in all cases.
|
||||
|
||||
; Code from Microprocessor (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/Microprocessor/
|
||||
|
||||
; BEGINNING OF CODE
|
||||
%macro cmn 4 ;input/output
|
||||
mov rax,%1
|
||||
mov rdi,%2
|
||||
mov rsi,%3
|
||||
mov rdx,%4
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro exit 0
|
||||
mov rax,60
|
||||
mov rdi,0
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fopen 1
|
||||
mov rax,2 ;open
|
||||
mov rdi,%1 ;filename
|
||||
mov rsi,2 ;mode RW
|
||||
mov rdx,0777o ;file permissions
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fread 3
|
||||
mov rax,0 ;read
|
||||
mov rdi,%1 ;filehandle
|
||||
mov rsi,%2 ;buf
|
||||
mov rdx,%3 ;buf_len
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fwrite 3
|
||||
mov rax,1 ;write/print
|
||||
mov rdi,%1 ;filehandle
|
||||
mov rsi,%2 ;buf
|
||||
mov rdx,%3 ;buf_len
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fclose 1
|
||||
mov rax,3 ;close
|
||||
mov rdi,%1 ;file handle
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
section .data
|
||||
menu db 'MENU:',0Ah
|
||||
db "1 -> TYPE",0Ah
|
||||
db "2 -> COPY",0Ah
|
||||
db "3 -> DELETE",0Ah
|
||||
db "4 -> EXIT",0Ah
|
||||
db "Choose an option (1-4): "
|
||||
menulen equ $-menu
|
||||
msg db "Command: "
|
||||
msglen equ $-msg
|
||||
cpysc db "Successfully copied the file.",0Ah
|
||||
cpysclen equ $-cpysc
|
||||
|
||||
delsc db "File deletion successful.",0Ah
|
||||
delsclen equ $-delsc
|
||||
|
||||
err db "Error!",0Ah
|
||||
errlen equ $-err
|
||||
|
||||
cpywr db "Command does not exist.",0Ah
|
||||
cpywrlen equ $-cpywr
|
||||
|
||||
err_par db "Insufficient parameter.",0Ah
|
||||
err_parlen equ $-err_par
|
||||
|
||||
section .bss
|
||||
choice resb 2
|
||||
buffer resb 50
|
||||
name1 resb 15
|
||||
name2 resb 15
|
||||
cmdlen resb 1
|
||||
filehandle1 resq 1
|
||||
filehandle2 resq 1
|
||||
abuf_len resq 1 ;actual buffer length
|
||||
dispnum resb 2
|
||||
buf resb 4096
|
||||
buf_len equ $-buf ;buffer initial length
|
||||
|
||||
section .txt
|
||||
global _start
|
||||
_start:
|
||||
|
||||
again: cmn 1,1,menu,menulen
|
||||
cmn 0,0,choice,2
|
||||
|
||||
mov al,byte[choice]
|
||||
cmp al,31h
|
||||
jbe op1
|
||||
cmp al,32h
|
||||
jbe op2
|
||||
cmp al,33h
|
||||
jbe op3
|
||||
|
||||
exit
|
||||
ret
|
||||
|
||||
op1:
|
||||
call tproc
|
||||
jmp again
|
||||
|
||||
op2:
|
||||
call cpproc
|
||||
jmp again
|
||||
|
||||
op3:
|
||||
call delproc
|
||||
jmp again
|
||||
|
||||
;type command procedure
|
||||
tproc:
|
||||
cmn 1,1,msg,msglen
|
||||
cmn 0,0,buffer,50
|
||||
mov byte[cmdlen],al
|
||||
dec byte[cmdlen]
|
||||
|
||||
mov rsi,buffer
|
||||
mov al,[rsi] ;search for correct type command
|
||||
cmp al,'t'
|
||||
jne skipt
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jz skipt
|
||||
mov al,[rsi]
|
||||
cmp al,'y'
|
||||
jne skipt
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jz skipt
|
||||
mov al,[rsi]
|
||||
cmp al,'p'
|
||||
jne skipt
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jz skipt
|
||||
mov al,[rsi]
|
||||
cmp al,'e'
|
||||
jne skipt
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jnz correctt
|
||||
cmn 1,1,err_par,err_parlen
|
||||
call exit
|
||||
|
||||
skipt: cmn 1,1,cpywr,cpywrlen
|
||||
exit
|
||||
correctt:
|
||||
mov rdi,name1 ;finding file name
|
||||
call find_name
|
||||
|
||||
fopen name1 ;on success returns handle
|
||||
cmp rax,-1H ;on failure returns -1
|
||||
jle error
|
||||
mov [filehandle1],rax
|
||||
|
||||
xor rax,rax
|
||||
fread [filehandle1],buf,buf_len
|
||||
mov [abuf_len],rax
|
||||
dec byte[abuf_len]
|
||||
|
||||
cmn 1,1,buf,abuf_len ;printing file content on screen
|
||||
ret
|
||||
|
||||
;copy command procedure
|
||||
cpproc:
|
||||
cmn 1,1,msg,msglen
|
||||
cmn 0,0,buffer,50 ;accept command
|
||||
mov byte[cmdlen],al
|
||||
dec byte[cmdlen]
|
||||
|
||||
mov rsi,buffer
|
||||
mov al,[rsi] ;search for copy
|
||||
cmp al,'c'
|
||||
jne skip
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jz skip
|
||||
mov al,[rsi]
|
||||
cmp al,'o'
|
||||
jne skip
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jz skip
|
||||
mov al,[rsi]
|
||||
cmp al,'p'
|
||||
jne skip
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jz skip
|
||||
mov al,[rsi]
|
||||
cmp al,'y'
|
||||
jne skip
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jnz correct
|
||||
cmn 1,1,err_par,err_parlen
|
||||
exit
|
||||
|
||||
skip: cmn 1,1,cpywr,cpywrlen
|
||||
exit
|
||||
correct:
|
||||
mov rdi,name1 ;finding first file name
|
||||
call find_name
|
||||
|
||||
mov rdi,name2 ;finding second file name
|
||||
call find_name
|
||||
|
||||
skip3: fopen name1 ;on success returns handle
|
||||
cmp rax,-1H ;on failure returns -1
|
||||
jle error
|
||||
mov [filehandle1],rax
|
||||
|
||||
fopen name2 ;on success returns handle
|
||||
cmp rax,-1H ;on failure returns -1
|
||||
jle error
|
||||
mov [filehandle2],rax
|
||||
xor rax,rax
|
||||
fread [filehandle1],buf,buf_len
|
||||
mov [abuf_len],rax
|
||||
dec byte[abuf_len]
|
||||
|
||||
fwrite [filehandle2],buf,[abuf_len] ;write to file
|
||||
fclose [filehandle1]
|
||||
fclose [filehandle2]
|
||||
cmn 1,1,cpysc,cpysclen
|
||||
|
||||
jmp again
|
||||
error:
|
||||
cmn 1,1,err,errlen
|
||||
exit
|
||||
ret
|
||||
|
||||
;delete command procedure
|
||||
delproc:
|
||||
cmn 1,1,msg,msglen
|
||||
cmn 0,0,buffer,50 ;accept command
|
||||
mov byte[cmdlen],al
|
||||
dec byte[cmdlen]
|
||||
|
||||
mov rsi,buffer
|
||||
mov al,[rsi] ;search for copy
|
||||
cmp al,'d'
|
||||
jne skipr
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jz skipr
|
||||
mov al,[rsi]
|
||||
cmp al,'e'
|
||||
jne skipr
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jz skipr
|
||||
mov al,[rsi]
|
||||
cmp al,'l'
|
||||
jne skipr
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
jnz correctr
|
||||
cmn 1,1,err_par,err_parlen
|
||||
exit
|
||||
|
||||
skipr: cmn 1,1,cpywr,cpywrlen
|
||||
exit
|
||||
|
||||
correctr:
|
||||
mov rdi,name1 ;finding first file name
|
||||
call find_name
|
||||
mov rax,87 ;unlink system call
|
||||
mov rdi,name1
|
||||
syscall
|
||||
|
||||
cmp rax,-1H ;on failure returns -1
|
||||
jle errord
|
||||
cmn 1,1,delsc,delsclen
|
||||
jmp again
|
||||
|
||||
errord:
|
||||
cmn 1,1,err,errlen
|
||||
exit
|
||||
ret
|
||||
|
||||
find_name: ;finding file name from command
|
||||
inc rsi
|
||||
dec byte[cmdlen]
|
||||
|
||||
cont1: mov al,[rsi]
|
||||
mov [rdi],al
|
||||
inc rdi
|
||||
inc rsi
|
||||
mov al,[rsi]
|
||||
cmp al,20h ;searching for space
|
||||
je skip2
|
||||
cmp al,0Ah ;searching for enter key
|
||||
je skip2
|
||||
dec byte[cmdlen]
|
||||
jnz cont1
|
||||
cmn 1,1,err,errlen
|
||||
exit
|
||||
|
||||
skip2:
|
||||
ret
|
||||
; END OF CODE
|
BIN
Codes/org-pen/Practical-8/FN
Normal file
BIN
Codes/org-pen/Practical-8/FN
Normal file
Binary file not shown.
2
Codes/org-pen/Practical-8/fle.txt
Normal file
2
Codes/org-pen/Practical-8/fle.txt
Normal file
@ -0,0 +1,2 @@
|
||||
"Welcome!!!"
|
||||
|
54
Codes/org-pen/Practical-8/macro.asm
Normal file
54
Codes/org-pen/Practical-8/macro.asm
Normal file
@ -0,0 +1,54 @@
|
||||
;macros as per 64 bit conventions
|
||||
|
||||
%macro read 2
|
||||
mov rax,0 ;read
|
||||
mov rdi,0 ;stdin/keyboard
|
||||
mov rsi,%1 ;buf
|
||||
mov rdx,%2 ;buf_len
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro print 2
|
||||
mov rax,1 ;print
|
||||
mov rdi,1 ;stdout/screen
|
||||
mov rsi,%1 ;msg
|
||||
mov rdx,%2 ;msg_len
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fopen 1
|
||||
mov rax,2 ;open
|
||||
mov rdi,%1 ;filename
|
||||
mov rsi,2 ;mode RW
|
||||
mov rdx,0777o ;File permissions
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fread 3
|
||||
mov rax,0 ;read
|
||||
mov rdi,%1 ;filehandle
|
||||
mov rsi,%2 ;buf
|
||||
mov rdx,%3 ;buf_len
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fwrite 3
|
||||
mov rax,1 ;write/print
|
||||
mov rdi,%1 ;filehandle
|
||||
mov rsi,%2 ;buf
|
||||
mov rdx,%3 ;buf_len
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fclose 1
|
||||
mov rax,3 ;close
|
||||
mov rdi,%1 ;file handle
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro exit 0
|
||||
print nline,nline_len
|
||||
mov rax,60 ;exit
|
||||
mov rdi,0
|
||||
syscall
|
||||
%endmacro
|
108
Codes/org-pen/Practical-8/program1.asm
Normal file
108
Codes/org-pen/Practical-8/program1.asm
Normal file
@ -0,0 +1,108 @@
|
||||
;NAME:- Chinmay M. Mule
|
||||
;CLASS:-SE COMP II SHIFT
|
||||
;ROLLNO:-34 PRN:-S18111044
|
||||
;Assignment no. :5
|
||||
;Assignment Name :X86/64 Assembly language program (ALP) to find
|
||||
; a) Number of Blank spaces
|
||||
; b) Number of lines
|
||||
; c) Occurrence of a particular character.
|
||||
;Accept the data from the text file. The text file has to be accessed during Program_1 execution.
|
||||
;Write FAR PROCEDURES in Program_2 for the rest of the processing.
|
||||
;Use of PUBLIC/GLOBAL and EXTERN directives is mandatory.
|
||||
;------------------------------------------------------------------------
|
||||
|
||||
extern far_proc ; [ FAR PROCRDURE
|
||||
; USING EXTERN DIRECTIVE ]
|
||||
|
||||
global filehandle, char, buf, abuf_len
|
||||
|
||||
%include "macro.asm"
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
section .data
|
||||
nline db 10
|
||||
nline_len equ $-nline
|
||||
|
||||
ano db 10,10,10,10,"ML assignment 05 :- String Operation using Far Procedure"
|
||||
db 10,"---------------------------------------------------",10
|
||||
ano_len equ $-ano
|
||||
|
||||
filemsg db 10,"Enter filename for string operation : "
|
||||
filemsg_len equ $-filemsg
|
||||
|
||||
charmsg db 10,"Enter character to search : "
|
||||
charmsg_len equ $-charmsg
|
||||
|
||||
errmsg db 10,"ERROR in opening File...",10
|
||||
errmsg_len equ $-errmsg
|
||||
|
||||
exitmsg db 10,10,"Exit from program...",10,10
|
||||
exitmsg_len equ $-exitmsg
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
section .bss
|
||||
buf resb 4096
|
||||
buf_len equ $-buf ; buffer initial length
|
||||
|
||||
filename resb 50
|
||||
char resb 2
|
||||
|
||||
filehandle resq 1
|
||||
abuf_len resq 1 ; actual buffer length
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
section .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
print ano,ano_len ;assignment no.
|
||||
|
||||
print filemsg,filemsg_len
|
||||
read filename,50
|
||||
dec rax
|
||||
mov byte[filename + rax],0 ; blank char/null char
|
||||
|
||||
print charmsg,charmsg_len
|
||||
read char,2
|
||||
|
||||
fopen filename ; on succes returns handle
|
||||
cmp rax,-1H ; on failure returns -1
|
||||
jle Error
|
||||
mov [filehandle],rax
|
||||
|
||||
fread [filehandle],buf, buf_len
|
||||
mov [abuf_len],rax
|
||||
|
||||
call far_proc
|
||||
jmp Exit
|
||||
|
||||
Error: print errmsg, errmsg_len
|
||||
|
||||
Exit: print exitmsg,exitmsg_len
|
||||
exit
|
||||
;--------------------------------------------------------------------------------
|
||||
|
||||
; OUTPUT:-
|
||||
;chinmay@ubuntu:~Desktop/Assignment5$ nasm -f elf64 program1.asm
|
||||
;chinmay@ubuntu:~Desktop/Assignment5$ nasm -f elf64 program2.asm
|
||||
;chinmay@ubuntu:~Desktop/Assignment5$ ld -o FN program1.o program2.o
|
||||
;chinmay@ubuntu:~Desktop/Assignment5$ ./FN
|
||||
|
||||
|
||||
|
||||
|
||||
; ML assignment 05 :- String Operation using Far Procedure
|
||||
;---------------------------------------------------
|
||||
|
||||
;Enter filename for string operation : fle.txt
|
||||
|
||||
;Enter character to search : e
|
||||
|
||||
;No. of spaces are : 0000
|
||||
;No. of lines are : 0002
|
||||
;No. of character occurances are : 0002
|
||||
|
||||
;Exit from program...
|
||||
|
||||
|
||||
|
103
Codes/org-pen/Practical-8/program2.asm
Normal file
103
Codes/org-pen/Practical-8/program2.asm
Normal file
@ -0,0 +1,103 @@
|
||||
;---------------------------------------------------------------------
|
||||
section .data
|
||||
nline db 10,10
|
||||
nline_len: equ $-nline
|
||||
|
||||
smsg db 10,"No. of spaces are : "
|
||||
smsg_len: equ $-smsg
|
||||
|
||||
nmsg db 10,"No. of lines are : "
|
||||
nmsg_len: equ $-nmsg
|
||||
|
||||
cmsg db 10,"No. of character occurances are : "
|
||||
cmsg_len: equ $-cmsg
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
section .bss
|
||||
|
||||
scount resq 1
|
||||
ncount resq 1
|
||||
ccount resq 1
|
||||
|
||||
char_ans resb 16
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
global far_proc
|
||||
|
||||
extern filehandle, char, buf, abuf_len
|
||||
|
||||
%include "macro.asm"
|
||||
;---------------------------------------------------------------------
|
||||
section .text
|
||||
global _main
|
||||
_main:
|
||||
|
||||
far_proc: ;FAR Procedure
|
||||
|
||||
xor rax,rax
|
||||
xor rbx,rbx
|
||||
xor rcx,rcx
|
||||
xor rsi,rsi
|
||||
|
||||
mov bl,[char]
|
||||
mov rsi,buf
|
||||
mov rcx,[abuf_len]
|
||||
|
||||
again: mov al,[rsi]
|
||||
|
||||
case_s: cmp al,20h ;space : 32 (20H)
|
||||
jne case_n
|
||||
inc qword[scount]
|
||||
jmp next
|
||||
|
||||
case_n: cmp al,0Ah ;newline : 10(0AH)
|
||||
jne case_c
|
||||
inc qword[ncount]
|
||||
jmp next
|
||||
|
||||
case_c: cmp al,bl ;character
|
||||
jne next
|
||||
inc qword[ccount]
|
||||
|
||||
next: inc rsi
|
||||
dec rcx ;
|
||||
jnz again ;loop again
|
||||
|
||||
print smsg,smsg_len
|
||||
mov rax,[scount]
|
||||
call display
|
||||
|
||||
print nmsg,nmsg_len
|
||||
mov rax,[ncount]
|
||||
call display
|
||||
|
||||
print cmsg,cmsg_len
|
||||
mov rax,[ccount]
|
||||
call display
|
||||
|
||||
fclose [filehandle]
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------
|
||||
display:
|
||||
mov rsi,char_ans+3 ; load last byte address of char_ans in rsi
|
||||
mov rcx,4 ; number of digits
|
||||
|
||||
cnt:mov rdx,0 ; make rdx=0 (as in div instruction rdx:rax/rbx)
|
||||
mov rbx,10 ; divisor=10 for decimal and 16 for hex
|
||||
div rbx
|
||||
; cmp dl, 09h ; check for remainder in RDX
|
||||
; jbe add30
|
||||
; add dl, 07h
|
||||
;add30:
|
||||
add dl,30h ; calculate ASCII code
|
||||
mov [rsi],dl ; store it in buffer
|
||||
dec rsi ; point to one byte back
|
||||
|
||||
dec rcx ; decrement count
|
||||
jnz cnt ; if not zero repeat
|
||||
|
||||
print char_ans,4 ; display result on screen
|
||||
ret
|
||||
;----------------------------------------------------------------
|
||||
|
BIN
Codes/org-pen/Practical-9/b
Normal file
BIN
Codes/org-pen/Practical-9/b
Normal file
Binary file not shown.
175
Codes/org-pen/Practical-9/bsort.asm
Normal file
175
Codes/org-pen/Practical-9/bsort.asm
Normal file
@ -0,0 +1,175 @@
|
||||
;NAME:- Chinmay M. Mule
|
||||
;CLASS:-SE COMP II SHIFT
|
||||
;ROLLNO:-34 PRN:-S18111044
|
||||
; Assignment Name:- Write X86 program to sort the list of integers in
|
||||
; ascending order.
|
||||
; Read the input from the text file and write the sorted
|
||||
; data back to the same text file using bubble sort.
|
||||
|
||||
|
||||
|
||||
%include "macro.asm"
|
||||
|
||||
section .data
|
||||
|
||||
nline db 10
|
||||
nline_len equ $-nline
|
||||
|
||||
ano db 10,10,10,10,"MPL assignment 07-Bubble sort using file operations"
|
||||
db 10,"........................................",10
|
||||
ano_len equ $-ano
|
||||
|
||||
filemsg db 10,"Enter filename of input data:"
|
||||
filemsg_len equ $-filemsg
|
||||
|
||||
omsg db 10,"Sorting using bubble sort operation successful."
|
||||
db 10,"Output stored in same file.....",10,10
|
||||
omsg_len equ $-omsg
|
||||
|
||||
errmsg db 10,"ERROR in opening/reading/writing file..",10
|
||||
errmsg_len equ $-errmsg
|
||||
|
||||
exitmsg db 10,10,"Exit from program....",10,10
|
||||
exitmsg_len equ $-exitmsg
|
||||
|
||||
section .bss
|
||||
|
||||
buf resb 1024
|
||||
buf_len equ $-buf ;buffer length
|
||||
|
||||
filename resb 50
|
||||
|
||||
filehandle resq 1
|
||||
abuf_len resq 1 ;actual buffer length
|
||||
|
||||
array resb 10
|
||||
n resq 1 ;passes
|
||||
|
||||
section .text
|
||||
|
||||
global _start
|
||||
|
||||
_start:
|
||||
print ano,ano_len
|
||||
|
||||
print filemsg,filemsg_len
|
||||
read filename,50
|
||||
dec rax
|
||||
mov byte[filename+rax],0 ; blank char/null char
|
||||
|
||||
fopen filename ;on success returns handle
|
||||
cmp rax,-1H
|
||||
je Error
|
||||
mov[filehandle],rax
|
||||
|
||||
fread[filehandle],buf,buf_len
|
||||
dec rax
|
||||
mov [abuf_len],rax
|
||||
|
||||
call bsort
|
||||
jmp Exit
|
||||
|
||||
Error:print errmsg,errmsg_len
|
||||
|
||||
Exit:print exitmsg,exitmsg_len
|
||||
exit
|
||||
;........................................................................
|
||||
bsort: ;Bubble sort procedure
|
||||
call buf_array
|
||||
|
||||
xor rax,rax
|
||||
mov rbp,[n]
|
||||
dec rbp
|
||||
|
||||
xor rcx,rcx
|
||||
xor rdx,rdx
|
||||
xor rsi,rsi
|
||||
xor rdi,rdi
|
||||
|
||||
mov rcx,0 ;i=0
|
||||
|
||||
oloop:mov rbx,0 ;j=0
|
||||
|
||||
mov rsi,array ;a[j]
|
||||
|
||||
iloop:mov rdi,rsi ;a[j+1]
|
||||
inc rdi
|
||||
|
||||
mov al,[rsi]
|
||||
cmp al,[rdi]
|
||||
jbe next
|
||||
|
||||
mov dl,0
|
||||
mov dl,[rdi] ;swap
|
||||
mov [rdi],al
|
||||
mov [rsi],dl
|
||||
|
||||
next:inc rsi
|
||||
inc rbx ; j++
|
||||
cmp rbx,rbp
|
||||
jb iloop
|
||||
inc rcx
|
||||
cmp rcx,rbp
|
||||
jb oloop
|
||||
|
||||
fwrite [filehandle],omsg,omsg_len
|
||||
fwrite [filehandle],array,[n]
|
||||
|
||||
fclose [filehandle]
|
||||
|
||||
print omsg,omsg_len
|
||||
print array,[n]
|
||||
|
||||
ret
|
||||
|
||||
Error1:
|
||||
print errmsg,errmsg_len
|
||||
ret
|
||||
;....................................................
|
||||
buf_array:
|
||||
xor rcx,rcx
|
||||
xor rsi,rsi
|
||||
xor rdi,rdi
|
||||
|
||||
mov rcx,[abuf_len]
|
||||
mov rsi,buf
|
||||
mov rdi,array
|
||||
|
||||
next_num:
|
||||
mov al,[rsi]
|
||||
mov [rdi],al
|
||||
|
||||
inc rsi ;number
|
||||
inc rsi ;newline
|
||||
inc rdi
|
||||
|
||||
inc byte[n] ; counter
|
||||
|
||||
dec rcx
|
||||
dec rcx
|
||||
jnz next_num
|
||||
ret
|
||||
|
||||
|
||||
; OUTPUT:-
|
||||
;chinmay@ubuntu:~Desktop/MPL Programs/Assignment7$ nasm -f elf64 bsort.asm
|
||||
;chinmay@ubuntu:~Desktop/MPL Programs/Assignment7$ ld -o b bsort.o
|
||||
;chinmay@ubuntu:~Desktop/MPL Programs/Assignment7$ ./b
|
||||
|
||||
|
||||
|
||||
|
||||
;MPL assignment 07-Bubble sort using file operations
|
||||
;........................................
|
||||
|
||||
;Enter filename of input data:fl.txt
|
||||
|
||||
;Sorting using bubble sort operation successful.
|
||||
;Output stored in same file.....
|
||||
|
||||
;12467
|
||||
|
||||
;Exit from program....
|
||||
|
||||
|
||||
|
6
Codes/org-pen/Practical-9/fl.txt
Normal file
6
Codes/org-pen/Practical-9/fl.txt
Normal file
@ -0,0 +1,6 @@
|
||||
2
|
||||
7
|
||||
4
|
||||
6
|
||||
1
|
||||
|
57
Codes/org-pen/Practical-9/macro.asm
Normal file
57
Codes/org-pen/Practical-9/macro.asm
Normal file
@ -0,0 +1,57 @@
|
||||
;macro.asm
|
||||
|
||||
%macro read 2
|
||||
mov rax,0 ;read
|
||||
mov rdi,0
|
||||
mov rsi,%1
|
||||
mov rdx,%2
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro print 2
|
||||
mov rax,1
|
||||
mov rdi,1
|
||||
mov rsi,%1
|
||||
mov rdx,%2
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fopen 1
|
||||
mov rax,2 ;open
|
||||
mov rdi,%1 ;filename
|
||||
mov rsi,2 ;mode RW
|
||||
mov rdx,0777o ;File permissions(Read-4,Write-2,Execute-1)
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fread 3
|
||||
mov rax,0 ;read
|
||||
mov rdi,%1 ;filehandle
|
||||
mov rsi,%2 ;buf
|
||||
mov rdx,%3 ;buf_len
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fwrite 3
|
||||
mov rax,0 ;write
|
||||
mov rdi,%1 ;filehandle
|
||||
mov rsi,%2 ;buf
|
||||
mov rdx,%3 ;buf_len
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro fclose 1
|
||||
mov rax,3 ;close
|
||||
mov rdi,%1;file handle
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
%macro exit 0
|
||||
print nline,nline_len
|
||||
mov rax,60
|
||||
mov rdi,0
|
||||
syscall
|
||||
%endmacro
|
||||
|
||||
|
||||
|
78
Codes/org-pen/cosinewave.asm
Normal file
78
Codes/org-pen/cosinewave.asm
Normal file
@ -0,0 +1,78 @@
|
||||
;Y=100-60 cos((pi/180)*x)
|
||||
;Bit 7 6 5 4 3 2 1 0
|
||||
;Data R R R G G G B B
|
||||
|
||||
.387
|
||||
.model small
|
||||
|
||||
.stack 100
|
||||
|
||||
.data
|
||||
msg db 10,13,'this is COS wave$'
|
||||
one_eighty dw 180
|
||||
scale dw 30
|
||||
hundred dw 100
|
||||
rint dw 0
|
||||
x dw 0
|
||||
|
||||
.code
|
||||
main:
|
||||
mov ax,@data ; Initialize DS (needed for .exe-program)
|
||||
mov ds, ax
|
||||
mov ax, 0A000h ; Segment to video memory
|
||||
mov es, ax
|
||||
|
||||
mov ax, 13h ;Standard video graphics mode
|
||||
int 10h ; switch to 320x200 mode
|
||||
|
||||
mov cx,0
|
||||
|
||||
l1:
|
||||
push cx ; store CX
|
||||
call get_cos
|
||||
|
||||
mov bx, cx
|
||||
call vector_to_memory
|
||||
mov di, ax
|
||||
mov al, 03h ; color
|
||||
mov [es:di], al ; put pixel
|
||||
pop cx ; restore CX
|
||||
inc cx ; CX = CX + 1
|
||||
cmp cx, 320 ; right boarder reached?
|
||||
jne l1 ; no, next degree
|
||||
|
||||
mov ah,09h ; display message
|
||||
lea dx,msg
|
||||
int 21h
|
||||
|
||||
xor ah, ah
|
||||
int 16h ; keyboard (wait for key)
|
||||
mov ax, 3
|
||||
int 10h ; go to text mode
|
||||
mov ax, 4C00h
|
||||
int 21h ; return to DOS, exit code 0
|
||||
|
||||
get_cos: ; Args: CX = angle (degree!)
|
||||
mov word[x],cx
|
||||
fldpi ; ST(0)=Pi, ST(1)=CX
|
||||
fimul word[x] ; ST(0)=Pi*CX
|
||||
|
||||
fidiv word[one_eighty] ; ST(0)=(Pi*CX)/180(degree to rad)
|
||||
fcos ; ST(0)=sine (rad)
|
||||
fimul word[scale] ; ST(0)=sine*scale
|
||||
fild hundred
|
||||
fsub st,st(1) ;ST(0)=100-60*SIN((Pi*CX)/180)
|
||||
fist word [rint] ; store integer with rounding
|
||||
mov ax, word[rint] ; AX = Y
|
||||
ret ; Return: AX = Y (signed!)
|
||||
|
||||
vector_to_memory: ; Calculate offset=Y*320+X
|
||||
;Args: BX = X, AX = Y
|
||||
push dx ; mul changes dx too
|
||||
mov cx, 320 ; video mode width
|
||||
mul cx ; DX:AX = AX * CX
|
||||
add ax, bx ; left indentation
|
||||
pop dx
|
||||
ret ; Return: AX = offset in memory
|
||||
|
||||
end main
|
87
Codes/org-pen/sinewave.asm
Normal file
87
Codes/org-pen/sinewave.asm
Normal file
@ -0,0 +1,87 @@
|
||||
;NAME:- Chinmay M. Mule
|
||||
;CLASS:-SE COMP II SHIFT
|
||||
;ROLLNO:-34 PRN:-S18111044
|
||||
;Assignment Name:-Write 80387 ALP to plot Sine Wave, Cosine Wave. Access
|
||||
; video memory directly for plotting.
|
||||
|
||||
|
||||
|
||||
.387
|
||||
.MODEL SMALL
|
||||
.DATA
|
||||
X DW 1
|
||||
Y DW 0
|
||||
Xrad DQ ?
|
||||
D60 DW 60
|
||||
D100 DW 100
|
||||
D180 DW 180
|
||||
PIby180 DQ ?
|
||||
TAB DB 80H,40H,20H,10H,8H,4,2,1
|
||||
OFS DW 0
|
||||
|
||||
.CODE
|
||||
START: MOV AX,@DATA
|
||||
MOV DS,AX
|
||||
|
||||
MOV AH,00 ;Set video mode
|
||||
MOV AL,06 ;Mode 6 i.e. 640 by 200 Graphics
|
||||
INT 10H
|
||||
|
||||
FINIT
|
||||
FLDPI
|
||||
FIDIV D180
|
||||
FSTP PIby180
|
||||
DRAWSINE:
|
||||
FILD X ;Load angle
|
||||
FLD PIby180 ;Convert to radian
|
||||
FMUL ;i.e. multiply by Pi/180
|
||||
FST Xrad
|
||||
FSIN ;Calculate sine
|
||||
FDIV Xrad
|
||||
FILD D60 ;Load amplitude
|
||||
FMUL ;Calculate Amplitude x sin
|
||||
FILD D100
|
||||
FSUBR
|
||||
FISTP Y
|
||||
|
||||
CALL OFSCAL
|
||||
INC X ;Next angle
|
||||
CMP X,639 ;Last point on X axis
|
||||
JNE DRAWSINE
|
||||
EXIT:
|
||||
MOV AH,0
|
||||
INT 16H
|
||||
|
||||
MOV AH,00 ;Set video mode
|
||||
MOV AL,02 ;Mode 2 i.e. 80 by 25 text
|
||||
INT 10H
|
||||
|
||||
MOV AH,4CH
|
||||
INT 21H
|
||||
|
||||
OFSCAL PROC NEAR
|
||||
MOV AX,Y
|
||||
AND AX,1
|
||||
JZ L1
|
||||
MOV OFS,2000H
|
||||
L1: MOV AX,Y
|
||||
SHR AX,1
|
||||
MOV BX,50H
|
||||
MUL BX
|
||||
ADD OFS,AX
|
||||
MOV AX,X
|
||||
MOV CL,3
|
||||
SHR AX,CL
|
||||
ADD OFS,AX
|
||||
LEA BX,TAB
|
||||
MOV AX,X
|
||||
AND AX,07
|
||||
XLAT
|
||||
MOV BX,OFS
|
||||
MOV DX,0B800H
|
||||
MOV ES,DX
|
||||
OR ES:[BX],AL
|
||||
MOV OFS,0
|
||||
RET
|
||||
OFSCAL ENDP
|
||||
END START
|
15
README.md
Normal file
15
README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Microprocessor (MP) - TESTING BRANCH
|
||||
|
||||
⚠️⚠️⚠️ This branch contains untested code and other miscellaneous content such as never-to-be-checked assignments. ⚠️⚠️⚠️
|
||||
|
||||
---
|
||||
|
||||
### Testing codes:
|
||||
- [6 - hex to bcd](https://git.kska.io/sppu-se-comp-content/Microprocessor/src/branch/testing/Codes/Practical-6.asm)
|
||||
- [7 - implement os commands](https://git.kska.io/sppu-se-comp-content/Microprocessor/src/branch/testing/Codes/Practical-7.asm)
|
||||
- [8 - space, lines, occurn](https://git.kska.io/sppu-se-comp-content/Microprocessor/src/branch/testing/Codes/org-pen/Practical-8)
|
||||
- [9 - bubble sort](https://git.kska.io/sppu-se-comp-content/Microprocessor/src/branch/testing/Codes/org-pen/Practical-9)
|
||||
|
||||
### Old assignments
|
||||
- [Assignment-1.old](https://git.kska.io/sppu-se-comp-content/Microprocessor/src/branch/main/Assignments/Assignment-01.old.pdf)
|
||||
|
233
git-commit-logs.txt
Normal file
233
git-commit-logs.txt
Normal file
@ -0,0 +1,233 @@
|
||||
commit 630ee1673b42f2e6bf9193e0234a71ee6ccdf614
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Mon Apr 22 14:10:59 2024 +0530
|
||||
|
||||
an attempt to merge 5.1 and 5.2. this code is not tested at all.
|
||||
|
||||
commit 841d01e4fa8f2cf58c1490fcc412d0767a68c0f0
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Mon Apr 22 14:05:24 2024 +0530
|
||||
|
||||
removed 5.1 since it's been merged with main
|
||||
|
||||
commit 1128c86d477a797aa335c7153fedcc1433a6ac73
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Mon Apr 22 09:46:27 2024 +0530
|
||||
|
||||
fixed Practical 5.1 code and tested. ready to merge.
|
||||
|
||||
commit c73f71d92c1c3808697e45f62d5756ce7a585ec0
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sun Apr 21 00:03:54 2024 +0530
|
||||
|
||||
tried fixing these codes (5.1, 6, 7). didn't work. still trying.
|
||||
|
||||
commit bc9fbdeca0c109e15462e2ceeb1546a7871c454b
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sat Apr 20 23:57:57 2024 +0530
|
||||
|
||||
removed merged code, practical-13
|
||||
|
||||
commit a06e20db952d16363108d481ae776e7ae931186c
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sat Apr 20 23:54:24 2024 +0530
|
||||
|
||||
modified and tested practical-13 code. ready to merge
|
||||
|
||||
commit 39a770ff82bd19e2d0f9b42b99fff7d613ccf977
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sat Apr 20 22:47:40 2024 +0530
|
||||
|
||||
removed merged code
|
||||
|
||||
commit c9e507737e2803be53ffbc7618713ea9758dab64
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sat Apr 20 22:40:50 2024 +0530
|
||||
|
||||
tested and modified practical-12 code. ready to merge.
|
||||
|
||||
commit 636c174734d0f5ee04c95bf6b9a08c6a411c5755
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sat Apr 20 22:32:03 2024 +0530
|
||||
|
||||
removed merged codes
|
||||
|
||||
commit 33ef4440c5f2019d7cd9fc02d5ef63a258c3a4b2
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sat Apr 20 22:26:39 2024 +0530
|
||||
|
||||
modified and tested practical-11 code. fully functional. ready to merge.
|
||||
|
||||
commit 6006c488edc8bb4f677dc4cb54373f7c75715af9
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sat Apr 20 22:16:31 2024 +0530
|
||||
|
||||
added practical 10 code. fully functional and tested. ready to merge with main
|
||||
|
||||
commit 35bb0d9b7c54ed193873972cc77f323355d4291b
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Fri Apr 19 12:51:07 2024 +0530
|
||||
|
||||
merged 5.2 in main, deleting from testing branch
|
||||
|
||||
commit e5057904a7556122d0df4f6ab0f2cfaed3e137a6
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Fri Apr 19 12:41:04 2024 +0530
|
||||
|
||||
fixed and tested Practical-5.2 code, ready for merge
|
||||
|
||||
commit ef58c662a9eda643570a6658c46516fcbf8451c0
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Wed Apr 17 00:04:04 2024 +0530
|
||||
|
||||
updated readme
|
||||
|
||||
commit f81c59594f82285612146dad7a8949a30899744a
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Wed Apr 17 00:01:53 2024 +0530
|
||||
|
||||
created a testing branch, deleted unnecessary stuff. only kept untested codes and unchecked assignment
|
||||
|
||||
commit 27ce9c7f275210a3924e4648715b81c698d3c4b1
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Tue Apr 16 23:43:23 2024 +0530
|
||||
|
||||
forgot to add readme file in the last commit lol
|
||||
|
||||
commit 1c2829671bc68922052632d72dd615009ade58d4
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Tue Apr 16 23:42:02 2024 +0530
|
||||
|
||||
added 3.2 (non-overlapped without string specific instruction block transfer), 4.1 & 4.2 (overlapped block transfer) and updated readme file
|
||||
|
||||
commit daa924ef684b1fe62b5946bdb162c125cd24c451
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Tue Apr 16 13:29:20 2024 +0530
|
||||
|
||||
Added code for practical 1 and 3.1, plus updated readme
|
||||
|
||||
commit 75db27b6a25862d87ef25ee5db1e7759752c6db5
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Tue Apr 16 12:27:17 2024 +0530
|
||||
|
||||
fixed link for factorial write-up part 2
|
||||
|
||||
commit e152f88e38fcee8e1944fc628e9dd41999d50b77
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Tue Apr 16 12:26:09 2024 +0530
|
||||
|
||||
fixed link for factorial write-up
|
||||
|
||||
commit 171ffc667122c495dd03f7a36ae648baa153bd2c
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Tue Apr 16 12:24:41 2024 +0530
|
||||
|
||||
added write-ups and updated readme file
|
||||
|
||||
commit 8bc6f6650279e2a65ecfd1802f9e8eb9cc1bc4fe
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Fri Apr 12 10:26:23 2024 +0530
|
||||
|
||||
added u3 notes
|
||||
|
||||
commit 6dc72916ba907b0895c6a83be2ccd88d6fe7f557
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sun Mar 10 00:29:23 2024 +0530
|
||||
|
||||
fixed link in readme
|
||||
|
||||
commit 70587254ab508d88aecff578368424079df38cf2
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sun Mar 10 00:24:59 2024 +0530
|
||||
|
||||
added question banks for unit 1 and 2
|
||||
|
||||
commit b188e8011d19968210239c7954515a72f7f418fb
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Mon Mar 4 21:26:02 2024 +0530
|
||||
|
||||
added code for assignment 8
|
||||
|
||||
commit 5d1e57a62decfdf3f6cd6fa0fb2e0dcea00e749d
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Mon Feb 26 09:35:19 2024 +0530
|
||||
|
||||
updated README
|
||||
|
||||
commit 6501e8a3841cd16ec5f286c93122f7ab6facd628
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Mon Feb 26 09:33:18 2024 +0530
|
||||
|
||||
added code for A5
|
||||
|
||||
commit 40c23cdfca96fdfcc2bb9295839db096ca7d43b9
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Wed Feb 21 02:25:23 2024 +0530
|
||||
|
||||
added unit 2 notes
|
||||
|
||||
commit 4a323c06a449c02c15f5b1344b149c08c033950d
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Fri Feb 16 16:51:45 2024 +0530
|
||||
|
||||
removed assignment-01
|
||||
|
||||
commit 76e6a414b110ddcfdfd024e579582745b291d171
|
||||
Author: TanmayMachkar <REDACTED_EMAIL>
|
||||
Date: Sat Feb 10 22:47:37 2024 +0530
|
||||
|
||||
readme updated
|
||||
|
||||
commit 720b550f5d1b9875a019d3b1d15dc861591534a6
|
||||
Author: TanmayMachkar <REDACTED_EMAIL>
|
||||
Date: Sat Feb 10 22:45:23 2024 +0530
|
||||
|
||||
unit 1 pdf's added
|
||||
|
||||
commit 3d4c0a5ed3264c44456d304b92b11efc87352053
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sat Feb 10 13:29:40 2024 +0530
|
||||
|
||||
Updated readme
|
||||
|
||||
commit dd882d8b20798ad7cc653cb442d68dfa97755dbe
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sat Feb 10 13:27:07 2024 +0530
|
||||
|
||||
Added assignment 01
|
||||
|
||||
commit fc48b3ac0f0a32969b66d416698fc7f8553643db
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Mon Feb 5 00:59:30 2024 +0530
|
||||
|
||||
Added links for PYQs
|
||||
|
||||
commit bfb19b79d8174387ac467d1f62b00d14f170d26a
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Mon Feb 5 00:57:56 2024 +0530
|
||||
|
||||
Added PYQs
|
||||
|
||||
commit 8818a373b5fe5a34fa2f818593ad7d197e4732d4
|
||||
Author: Kshitij <REDACTED_EMAIL>
|
||||
Date: Sun Feb 4 20:12:23 2024 +0530
|
||||
|
||||
Added DISCLAIMER, LICENSE file, updated the README file, moved Unit 1 notes to notes folder
|
||||
|
||||
commit a6ed2610f8ac5c96b94389cef6f8a2c2cb0e326a
|
||||
Author: TanmaySpamzzz <REDACTED_EMAIL>
|
||||
Date: Mon Jan 29 19:16:05 2024 +0530
|
||||
|
||||
Update README.md
|
||||
|
||||
commit 275194c744be835c03dc56b4c23e644a9902637c
|
||||
Author: TanmayMachkar <REDACTED_EMAIL>
|
||||
Date: Mon Jan 29 19:10:06 2024 +0530
|
||||
|
||||
readme updated
|
||||
|
||||
commit 2177ad1fffa2ca1eae559ebf5d5e3b17293ca599
|
||||
Author: TanmayMachkar <REDACTED_EMAIL>
|
||||
Date: Mon Jan 29 19:09:03 2024 +0530
|
||||
|
||||
u1 added
|
Loading…
Reference in New Issue
Block a user