Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------ Test Best
- section .text
- global _start
- _start:
- mov edx, 6
- mov ecx, message
- mov ebx, 1
- mov eax, 4
- int 0x80
- mov [message+2], byte 'B'
- mov edx, 6
- mov ecx, message
- mov ebx, 1
- mov eax, 4
- int 0x80
- mov eax, 1
- int 0x80
- section .data
- message db 'Test', 0xA, 0xD
- --------- odd or even
- %macro print 2
- mov edx, %1
- mov ecx, %2
- mov ebx, 1
- mov eax, 4
- int 0x80
- %endmacro
- section .text
- global _start
- _start:
- mov ax, [value]
- and ax, 1
- cmp ax, 0
- jne _odd
- je _even
- _even:
- print len1, message1
- jmp _exit
- _odd:
- print len2, message2
- _exit:
- mov eax, 1
- int 0x80
- section .data
- value db 1
- message1 db "The value is even", 0xA, 0xD
- len1 equ $ - message1
- message2 db "The value is odd", 0xA, 0xD
- len2 equ $ - message2
- ---------- mod
- %macro print 2
- mov edx, %1
- mov ecx, %2
- mov ebx, 1
- mov eax, 4
- int 0x80
- %endmacro
- section .text
- global _start
- _start:
- mov ecx, 10
- mov edx, 0
- mov eax, 123
- div ecx
- mov eax, edx ; edx -- reminder, eax - quotent
- add eax, '0'
- mov [result], eax
- print 1, result
- print nlen, newline
- print len, message
- print nlen, newline
- mov eax, 1
- int 0x80
- section .data
- number dw 1
- message db "Done"
- len equ $ - message
- newline db 0xA, 0xD
- nlen equ $ - newline
- section .bss
- result resb 1
- ----------------- mod 2
- %macro print 2
- mov edx, %1
- mov ecx, %2
- mov ebx, 1
- mov eax, 4
- int 0x80
- %endmacro
- section .text
- global _start
- _start:
- mov ecx, 10
- mov ebx, 0
- mov eax, [number]
- div ecx
- mov eax, edx ; edx -- reminder, eax - quotent
- add eax, '0'
- mov [result], eax
- print 1, result
- print nlen, newline
- print len, message
- print nlen, newline
- mov eax, 1
- int 0x80
- section .data
- number dd 3214
- message db "Done"
- len equ $ - message
- newline db 0xA, 0xD
- nlen equ $ - newline
- section .bss
- result resb 1
- -----------------------------------
- %macro pushd 0
- push edx
- push ecx
- push ebx
- push eax
- %endmacro
- %macro popd 0
- pop eax
- pop ebx
- pop ecx
- pop edx
- %endmacro
- %macro print 2
- pushd
- mov edx, %1
- mov ecx, %2
- mov ebx, 1
- mov eax, 4
- int 0x80
- popd
- %endmacro
- %macro dprint 0
- %endmacro
- section .text
- global _start
- _start:
- mov ecx, 10
- mov bx, 0
- mov eax, [number]
- _divide:
- mov edx, 0
- div ecx
- push dx
- inc bx
- test eax, eax
- jnz _divide
- mov cx, bx
- _digit:
- pop ax
- add ax, '0'
- mov [count], ax
- print 1, count
- dec cx
- mov ax, cx
- cmp cx, 0
- jg _digit
- print nlen, newline
- print len, message
- print nlen, newline
- mov eax, 1
- int 0x80
- section .data
- number dd 9876
- message db "Done"
- len equ $ - message
- newline db 0xA, 0xD
- nlen equ $ - newline
- section .bss
- count resb 1
- -----------------------------------
- %macro pushd 0
- push edx
- push ecx
- push ebx
- push eax
- %endmacro
- %macro popd 0
- pop eax
- pop ebx
- pop ecx
- pop edx
- %endmacro
- %macro print 2
- pushd
- mov edx, %1
- mov ecx, %2
- mov ebx, 1
- mov eax, 4
- int 0x80
- popd
- %endmacro
- %macro dprint 0
- pushd
- %%_divide:
- mov edx, 0
- div ecx
- push dx
- inc bx
- test eax, eax
- jnz %%_divide
- mov cx, bx
- %%_digit:
- pop ax
- add ax, '0'
- mov [count], ax
- print 1, count
- dec cx
- mov ax, cx
- cmp cx, 0
- jg %%_digit
- print nlen, newline
- popd
- %endmacro
- section .text
- global _start
- _start:
- mov ecx, 10
- mov bx, 0
- mov eax, [number]
- dprint
- mov eax, 1234
- dprint
- print nlen, newline
- print len, message
- print nlen, newline
- mov eax, 1
- int 0x80
- section .data
- number dd 9876
- message db "Done"
- len equ $ - message
- newline db 0xA, 0xD
- nlen equ $ - newline
- section .bss
- count resb 1
- ------------------------------------
- %macro pushd 0
- push edx
- push ecx
- push ebx
- push eax
- %endmacro
- %macro popd 0
- pop eax
- pop ebx
- pop ecx
- pop edx
- %endmacro
- %macro print 2
- pushd
- mov edx, %1
- mov ecx, %2
- mov ebx, 1
- mov eax, 4
- int 0x80
- popd
- %endmacro
- %macro dprint 0
- pushd
- mov ecx, 10
- mov bx, 0
- %%_divide:
- mov edx, 0
- div ecx
- push dx
- inc bx
- test eax, eax
- jnz %%_divide
- mov cx, bx
- %%_digit:
- pop ax
- add ax, '0'
- mov [count], ax
- print 1, count
- dec cx
- mov ax, cx
- cmp cx, 0
- jg %%_digit
- print nlen, newline
- popd
- %endmacro
- section .text
- global _start
- _start:
- mov bx, 0
- _loop:
- add al, [array + ebx]
- inc bx
- cmp bx, alen
- jne _loop
- dprint
- print nlen, newline
- print len, message
- print nlen, newline
- mov eax, 1
- int 0x80
- section .data
- array db 10, 13, 14, 7, 8, 12
- alen equ $ - array
- message db "Done"
- len equ $ - message
- newline db 0xA, 0xD
- nlen equ $ - newline
- section .bss
- count resb 1
- --------------------------------------------------
- %macro pushd 0
- push edx
- push ecx
- push ebx
- push eax
- %endmacro
- %macro popd 0
- pop eax
- pop ebx
- pop ecx
- pop edx
- %endmacro
- %macro print 2
- pushd
- mov edx, %1
- mov ecx, %2
- mov ebx, 1
- mov eax, 4
- int 0x80
- popd
- %endmacro
- %macro dprint 0
- pushd
- mov ecx, 10
- mov bx, 0
- %%_divide:
- mov edx, 0
- div ecx
- push dx
- inc bx
- test eax, eax
- jnz %%_divide
- mov cx, bx
- %%_digit:
- pop ax
- add ax, '0'
- mov [count], ax
- print 1, count
- dec cx
- mov ax, cx
- cmp cx, 0
- jg %%_digit
- print nlen, newline
- popd
- %endmacro
- section .text
- global _start
- _start:
- print len, msg
- print nlen, newline
- mov ebx, 0
- _loop:
- mov al, [msg + ebx]
- cmp al, 'Z'
- jle _end
- sub eax, 32
- _end:
- mov [symbol], eax
- print 1, symbol
- inc ebx
- cmp ebx, len
- jne _loop
- print nlen, newline
- mov eax, 1
- int 0x80
- section .data
- msg db "AsSembLER"
- len equ $ - msg
- newline db 0xA, 0xD
- nlen equ $ - newline
- section .bss
- symbol resb 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement