fork download
  1. section .data
  2. nline db 10,10
  3. nline_len equ $-nline
  4.  
  5. space db " "
  6.  
  7. ano db 10," Assignment no :2-A by Ganesh Kendre",
  8. db 10,"-------------------------------------------------------------------",
  9. db 10," Block Transfer-Non overlapped without String instruction.",
  10. db 10,"-------------------------------------------------------------------",10
  11. ano_len equ $-ano
  12.  
  13. bmsg db 10,"Before Transfer::"
  14. bmsg_len equ $-bmsg
  15.  
  16. amsg db 10,"After Transfer::"
  17. amsg_len equ $-amsg
  18.  
  19. smsg db 10," Source Block :"
  20. smsg_len equ $-smsg
  21.  
  22. dmsg db 10," Destination Block :"
  23. dmsg_len equ $-dmsg
  24.  
  25. sblock db 11h,22h,33h,44h,55h
  26. dblock times 5 db 0
  27.  
  28. ;------------------------------------------------------------------------------
  29. section .bss
  30.  
  31. char_ans resB 2 ;char_ans is of 2 byte because we have 2 byte nos
  32. ;-----------------------------------------------------------------------------
  33.  
  34. %macro Print 2
  35. MOV RAX,1
  36. MOV RDI,1
  37. MOV RSI,%1
  38. MOV RDX,%2
  39. syscall
  40. %endmacro
  41.  
  42. %macro Read 2
  43. MOV RAX,0
  44. MOV RDI,0
  45. MOV RSI,%1
  46. MOV RDX,%2
  47. syscall
  48. %endmacro
  49.  
  50. %macro Exit 0
  51. Print nline,nline_len
  52. MOV RAX,60
  53. MOV RDI,0
  54. syscall
  55. %endmacro
  56. ;---------------------------------------------------------------
  57.  
  58. section .text
  59. global _start
  60. _start:
  61. Print ano,ano_len
  62.  
  63. Print bmsg,bmsg_len ;Block values before transfer
  64.  
  65. Print smsg,smsg_len
  66. mov rsi,sblock ;As rsi is used to point source as well as destination block
  67. call disp_block ;assign source and destination block separately before call
  68.  
  69. Print dmsg,dmsg_len
  70. mov rsi,dblock
  71. call disp_block
  72.  
  73. call BT_NO ;call for actual block transfer
  74.  
  75. Print amsg,amsg_len ;Block values after transfer
  76.  
  77. Print smsg,smsg_len
  78. mov rsi,sblock
  79. call disp_block
  80.  
  81. Print dmsg,dmsg_len
  82. mov rsi,dblock
  83. call disp_block
  84.  
  85. Exit
  86. ;-----------------------------------------------------------------
  87. BT_NO:
  88. mov rsi,sblock
  89. mov rdi,dblock
  90. mov rcx,5
  91. back: mov al,[rsi] ;moves 1 value from rsi to rdi
  92.  
  93. mov [rdi],al ;(memory-memory transfer is not allowed)
  94. inc rsi
  95. inc rdi
  96. dec rcx
  97. jnz back
  98. RET
  99. ;-----------------------------------------------------------------
  100. disp_block:
  101. mov rbp,5 ;counter as 5 values
  102.  
  103. next_num:
  104. mov al,[rsi] ;moves 1 value to rsi
  105. push rsi ;push rsi on stack as it get modified in Disp_8
  106.  
  107. call Disp_8
  108. Print space,1
  109.  
  110. pop rsi ;again pop rsi that pushed on stack
  111. inc rsi
  112. dec rbp
  113. jnz next_num
  114. RET
  115. ;---------------------------------------------------------------
  116. Disp_8:
  117. MOV RSI,char_ans+1
  118. MOV RCX,2 ;counter
  119. MOV RBX,16 ;Hex no
  120.  
  121. next_digit:
  122. XOR RDX,RDX
  123. DIV RBX
  124. CMP DL,9
  125. JBE add30
  126. ADD DL,07H
  127. add30 :
  128. ADD DL,30H
  129. MOV [RSI],DL
  130. DEC RSI
  131. DEC RCX
  132. JNZ next_digit
  133.  
  134. Print char_ans,2
  135. ret
  136.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
	Assignment no	:2-A by Ganesh Kendre
-------------------------------------------------------------------
	Block Transfer-Non overlapped without String instruction.
-------------------------------------------------------------------

Before Transfer::
	Source Block		:11 22 33 44 55 
	Destination Block	:00 00 00 00 00 
After Transfer::
	Source Block		:11 22 33 44 55 
	Destination Block	:11 22 33 44 55