Last active
October 30, 2020 13:16
-
-
Save chfle/c131c49655038316e458400c5546b2ed to your computer and use it in GitHub Desktop.
looping att asm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
.data | |
.global main | |
main: | |
movl $5, %ecx # loop 5 times | |
looping: | |
movl %ecx, %esi # move the current loop count to esi | |
movl $4, %eax # sys_write | |
movl $1, %ebx # stdout | |
movl $loopMessage, %ecx # message | |
movl $lMessageLen, %edx # message len.text | |
.data | |
.global main | |
main: | |
movl $5, %ecx # loop 5 times | |
looping: | |
movl %ecx, %esi # move the current loop count to esi | |
movl $4, %eax # sys_write | |
movl $1, %ebx # stdout | |
movl $loopMessage, %ecx # message | |
movl $lMessageLen, %edx # message len | |
int $0x80 # linux interrupt | |
movl %esi, %ecx #move the count back to ecx | |
cmp $0, %ecx | |
sub $1, %ecx | |
jne looping | |
movl $4, %eax # sys_write | |
movl $1, %ebx # stdout | |
movl $loopEndMessage, %ecx | |
movl $lEndLen, %edx | |
int $0x80 | |
movl $1, %eax | |
movl $0, %ebx | |
int $0x80 | |
loopMessage: | |
.ascii "Looping\n" | |
lMessageLen = . - loopMessage | |
loopEndMessage: | |
.ascii "Loop has finished\n" | |
lEndLen = . - loopEndMessage | |
int $0x80 # linux interrupt | |
movl %esi, %ecx #move the count back to ecx | |
loop looping | |
movl $loopEndMessage, %ecx | |
movl $lEndLen, %edx | |
int $0x80 | |
movl $1, %eax | |
movl $0, %ebx | |
int $0x80 | |
loopMessage: | |
.ascii "Looping\n" | |
lMessageLen = . - loopMessage | |
loopEndMessage: | |
.ascii "Loop has finished\n" | |
lEndLen = . - loopEndMessage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment