User Name
Password

Register Members List Calendar Search FAQ Posting Guidelines
Assembly
Thread Tools
evan
Formerly CoachKrzyzewski
 
Join Date: Jan 2006
Location: Charlottesville, VA
Send a message via AIM to evan  
2010-03-25, 02:25

just made a bubble sort in assembly. I feel awesome.
  quote
scratt
Veteran Member
 
Join Date: Jul 2004
Location: M-F: Thailand Weekends : F1 2010 - Various Tracks!
Send a message via Skype™ to scratt 
2010-03-25, 04:06

Nice work. There is nothing like coding in ASM to put hairs on your chest!!

What flavour of assembly? i386, ARM... ?
  quote
Baron Munchausen
Senior Member
 
Join Date: Jan 2005
 
2010-03-25, 04:51

I am really glad to hear people still get a buzz from doing such things and I am also happy now I realised that I got a buzz from hearing about another person doing it!

I always used to check key routines or fragments to see what the compiler created in machine code. People who write compilers sure know their machine code!

Brings it home that a computer does only a few things such as loads, compares, add/subtract, shift, branch.
  quote
bassplayinMacFiend
Banging the Bottom End
 
Join Date: Jun 2004
 
2010-03-25, 06:59

Wow, that's awesome! I did ASM in SPIM ( a MIPS emulator) back in school. I loved ASM because with proper flowcharting, an ASM program will run right the first time it's programmed. Plus I think it's wicked to get "inside the head" of a CPU and get a solid understanding of how it works / what makes it tick.
  quote
Ryan
Veteran Member
 
Join Date: May 2004
Location: Promise Land of Trustafarians
 
2010-03-25, 08:43

Quote:
Originally Posted by bassplayinMacFiend View Post
Wow, that's awesome! I did ASM in SPIM ( a MIPS emulator) back in school. I loved ASM because with proper flowcharting, an ASM program will run right the first time it's programmed. Plus I think it's wicked to get "inside the head" of a CPU and get a solid understanding of how it works / what makes it tick.
I’m in a class using the same tool right now. We haven’t written anything, we’re still on control flow and datapaths right now, but I think we’re starting that next week. Our semester project is to write our own MIPS emulator, so I should go get started on that.
  quote
evan
Formerly CoachKrzyzewski
 
Join Date: Jan 2006
Location: Charlottesville, VA
Send a message via AIM to evan  
2010-03-25, 23:37

Quote:
Originally Posted by scratt View Post
Nice work. There is nothing like coding in ASM to put hairs on your chest!!

What flavour of assembly? i386, ARM... ?
IBCM

Here's my bubbles sort - it sorts the array that is the last 5 lines of code. obviously you could change N and a[] and put in a different array and (hopefully) it would still work.

Code:
C00A 00 jmp start skip around the variables 0000 01 i dw 0 int i 0000 02 j dw 0 int j 0043 03 a dw 0 int a[] - array of 5 [ 5, 4, 3, 2, 1] 0005 04 N dw 0 int N 0001 05 one dw 1 3000 06 loadit dw 3000 6000 07 subit dw 6000 0000 08 temp dw 0 4000 09 stoit dw 4000 3004 0A oloop load n if (j >= N) goto xit 6002 0B sub j E023 0C jmpl xit jump to exit if N < j D023 0D jmpe xit jump to exit if N == j 3004 0E iloop load n if (i >= N-1) goto end of outterloop 6001 0F sub i 6005 10 sub 1 E03D 11 jmpl xit jump to end of iloop if N < i D03D 12 jmpe xit jump to end of iloop if N == i 3006 13 load loadit form instruction to load a[i] 5003 14 add a 5001 15 add i 5005 16 add 1 401C 17 store doit plant instruction into program 3007 18 load subit form instruction to load a[i] 5003 19 add a 5001 1A add i 401D 1B store doit2 plant instructions 0000 1C doit load doit 0000 1D doit2 dw 0 E024 1E jmpl swap goto swap if a[i]>a[i+1] 3001 1F load i i += 1 5005 20 add one 4001 21 store i C00E 22 jmp loop goto iloop 0000 23 xit 3006 24 swap load loadit form instructions to put a[i] in temp----- 5003 25 add a 5001 26 add i 4028 27 store doit3 plant instructions 0000 28 doit3 dw 0 4008 29 store a[i] storing in temp ----------------- 3009 2A load stoit form instructions to put a[i+1] in a[i] 5003 2B add a 5001 2C add i 4034 2D store doit4 plant instructions to store in a[i+1] 3006 2E load loadit 5005 2F add 1 5003 30 add a 5001 31 add i 4033 32 store doit5 0000 33 doit5 dw 0 0000 34 doit4 dw 0 put a[i+1] into a[i]------------------ 3009 35 load stoit form instructions to put temp in a[i+1] 5005 36 add 1 5003 37 add a 5001 38 add i 403B 39 store doit6 3008 3A load temp 0000 3B doit6 dw 0 puts temp in [a+1] C01F 3C jmp back into loop 3002 3D load j i += 1 5005 3E add one 4002 3F store j 3050 40 load zero 4001 41 store i C00A 42 jmp loop goto loop 0005 0004 0003 0002 0001
the first four digits of each line is all the compiler reads, the rest is just comments to make it readable.

when I finally got it it was awesome. One of the more rewarding programming experiences I've had (and last week we made our own hash tree! - in C++, not assembly )
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools

« Previous Thread | Next Thread »

All times are GMT -5. The time now is 18:29.


Powered by vBulletin®
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2022, AppleNova