Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. EXIT_NR = 1
  2. READ_NR = 3
  3. WRITE_NR = 4
  4. STDOUT = 1
  5. STDIN = 0
  6. EXIT_CODE_SUCCESS = 0
  7.  
  8. input_len=512
  9. output_len=1
  10.  
  11. .global _start
  12.  
  13. .data
  14. space: .byte ' ;
  15.  
  16. .bss
  17. .comm input, 512
  18. .comm output_high, 1
  19. .comm output_low, 1
  20.  
  21.  
  22. .text
  23.  
  24. _start:
  25.  
  26. mov $READ_NR, %eax
  27. mov $STDIN, %ebx
  28. mov $input, %ecx
  29. mov $input_len, %edx
  30. int $0x80
  31.  
  32. mov %eax,%edi
  33. //sub $1,%edi
  34. mov $0,%esi
  35.  
  36. loop:
  37.  
  38. mov input(%esi),%ah
  39. mov input(%esi),%al
  40.  
  41. shrb $4,%ah
  42. addb $0x30,%ah
  43. movb %ah, output_high
  44.  
  45. andb $0x0F,%al
  46.  
  47. cmpb $0x0A, %al
  48. jge wieksze_od_10
  49.  
  50. addb $0x30,%al
  51. jmp po
  52.  
  53. wieksze_od_10:
  54. addb $0x37,%al
  55.  
  56. po:
  57.  
  58. movb %al, output_low
  59.  
  60. mov $WRITE_NR, %eax
  61. mov $STDOUT, %ebx
  62. mov $output_high, %ecx
  63. mov $output_len, %edx
  64. int $0x80
  65.  
  66. mov $WRITE_NR, %eax
  67. mov $STDOUT, %ebx
  68. mov $output_low, %ecx
  69. mov $output_len, %edx
  70. int $0x80
  71.  
  72. mov $WRITE_NR, %eax
  73. mov $STDOUT, %ebx
  74. mov $space, %ecx
  75. mov $output_len, %edx
  76. int $0x80
  77.  
  78. inc %esi
  79.  
  80. cmp %esi,%edi
  81. jne loop
  82.  
  83.  
  84. mov $EXIT_NR , %eax
  85. mov $EXIT_CODE_SUCCESS, %ebx
  86. int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement