generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: would this work?

Previous Thread :: Next Thread 
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
29 Oct 2014 10:26 PM
i know this isn't the right place for this, but if anyone knows anything about assembly, can you tell me if this would work?

SECTION .TEXT
GLOBAL _MOD;
_MOD:
MOV BX,ITEM;
MOV AX,SECOND;
DIV BX; div of ax register
MOV RESULT,DX;

SECTION .DATA
MOV ITEM,4;
MOV SECOND,2;
JMP _MOD; sets result to 4 % 2

Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
29 Oct 2014 10:40 PM
b1


semicolons are love, semicolons are life
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
29 Oct 2014 10:50 PM
b2


semicolons are love, semicolons are life
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
29 Oct 2014 10:57 PM
It seems fine, but don't you define memory in the .data section using var size value (item dw 4 since you are using 16 bit reg.)
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
30 Oct 2014 12:28 AM
so, could i just do this in .bss?

SECTION .TEXT
GLOBAL _MOD;
_MOD:
MOV BX,ITEM;
MOV AX,SECOND;
DIV BX; div of ax register
MOV RESULT,DX;

SECTION .BSS
MOV ITEM,4;
MOV SECOND,2;

SECTION .DATA
JMP _MOD; sets result to 4 % 2

Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Oct 2014 12:31 AM
Never used the .BSS section, but I meant this (in the .data section):

ITEM DW 4 ; you can also use WORD instead of DW
SECOND DW 2
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
30 Oct 2014 12:35 AM
oh, thanks. never knew that before.


semicolons are love, semicolons are life
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Oct 2014 12:35 AM
"dw" just means define word.
There is also db, dd, and dq (define byte, define dword, and define qword respectively)
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
30 Oct 2014 08:17 PM
so, if i wanted to find if a number was odd, would this work?

SECTION .TEXT
GLOBAL _MOD;
_MOD:
MOV BX,ITEM;
MOV AX,SECOND;
DIV BX;
MOV RESULT,DX;

GLOBAL HANDLE;
HANDLE:
MOV ODD,'FALSE';
GLOBAL _INC;
_ISODD:
MOV EAX,INPUT;
MOV ITEM,EAX;
MOV SECOND,2;
JMP _MOD;
CMP RESULT,0;
JZ HANDLE;
MOV ODD,'TRUE';


SECTION .DATA
INPUT DW 1;
JMP _ISODD;
ISODD DW ODD;
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Oct 2014 08:22 PM
The code is a bit too long but to check if it was add, you can just use the AND instruction and use "1" so if the right-most bit is one, it is odd. Otherwise even
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Oct 2014 08:23 PM
odd* (and not 1 in quotes :)) since: number & 1 = right-most bit (if you know your bitwise functions)
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
30 Oct 2014 08:46 PM
and final question (sorry for bothering you, if i am, i know i keep asking a bunch of questions), but would this work for solving a slope intercept equation and storing the value in X


SECTION .TEXT
GLOBAL _SINTERCEPT;
GLOBAL _EXIT;

_SINTERCEPT:

MOV EAX,M;
MOV EBX,Y;
MOV ECX,B;
SUB EBX,ECX;
CMP EAX,0;
JZ _EXIT;
DIV EBX;
MOV X,EAX;

_EXIT:
EXIT;

SECTION .DATA
M DW 2;
B DW 6;
Y DW 20;
JMP _SINTERCEPT;
Report Abuse
YoungSuperman100 is not online. YoungSuperman100
Joined: 08 Feb 2010
Total Posts: 2959
30 Oct 2014 08:47 PM
idk
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Oct 2014 08:54 PM
You would have to define the X variable but shouldn't you divide (y - b) by m (eax) not, not by y-b?

Since:
ebx = eax * x + ecx
(ebx - ecx) = eax * x
x = (ebx - ecx) / eax
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
30 Oct 2014 09:00 PM
i thought div divides operand1 by the eax register.


semicolons are love, semicolons are life
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Oct 2014 09:03 PM
it does but your eax is the slope which you should really change and use something else, like Y or something.

mov eax, y
mov ebx, m
mov ecx, b

sub eax, ecx ; subtract b by y (y - b = mx)
div ebx ; divide y by m ( (y - b)/m = x)
; eax should now be y, you should compare make sure it isn't dividing by 0 ofc
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Oct 2014 09:04 PM
eax should now be x* my bad
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Oct 2014 09:06 PM
divide (y - b) by m*
The code is correct, the comment was incomplete
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
30 Oct 2014 09:09 PM
so, this?


SECTION .TEXT
GLOBAL _SINTERCEPT;
GLOBAL _EXIT;

_SINTERCEPT:

MOV EAX,Y;
MOV EBX,M;
MOV ECX,B;
SUB EAX,ECX;
CMP EBX,0;
JZ _EXIT;
DIV EBX;
MOV X,EAX;

_EXIT:
EXIT;

SECTION .DATA
M DW 2;
B DW 6;
Y DW 20;
JMP _SINTERCEPT;
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Oct 2014 09:12 PM
yeah that seems fine, except you might need to initialize x

X DW 0 ; you can alternatively use a ? to keep data already in that address but there really is no point
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
30 Oct 2014 09:16 PM
final code:

SECTION .TEXT
GLOBAL _SINTERCEPT;
GLOBAL _EXIT;

_SINTERCEPT:

MOV EAX,Y;
MOV EBX,M;
MOV ECX,B;
SUB EAX,ECX;
CMP EBX,0;
JZ _EXIT;
DIV EBX;
MOV X,EAX;

_EXIT:
EXIT;

SECTION .DATA
M DW 2;
B DW 6;
Y DW 20;
X DW 0;
JMP _SINTERCEPT;
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image