Assembly programming
assembly programs are generally written as pure text files using any text editor (Notepad etc.) as saved as. ASM files the steps are as follows.
1.CODES the program and save as .asm files, using any suitable text editor. dont use MS-Word or any word processing software.
2.ASSEMBLE program with the command Tasm <filenamw.ASM>. An object file <filename.obj> is generated.
3.If no errors are found, LINK the object file: TLINK <filename> to generate executable program/file <filename.e
REQUIREMENTS
1. Turbo Assemble (TASM.EXE)
2. LINKER (TLINK.EXE)
3.Editor
a. Notepad
b. C++ editor saved as a pure text file with asm extension.
Generally source file (.asm) is made up of segments containing INSTURCTION/MNEMOMICS and or DIRECTIVES. Comments must be proceded by a semi-colon (;) for each line.
Generally instructions are in the form of mnemomics such as:
*MOV
*ADD
*SUB
*RET
*INT
*XOR
*OR
*NOT
*MUL
*DIV
etc.
Arithmetic Instructions
* ADD
*MUL
*DIV
*SUB
Move Instructions
*MOV - Interrups
Logical Instructions
*OR
*AND
*NOT
*XOR
Other Instructions
*PUSH
*POP
*RET
*ROL
*ROR
Jump Instructions
*JMP-jump
*JE-jump if equal
*JNE-jump if not equal
*JZ-jump if zero
*JNZ-jump if not zero
*JAE-jump above/Equal
Sample program
PAGE SR, 132
TITLE DISPLAY
SSEG SEGMENT STRACK
DB 32 DUP ("STRACK....")
SSEG ENDS
DSEG SEGMENT
MESSAGE DB "HELLO, HOW ARE YOU?", OOH.OAH
L_MESS EQU $-MESSAGE
CSEG SEGMENT 'CODE'
ASSUME OS:CSEG:SS:SSEG,DS:DSEG
MAIN
PROC FAR
PUSH DS
PUSH O
MOV DX,DSEG
MOV DX,AX
MOV BX, 0001H
LEA DX,MESSAGE
MOV CX,L-MESS
MOV AH,40H
INT 21H
MAIN ENDP
CSEG ENDS
END MAIN
February 19, 2015
February 8, 2015
CONTRUCTOR or ABSTRACT CLASS for WEIGHT
Wieght Constractor with Paramaters
CONSTRACTOR:
public class Weight1 {
double zkg;
double yg;
double akg;
double sg;
Weight1(double z, double y, double a, double s){
zkg=z;
yg=y;
akg=a;
sg=s;
}
MAIN CLASS:
import java.util.Scanner;
public class Weight {
public static void main (String[]args){
Weight1 r1=new Weight1(0.453592, 453.59237, 0.02834952, 28.34952);
Scanner wieghtconverter = new Scanner(System.in);
System.out.println("Coverter \n Select to convert? \n 1 Pound \n 2 Ounce");
double m1=wieghtconverter.nextInt();
if(m1==1){
System.out.println("Enter number in pounds: ");
double pounds=wieghtconverter.nextInt();
double poundskg=pounds*r1.zkg;
double poundsg=pounds*r1.yg;
System.out.println("Kilograms: "+poundskg);
System.out.println("grams: "+poundsg);
}
else{
System.out.println("Enter number in ounce.");
double ounce=wieghtconverter.nextInt();
double ouncekg=ounce*r1.akg;
double ounceg=ounce*r1.sg;
System.out.println("Kilograms: "+ouncekg);
System.out.println("grams: "+ounceg);
}
}
}
CONSTRACTOR:
public class Weight1 {
double zkg;
double yg;
double akg;
double sg;
Weight1(double z, double y, double a, double s){
zkg=z;
yg=y;
akg=a;
sg=s;
}
MAIN CLASS:
import java.util.Scanner;
public class Weight {
public static void main (String[]args){
Weight1 r1=new Weight1(0.453592, 453.59237, 0.02834952, 28.34952);
Scanner wieghtconverter = new Scanner(System.in);
System.out.println("Coverter \n Select to convert? \n 1 Pound \n 2 Ounce");
double m1=wieghtconverter.nextInt();
if(m1==1){
System.out.println("Enter number in pounds: ");
double pounds=wieghtconverter.nextInt();
double poundskg=pounds*r1.zkg;
double poundsg=pounds*r1.yg;
System.out.println("Kilograms: "+poundskg);
System.out.println("grams: "+poundsg);
}
else{
System.out.println("Enter number in ounce.");
double ounce=wieghtconverter.nextInt();
double ouncekg=ounce*r1.akg;
double ounceg=ounce*r1.sg;
System.out.println("Kilograms: "+ouncekg);
System.out.println("grams: "+ounceg);
}
}
}
CONTRUCTOR or ABSTRACT CLASS for DISTANCE
Distance Constractor without Paramaters
CONSTRACTOR:
public class Distance {
double zmk;
Distance(){
zmk=0.62137;
}
MAIN CLASS:
import java.util.Scanner;
public class Distance1 {
public static void main (String[]args){
Distance p1=new Distance();
Scanner distanceconverter = new Scanner(System.in);
System.out.println("Enter number in kilometer.");
double dis=distanceconverter.nextInt();
double miles=dis*p1.zmk;
System.out.println("Miles: "+miles);
}
}
CONSTRACTOR:
public class Distance {
double zmk;
Distance(){
zmk=0.62137;
}
MAIN CLASS:
import java.util.Scanner;
public class Distance1 {
public static void main (String[]args){
Distance p1=new Distance();
Scanner distanceconverter = new Scanner(System.in);
System.out.println("Enter number in kilometer.");
double dis=distanceconverter.nextInt();
double miles=dis*p1.zmk;
System.out.println("Miles: "+miles);
}
}
Subscribe to:
Posts (Atom)