laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 01:23 PM |
I finished my x86 Assembly equivalent of my custom lua sleep function! The Assembly source code is a bit long, since lua is more of a high programming language. My original lua sleep function: function sleep(t) local tq = t * 10000000 for i = 1, tq do end end sleep(5) --will initiate a "sleep" for about 5 seconds And finally, the Assembly Equivalent I just finished: INCLUDE \masm32\include\masm32rt.inc .xmm .data t DD 0 tq DD 0 tr DD 10000000d i DD 0 .code sleep proc NOP MOV EBX, [t] MOV EAX, [tr] ADD tq, EBX PUSH EBX MUL tq MOV ECX, [tq] SUB tq, ECX ADD tq, EDX PUSH EAX PUSH EDX PUSH ECX MOV EAX, [tq] loopB: INC i CMP EAX, i JE loopEND JNE loopB NOP loopEND: MOV EAX, [t] MOV EBX, [tq] MOV ECX, [i] SUB t, EAX SUB tq, EBX SUB i, ECX NOP RET sleep endp ADD t, 5d CALL sleep END The 'ADD t, 5d' section is the input for the sleep procedure, the 'CALL sleep' is initiating the sleep procedure, kind of like the INT interrupt tables. Perhaps I could MOV 0x01 into the AL register, and call an INT 0x16 to get input so that you could call sleep and specify input wait time from a console, or client as well. |
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 02:03 PM |
| You don't need to worry about MOVing t into a 32 bit register, the SUBing t to the register, since the procedure already SUBs t, tq, and i back to 0 right at the end. |
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 02:57 PM |
| Also, this procedure will work with masm x86 Assembly, over Athlon, and Intel architectures. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 03:00 PM |
| Busy waiting is a stupid way of sleeping, implementing it in asm is also stupid. |
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:03 PM |
| Implementing it in assembly is more effecient since you no longer have to deal with complex run times, and compile times that high level languages will bring up. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 08 Aug 2016 03:04 PM |
gross. move this to stack exchange and low level websites, not this forum.
|
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:05 PM |
| this forum does imply that is is about "anything that has do do with scripting other than questions for help", sorry to burst your bubble. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 08 Aug 2016 03:07 PM |
sorry but high level languages only. (Lua)
|
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:08 PM |
| specified by who? lol. I guess low level language programmers and high level programmers don't like each other any more :( |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 03:11 PM |
No I don't just not like you for being a low-level programmer, I dislike everybody :)
Not get off my gawd dern lawn!~ |
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:11 PM |
| Anyway I thought it necessary to post the Assembly variant, for anyone who is interested in implementing low level programming. The best part with low level languages is that you are not limited to what a compiler and parser allow for that language. :1 |
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
| |
|
Crimsonal
|
  |
| Joined: 23 Apr 2011 |
| Total Posts: 1795 |
|
| |
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:16 PM |
| thanks Crim. I'm also working on building a 3d world kind of like ROBLOX from the ground up with Assembly, C#, and XML. Which will be pretty fun I guess. |
|
|
| Report Abuse |
|
|
Crimsonal
|
  |
| Joined: 23 Apr 2011 |
| Total Posts: 1795 |
|
|
| 08 Aug 2016 03:17 PM |
| Really? Message me when it's done :3 |
|
|
| Report Abuse |
|
|
L2000
|
  |
| Joined: 03 Apr 2008 |
| Total Posts: 77448 |
|
|
| 08 Aug 2016 03:18 PM |
Idk assembly but I'd assume there's a better way to do it Bcuz this'll keep using up the processor quite a bit which u don't want from sleep |
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:19 PM |
| Well, a team of friends and I are working on it together, I am working on the software tho. We also have a site for the project as well. I'll try to PM you to let you know when I have a stable alpha version if you want to try it out! |
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:21 PM |
| @L2000, true, I guess the sleep procedure is more of a freeze procedure in this case, literally doing NOP until [i] == [tq]. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 03:25 PM |
"Implementing it in assembly is more effecient since you no longer have to deal with complex run times, and compile times that high level languages will bring up." No such thing as efficiency when you're busy waiting LMFAO |
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:27 PM |
if you're trying to make it seem ironic, you really aren't too successful m8. Being that the procedure is made to freeze/sleep for t seconds. I hope you're not butt hurt cause you don't understand the source code. :1 |
|
|
| Report Abuse |
|
|
| |
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:35 PM |
| dang kind of afraid to view that link, since you seem really angry at this point lol. |
|
|
| Report Abuse |
|
|
laczka
|
  |
| Joined: 26 Jan 2015 |
| Total Posts: 258 |
|
|
| 08 Aug 2016 03:36 PM |
| keep in mind I sad "I hope" not necessarily implying that you don't know assembly language, I am hoping that was I said is not the case. You seem to be easily triggered. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 08 Aug 2016 03:36 PM |
Kind of afraid to open that link, you seem smarter than me or something and we can't have that!
^o^ |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2016 03:37 PM |
I'm not the one trying to show off on the forums by posting assembly thinking I'm some kind of genius when in reality assembly is simple.
Bud, there have been plenty of people like you. You're not cool because you know a language a lot of people don't know. |
|
|
| Report Abuse |
|
|