Advertisement
aranhid

Untitled

Sep 27th, 2020
745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ------ Test Best
  2.  
  3. section .text
  4.  
  5. global _start
  6.  
  7. _start:
  8.  
  9.     mov edx, 6
  10.     mov ecx, message
  11.     mov ebx, 1
  12.     mov eax, 4
  13.     int 0x80
  14.    
  15.     mov [message+2], byte 'B'
  16.    
  17.     mov edx, 6
  18.     mov ecx, message
  19.     mov ebx, 1
  20.     mov eax, 4
  21.     int 0x80
  22.  
  23.     mov     eax, 1
  24.     int     0x80
  25.  
  26. section .data
  27.  
  28.     message db 'Test', 0xA, 0xD
  29.  
  30.  
  31. --------- odd or even
  32.  
  33. %macro print 2
  34.     mov edx, %1
  35.     mov ecx, %2
  36.     mov ebx, 1
  37.     mov eax, 4
  38.     int 0x80
  39. %endmacro
  40.  
  41. section .text
  42.  
  43. global _start
  44.  
  45. _start:
  46.  
  47.     mov ax, [value]
  48.    
  49.     and ax, 1
  50.     cmp ax, 0
  51.     jne _odd
  52.     je _even
  53.    
  54. _even:
  55.     print len1, message1
  56.     jmp _exit
  57.    
  58. _odd:
  59.     print len2, message2
  60.    
  61. _exit:
  62.     mov     eax, 1
  63.     int     0x80
  64.  
  65. section .data
  66.  
  67.     value db 1
  68.     message1 db "The value is even", 0xA, 0xD
  69.     len1 equ $ - message1
  70.     message2 db "The value is odd", 0xA, 0xD
  71.     len2 equ $ - message2
  72.  
  73. ---------- mod
  74.  
  75. %macro print 2
  76.     mov edx, %1
  77.     mov ecx, %2
  78.     mov ebx, 1
  79.     mov eax, 4
  80.     int 0x80
  81. %endmacro
  82.  
  83. section .text
  84.  
  85. global _start
  86.  
  87. _start:
  88.  
  89.     mov ecx, 10
  90.     mov edx, 0
  91.     mov eax, 123
  92.     div ecx
  93.    
  94.     mov eax, edx ; edx -- reminder, eax - quotent
  95.     add eax, '0'
  96.     mov [result], eax
  97.     print 1, result
  98.     print nlen, newline
  99.  
  100.     print len, message
  101.     print nlen, newline
  102.    
  103.     mov     eax, 1
  104.     int     0x80
  105.  
  106. section .data
  107.  
  108.     number dw 1
  109.     message db "Done"
  110.     len equ $ - message
  111.     newline db 0xA, 0xD
  112.     nlen equ $ - newline
  113.    
  114. section .bss
  115.    
  116.     result resb 1
  117.  
  118.  
  119. ----------------- mod 2
  120. %macro print 2
  121.     mov edx, %1
  122.     mov ecx, %2
  123.     mov ebx, 1
  124.     mov eax, 4
  125.     int 0x80
  126. %endmacro
  127.  
  128. section .text
  129.  
  130. global _start
  131.  
  132. _start:
  133.  
  134.     mov ecx, 10
  135.     mov ebx, 0
  136.     mov eax, [number]
  137.     div ecx
  138.    
  139.     mov eax, edx ; edx -- reminder, eax - quotent
  140.     add eax, '0'
  141.     mov [result], eax
  142.     print 1, result
  143.     print nlen, newline
  144.  
  145.     print len, message
  146.     print nlen, newline
  147.    
  148.     mov     eax, 1
  149.     int     0x80
  150.  
  151. section .data
  152.  
  153.     number dd 3214
  154.     message db "Done"
  155.     len equ $ - message
  156.     newline db 0xA, 0xD
  157.     nlen equ $ - newline
  158.    
  159. section .bss
  160.    
  161.     result resb 1
  162.  
  163.  
  164. -----------------------------------
  165.  
  166. %macro pushd 0
  167.     push edx
  168.     push ecx
  169.     push ebx
  170.     push eax
  171. %endmacro
  172.  
  173. %macro popd 0
  174.     pop eax
  175.     pop ebx
  176.     pop ecx
  177.     pop edx
  178. %endmacro
  179.  
  180. %macro print 2
  181.     pushd
  182.     mov edx, %1
  183.     mov ecx, %2
  184.     mov ebx, 1
  185.     mov eax, 4
  186.     int 0x80
  187.     popd
  188. %endmacro
  189.  
  190. %macro dprint 0
  191.  
  192. %endmacro
  193.  
  194. section .text
  195.  
  196. global _start
  197.  
  198. _start:
  199.     mov ecx, 10
  200.     mov bx, 0
  201.     mov eax, [number]
  202.    
  203. _divide:
  204.     mov edx, 0
  205.     div ecx
  206.     push dx
  207.     inc bx
  208.     test eax, eax
  209.     jnz _divide
  210.  
  211.     mov cx, bx
  212.    
  213. _digit:
  214.     pop ax
  215.     add ax, '0'
  216.     mov [count], ax
  217.     print 1, count
  218.     dec cx
  219.     mov ax, cx
  220.     cmp cx, 0
  221.     jg _digit
  222.    
  223.     print nlen, newline
  224.     print len, message
  225.     print nlen, newline
  226.    
  227.     mov     eax, 1
  228.     int     0x80
  229.  
  230. section .data
  231.  
  232.     number dd 9876
  233.     message db "Done"
  234.     len equ $ - message
  235.     newline db 0xA, 0xD
  236.     nlen equ $ - newline
  237.    
  238. section .bss
  239.    
  240.     count resb 1
  241.  
  242. -----------------------------------
  243. %macro pushd 0
  244.     push edx
  245.     push ecx
  246.     push ebx
  247.     push eax
  248. %endmacro
  249.  
  250. %macro popd 0
  251.     pop eax
  252.     pop ebx
  253.     pop ecx
  254.     pop edx
  255. %endmacro
  256.  
  257. %macro print 2
  258.     pushd
  259.     mov edx, %1
  260.     mov ecx, %2
  261.     mov ebx, 1
  262.     mov eax, 4
  263.     int 0x80
  264.     popd
  265. %endmacro
  266.  
  267. %macro dprint 0
  268.     pushd
  269.    
  270.     %%_divide:
  271.         mov edx, 0
  272.         div ecx
  273.         push dx
  274.         inc bx
  275.         test eax, eax
  276.         jnz %%_divide
  277.  
  278.     mov cx, bx
  279.    
  280.     %%_digit:
  281.         pop ax
  282.         add ax, '0'
  283.         mov [count], ax
  284.         print 1, count
  285.         dec cx
  286.         mov ax, cx
  287.         cmp cx, 0
  288.         jg %%_digit
  289.        
  290.     print nlen, newline
  291.     popd
  292. %endmacro
  293.  
  294. section .text
  295.  
  296. global _start
  297.  
  298. _start:
  299.     mov ecx, 10
  300.     mov bx, 0
  301.     mov eax, [number]
  302.    
  303.     dprint
  304.     mov eax, 1234
  305.     dprint
  306.    
  307.     print nlen, newline
  308.     print len, message
  309.     print nlen, newline
  310.    
  311.     mov     eax, 1
  312.     int     0x80
  313.  
  314. section .data
  315.  
  316.     number dd 9876
  317.     message db "Done"
  318.     len equ $ - message
  319.     newline db 0xA, 0xD
  320.     nlen equ $ - newline
  321.    
  322. section .bss
  323.    
  324.     count resb 1
  325.  
  326. ------------------------------------
  327.  
  328. %macro pushd 0
  329.     push edx
  330.     push ecx
  331.     push ebx
  332.     push eax
  333. %endmacro
  334.  
  335. %macro popd 0
  336.     pop eax
  337.     pop ebx
  338.     pop ecx
  339.     pop edx
  340. %endmacro
  341.  
  342. %macro print 2
  343.     pushd
  344.     mov edx, %1
  345.     mov ecx, %2
  346.     mov ebx, 1
  347.     mov eax, 4
  348.     int 0x80
  349.     popd
  350. %endmacro
  351.  
  352. %macro dprint 0
  353.     pushd
  354.    
  355.     mov ecx, 10
  356.     mov bx, 0
  357.    
  358.     %%_divide:
  359.         mov edx, 0
  360.         div ecx
  361.         push dx
  362.         inc bx
  363.         test eax, eax
  364.         jnz %%_divide
  365.  
  366.     mov cx, bx
  367.    
  368.     %%_digit:
  369.         pop ax
  370.         add ax, '0'
  371.         mov [count], ax
  372.         print 1, count
  373.         dec cx
  374.         mov ax, cx
  375.         cmp cx, 0
  376.         jg %%_digit
  377.        
  378.     print nlen, newline
  379.     popd
  380. %endmacro
  381.  
  382. section .text
  383.  
  384. global _start
  385.  
  386. _start:
  387.     mov bx, 0
  388.    
  389. _loop:
  390.     add al, [array + ebx]
  391.    
  392.     inc bx
  393.     cmp bx, alen
  394.     jne _loop
  395.    
  396.     dprint
  397.    
  398.     print nlen, newline
  399.     print len, message
  400.     print nlen, newline
  401.    
  402.     mov     eax, 1
  403.     int     0x80
  404.  
  405. section .data
  406.     array db 10, 13, 14, 7, 8, 12
  407.     alen equ $ - array
  408.     message db "Done"
  409.     len equ $ - message
  410.     newline db 0xA, 0xD
  411.     nlen equ $ - newline
  412.    
  413. section .bss
  414.    
  415.     count resb 1
  416.  
  417. --------------------------------------------------
  418.  
  419. %macro pushd 0
  420.     push edx
  421.     push ecx
  422.     push ebx
  423.     push eax
  424. %endmacro
  425.  
  426. %macro popd 0
  427.     pop eax
  428.     pop ebx
  429.     pop ecx
  430.     pop edx
  431. %endmacro
  432.  
  433. %macro print 2
  434.     pushd
  435.     mov edx, %1
  436.     mov ecx, %2
  437.     mov ebx, 1
  438.     mov eax, 4
  439.     int 0x80
  440.     popd
  441. %endmacro
  442.  
  443. %macro dprint 0
  444.     pushd
  445.    
  446.     mov ecx, 10
  447.     mov bx, 0
  448.    
  449.     %%_divide:
  450.         mov edx, 0
  451.         div ecx
  452.         push dx
  453.         inc bx
  454.         test eax, eax
  455.         jnz %%_divide
  456.  
  457.     mov cx, bx
  458.    
  459.     %%_digit:
  460.         pop ax
  461.         add ax, '0'
  462.         mov [count], ax
  463.         print 1, count
  464.         dec cx
  465.         mov ax, cx
  466.         cmp cx, 0
  467.         jg %%_digit
  468.        
  469.     print nlen, newline
  470.     popd
  471. %endmacro
  472.  
  473. section .text
  474.  
  475. global _start
  476.  
  477. _start:
  478.     print len, msg
  479.     print nlen, newline
  480.    
  481.     mov ebx, 0
  482. _loop:
  483.     mov al, [msg + ebx]
  484.     cmp al, 'Z'
  485.    
  486.     jle _end
  487.    
  488.     sub eax, 32
  489.    
  490. _end:
  491.     mov [symbol], eax
  492.     print 1, symbol
  493.     inc ebx
  494.     cmp ebx, len
  495.     jne _loop
  496.    
  497.    
  498.     print nlen, newline
  499.     mov     eax, 1
  500.     int     0x80
  501.  
  502. section .data
  503.     msg db "AsSembLER"
  504.    
  505.     len equ $ - msg
  506.     newline db 0xA, 0xD
  507.     nlen equ $ - newline
  508.    
  509. section .bss
  510.    
  511.     symbol resb 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement