Skip to content

Instantly share code, notes, and snippets.

@mr-fool
mr-fool / Division.asm
Created June 19, 2014 16:59
Division x86 asm tasm syntax
;program that divide 6 by 3
.model small
.stack 200h
.code
Start:
mov ax,6 ;preparing the dividend
mov dx,0 ;zero extension
mov cx,3 ;preparing the divisor
div cx ;divides AX by CX, with quotient being stored in AX, and remainder in DX
mov ah, 4ch ;preparing exit call
@mr-fool
mr-fool / ascii.c
Created June 19, 2014 16:51
C printing ascii table without print buffer
#include <stdio.h>
int main(){
int i=0; //
while (i<=127){ /*227 = total number of asii value*/
if (i%8==0 ) {
printf("\n");
}
if ((i<=32) || (i==127) ){ /*Since 1-32 and 127 is non-printable*/
printf("%c",'.'); /*replace non-printable character with .*/
@mr-fool
mr-fool / ascii.c
Created June 19, 2014 16:50
A C program that print ascii table using print buff
#include <stdio.h>
#define LOWER_BOUND 33 //since 1-33 is considered nonprintable prof said consider space and tab as nonprintable
#define UPPER_BOUND 127
int main() {
char row[9]; //8 characters a row
int c, d; //d is used to control the bounds of the row buffer
for (d = 0, c = 0; c <= UPPER_BOUND; c++) { // c is the used as the ascii
if (c < LOWER_BOUND || c >= UPPER_BOUND) //1-33 or 127 print .
@mr-fool
mr-fool / mymath.asm
Created June 19, 2014 16:36
a simple math x86 assembly program
; The formula that I am trying to implement is (a+b-c)*d/e
; Caution: will not work with negative and floating point numbers
BITS 32 ;declare it as a 32 bit code
GLOBAL _start
SECTION .text
_start:
mov ebx,4 ;variable a
mov eax,4 ;variable b
mov ecx,5 ;variable c
mov edx,2 ;variable d
@mr-fool
mr-fool / interest.c
Last active August 29, 2015 14:02
Calculating compound interest
/*Calculating compound interest*/
#include <stdio.h>
#include <math.h>
int main (void) {
double amount;
double principal;
double rate;
int year;
int i;
@mr-fool
mr-fool / Makefile
Created June 16, 2014 05:11
A program that normalize fractions and simplify it (optimized for large fraction)
allFiles: fraction.c
gcc -Wall fraction.c -o fraction.out -lm
clean:
rm *.o fraction.out
@mr-fool
mr-fool / Makefile
Last active August 29, 2015 14:02
A program that normalize fractions and simplify it
allFiles: fraction.c
gcc -Wall fraction.c -o fraction.out -lm
clean:
rm *.o fraction.out
@mr-fool
mr-fool / bin2dec
Last active August 29, 2015 14:01
Number System Conversion in C
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/*Declaring Constant */
int const BASE = 2;
int const BASE_TEN = 10;
/* converting from decimal require the following information input number,quotient, remainder*/
int inputNumber;
int calculationRemainder;
@mr-fool
mr-fool / Makefile
Last active August 29, 2015 14:01
A C program that draws hollow circle, hollow rectangle and hollow right triangle
allFiles: draw.c
gcc -Wall draw.c -o draw.out -lm
clean:
rm *.o draw.out
@mr-fool
mr-fool / Circle
Last active August 29, 2015 14:00
Calculating the diameter, circumference and area of a circle
/*Calculate the diameter,circumference and area of a circle
Using C pi*/
/*Including Library*/
#include <math.h>
#include <stdio.h>
int main (void) {
/*Declaring the variable*/
int radius;