project2 / project3 com390
Signed-off-by: Amrit Panesar <apanesar@4195tech.com>
This commit is contained in:
1 parent
eb1cdc34a3
commit
b24453a5ba
16 files changed
+375
-13
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -43,7 +43,7 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
||||
@@ -2,48 +2,106 @@
|
||||
* Program: COM 390 - Project 2
|
||||
* Author: Amrit Panesar <apanesar-77260@student.coleman.edu
|
||||
* Date: 2015-08-11
|
||||
* Purpose: Count from 100 to 0 and 0 to 100 two different ways.
|
||||
* Purpose: Count from 0 to 100 and 100 to 0 two different ways.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "main.h"
|
||||
|
||||
int i, j, k = 0;
|
||||
char bufnum[3];
|
||||
int i, j, k = 0, linebr = 80/3;
|
||||
#define BUFARR 100
|
||||
#define BUFLEN 3
|
||||
int bufnum1[BUFARR], bufnum2[BUFARR], bufnum3[BUFARR];
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
printf("%s\n", "Calculating...");
|
||||
|
||||
if (hundred2zero() != TRUE) {
|
||||
printf("Error condition found, exiting early");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (zero2hundred() != TRUE) {
|
||||
if (zero2hundred1() != TRUE) {
|
||||
printf("Error condition found, exiting early");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (zero2hundred2() != TRUE) {
|
||||
printf("Error condition found, exiting early");
|
||||
return 1;
|
||||
}
|
||||
|
||||
pause();
|
||||
|
||||
printf("%s\n", "Printing Hundred to Zero..");
|
||||
for (i = 0; i < BUFARR; i++) {
|
||||
if (i % 10 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
printf("%03d ", bufnum1[i]);
|
||||
}
|
||||
printf("\n");
|
||||
pause();
|
||||
|
||||
printf("%s\n", "Printing Hundred to Zero (1)");
|
||||
for (i = 0; i < BUFARR; i++) {
|
||||
if (i % 10 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
printf("%03d ", bufnum2[i]);
|
||||
}
|
||||
printf("\n");
|
||||
pause();
|
||||
|
||||
printf("%s\n", "Printing Hundred to Zero (2)");
|
||||
for (i = 0; i < BUFARR; i++) {
|
||||
if (i % 10 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
printf("%03d ", bufnum3[i]);
|
||||
}
|
||||
printf("\n");
|
||||
pause();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool hundred2zero() {
|
||||
for (i = 1; i <= 100; i++) {
|
||||
sprintf("%d03", i);
|
||||
for (i = 0; i < BUFARR; i++) {
|
||||
bufnum1[i] = i + 1;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool zero2hundred() {
|
||||
j = 100;
|
||||
bool zero2hundred1() {
|
||||
j = BUFARR + 1;
|
||||
|
||||
while (j > 0) {
|
||||
sprintf("%d03", j);
|
||||
bufnum2[BUFARR - j] = --j;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool zero2hundred2() {
|
||||
k = BUFARR + 1;
|
||||
|
||||
zerohundred_loop:
|
||||
|
||||
bufnum3[BUFARR - k] = --k;
|
||||
|
||||
if (k >= 0) {
|
||||
goto zerohundred_loop;
|
||||
} else {
|
||||
goto zerohundred_done;
|
||||
}
|
||||
|
||||
zerohundred_done:
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void pause() {
|
||||
printf("Press any key to continue. . .");
|
||||
printf("\n%s\n", "Press any key to continue. . .");
|
||||
getch();
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* Program: COM 390 - Project 2
|
||||
* Author: Amrit Panesar <apanesar-77260@student.coleman.edu
|
||||
* Date: 2015-08-11
|
||||
* Purpose: Count from 100 to 0 and 0 to 100 two different ways.
|
||||
* Purpose: Count from 0 to 100 and 100 to 0 two different ways.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -15,6 +15,7 @@ typedef int bool;
|
||||
#define FALSE 0
|
||||
|
||||
bool zero2hundred();
|
||||
bool hundred2zero();
|
||||
bool hundred2zero1();
|
||||
bool hundred2zero2();
|
||||
|
||||
void pause();
|
||||
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
;By Amrit Panesar <apanesar-77260@student.coleman.edu>
|
||||
;References code from Steve Hanna of vividmachines.com
|
||||
;Launches calc.exe
|
||||
|
||||
[Section .text]
|
||||
|
||||
global _start
|
||||
|
||||
_start:
|
||||
|
||||
jmp short GetCommand
|
||||
|
||||
CommandReturn:
|
||||
pop ebx ;ebx now holds the handle to the string
|
||||
xor eax,eax
|
||||
push eax
|
||||
xor eax,eax ;for some reason the registers can be very volatile, did this just in case
|
||||
mov [ebx + 89],al ;insert the NULL character
|
||||
push ebx
|
||||
mov ebx,0x77e6fd35
|
||||
call ebx ;call WinExec(path,showcode)
|
||||
|
||||
xor eax,eax ;zero the register again, clears winexec retval
|
||||
push eax
|
||||
mov ebx, 0x77e798fd
|
||||
call ebx ;call ExitProcess(0);
|
||||
|
||||
|
||||
GetCommand:
|
||||
;the N at the end of the db will be replaced with a null character
|
||||
call CommandReturn
|
||||
db "cmd.exe /c calc.exe"
|
||||
Reference in new issue
Block a user