Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #----------------------------------------------------------------
- # Program lab_1.s - Asemblery Laboratorium IS II rok
- #----------------------------------------------------------------
- #
- # To compile: as -o lab_1.o lab_1.s
- # To link: ld -o lab_1 lab_1.o
- # To run: ./lab_1
- #
- #----------------------------------------------------------------
- .equ kernel,0x80 #Linux system functions entry
- .equ write,0x04 #write data to file function
- .equ exit,0x01 #exit program function
- .equ stdout,0x01 #handle to stdout
- .equ zero,0x00
- .data
- starttxt: #first message
- .ascii "Start\n"
- endtxt: #second message
- .ascii "Finish\n"
- arg1: #first argument
- .byte 1
- arg2: #second argument
- .word 2
- arg3: #third argument
- .long 3
- result: #result
- .long 999
- .equ startlen, endtxt - starttxt
- .equ endlen, arg1 - endtxt
- .text
- .global _start
- _start:
- MOVL $write,%eax
- MOVL $stdout,%ebx
- MOVL $starttxt,%ecx
- MOVL $startlen,%edx
- INT $kernel
- NOP
- MOVL $zero,%eax
- MOVL $zero,%ebx
- MOVB arg1,%al
- MOVW arg2,%bx
- MOVL arg3,%ecx
- ADD %ebx,%eax
- SUB %ecx,%eax
- MOVL %eax,result
- NOP
- MOVL $write,%eax
- MOVL $stdout,%ebx
- MOVL $endtxt,%ecx
- MOVL $endlen,%edx
- INT $kernel
- NOP
- theend:
- MOVL $exit,%eax
- INT $kernel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement