[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
need help with this machine code
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 35
Thread images: 4
File: visual-studio-2013-logo.png (59 KB, 697x401) Image search: [Google]
visual-studio-2013-logo.png
59 KB, 697x401
Write a program in assembly language that will:
1. Read a number, n;
2. Read a second non-negative number, limit;
3. Go round a loop in which a further n non-negative numbers are read. Each number less than or
equal to limit should be added to a variable, smalltot, and each number greater than limit should
be added to bigtot;
4. Write out the smalltot and bigtot variables
>>
>>51300858
>>>/homework/
>>
What hardware?
>>
>>51301069
Microsoft Visual Studio
>>
>>51300858
What assembly language, retard?
>>
>>51301122
C++
>>
>>51301134
Is not assembly language...
>>
>>51301178
i need to write it in Microsoft Visual C++.
>>
>>51300858
Sound pretty simple desu senpai.
Its basic loop and >=, <=
>>
>>51301208
i understand the principles but we have not been taught how to write it
>>
File: 1447275845940.png (502 KB, 485x723) Image search: [Google]
1447275845940.png
502 KB, 485x723
>>51301201
Where is exacly problem? Post code, post errors
>>
>>51300858
While you guys are doing OP's homework, go ahead and do mine too:


Write and submit a MIPS Assembly Language program, by collecting the functions implemented in the "Other Programs" projects, which:
1) reads the year of interest from user input,
2) displays the dates and time of all full moons for the year, and
3) identifies the monthly and seasonal blue moons which occur during that year.

The program must make use of subprograms (functions, methods, subroutines, etc.).
>>
>>51301228
> post code
Nigga he's waiting on you.
>>
>>51301224
Stop wasting your parents money at university if you can't figure this simple shit out yourself, jesus christ.
>>
>>51301224
lmao, you'll never make it in cs if you can't figure it out yourself
>>
>>51301233
Just write the program in C and get the assembly from a C compiler.
>>
>>51301254
(Not OP) lol, was thinking about that one right ahead

char line[1024];
scanf("%[^\n]", line);

while(yearDate)
{
if(isFullMoon(yearDate)) printf("%d %d %d", YEAR(yearDate), MONTH(yearDate), DAY(yearDate));
}

while: Same as above, different if-check

>>
>>51301310
>>51301254
>>51301233
+ And then objdump to get mips assembly ;^)
>>
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
int main(void)
{
char getn[] = "Input how many numbers do you want to test (input n) :";
char getnext[] = "Insert next number ";
char numberzero[] = "The number of zero values is ";
char numbernegative[] = "The number of negative values is ";
char numberpositive[] = "The number of positive values is ";
char format[] = "%d"; // format string for the scanf function
char formatnumber[] = "%d\n"; //declaration of the format string to be used in printf function

int n;
int pos = 0; //declaration of an integer variable
int nega = 0; //declaration of an integer variable
int zero = 0; //declaration of an integer variable
int x;
_asm {
lea eax, getn // ask for the first number
push eax // push the variable onto the stack
// push the variable onto the stack
call printf // call printf, it will take parameter from the stack
add esp, 4 //clean the top position in the stack


lea eax, n //read it in
push eax // push the variable onto the stack
lea eax, format //address of the format string is saved in eax
push eax // push the variable onto the stack
call scanf // call printf, it will take parameter from the stack
add esp, 8 //clean the top 2 positions in the stack
>>
>>51301329
not quite. you can just do cc -S -o output.S input.c
>>
>>51301331
>lea eax, getn
>push eax
>call printf

lold, literally just printf(getn) but with more lines, way to productivity! But good practice
>>
>>51301331


////////// loop function

mov ecx, n // initialize loop counter by loading n into 32 bit accumulator
LOP : push ecx // loop count index saved on stack
lea eax, getnext //ask for the next number
push eax // push the variable onto the stack
call printf // call printf, it will take parameter from the stack
add esp, 4 //clean the top position in the stack

lea eax, x // read the next number x
push eax // push the variable onto the stack
lea eax, format //address of the format string is saved in eax
push eax // push the variable onto the stack
call scanf // call printf, it will take parameter from the stack
add esp, 8 //clean the top 2 positions in the stack

mov eax, x //initialise eax as the number we just read
cmp eax, 0 //compare x (which is in eax) with 0


jne notzero // if x is not zero jump to notzero
add zero, 1 //add 1 to the variable zero
jmp next

notzero :
jl negative // if x is lower then 0 jump to negative
add pos, 1 //add 1 to the variable pos
jmp next
>>
>using assembly language
>2015
>>
>>51301404
>Not coding crysis in macro-free assembly
>>
>>51300858

/r/stackoverflow
>>
>>51301404
this is how i feel right now honestly.
>>
File: 23_yrs_c_hash_experience.jpg (31 KB, 512x343) Image search: [Google]
23_yrs_c_hash_experience.jpg
31 KB, 512x343
Op, kill yourself.
>>
>>51300858
go to the homework board >>>/hm/
>>
>>51301646
maybe if i could give them enough cock they would help
>>
A time ago I made this one that just output the same string you input maybe it can help you to start with something

http://pastebin.com/KkCxvmfZ
>>
>>51301254
>>51301310

The assembly returned by a compiler would not follow convention for handwritten MIPS.
>>
>>51301854
Depends of optimation, a good "pretty print" compiler will output just fine, just small adjustments
>>
>>51301778
thank for the attempt of serious help here, i am just lost with how to use this honestly i understand what need to be done but i have really no idea how to write it in MSV
>>
>>51301854
Uh? You just tidy it up you retard. Unless of course you're referring to the ABI, which must be followed whether it's from a C compiler or not.
>>
>>51300858
gtdo and do your homework yourself, faggot kid
Thread replies: 35
Thread images: 4

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.