summaryrefslogtreecommitdiff
path: root/2522/CH10
diff options
context:
space:
mode:
Diffstat (limited to '2522/CH10')
-rwxr-xr-x2522/CH10/EX10.1/exm10_1.sce15
-rwxr-xr-x2522/CH10/EX10.1/exm10_1_output.jpgbin0 -> 19356 bytes
-rwxr-xr-x2522/CH10/EX10.2/exm10_2.sce36
-rwxr-xr-x2522/CH10/EX10.2/exm10_2_output.jpgbin0 -> 28224 bytes
-rwxr-xr-x2522/CH10/EX10.3/exm10_3.sce16
-rwxr-xr-x2522/CH10/EX10.3/exm10_3_output.jpgbin0 -> 29272 bytes
-rwxr-xr-x2522/CH10/EX10.4/exm10_4.sce48
-rwxr-xr-x2522/CH10/EX10.4/exm10_4_output.jpgbin0 -> 31874 bytes
-rwxr-xr-x2522/CH10/EX10.5/exm10_5.sce43
-rwxr-xr-x2522/CH10/EX10.5/exm10_5_output.jpgbin0 -> 27668 bytes
-rwxr-xr-x2522/CH10/EX10.6/exm10_6.sce15
-rwxr-xr-x2522/CH10/EX10.6/exm10_6_output.jpgbin0 -> 27067 bytes
-rwxr-xr-x2522/CH10/EX10.7/exm10_7.sce17
-rwxr-xr-x2522/CH10/EX10.7/exm10_7_output.jpgbin0 -> 22915 bytes
-rwxr-xr-x2522/CH10/EX10.8/exm10_8.sce6
-rwxr-xr-x2522/CH10/EX10.8/exm10_8_output.jpgbin0 -> 21403 bytes
16 files changed, 196 insertions, 0 deletions
diff --git a/2522/CH10/EX10.1/exm10_1.sce b/2522/CH10/EX10.1/exm10_1.sce
new file mode 100755
index 000000000..03436e088
--- /dev/null
+++ b/2522/CH10/EX10.1/exm10_1.sce
@@ -0,0 +1,15 @@
+// page no 310
+// example 10.1
+// BCD TO BINARY
+// BCD into its binary equivalent.
+// given BCD no is 72
+clc;
+a=72;
+ x=modulo(a,10); // seperating the units digit
+ printf('Unpacked BCD1 ')
+ disp(dec2bin(x,8));
+a=a/10; // seperating the tens place digit
+a=floor(a);
+printf('\n \n Unpacked BCD2');
+disp(dec2bin(a,8));
+printf('\n \n Multiply BCD2 by 10 and add BCD1');
diff --git a/2522/CH10/EX10.1/exm10_1_output.jpg b/2522/CH10/EX10.1/exm10_1_output.jpg
new file mode 100755
index 000000000..fe1455a12
--- /dev/null
+++ b/2522/CH10/EX10.1/exm10_1_output.jpg
Binary files differ
diff --git a/2522/CH10/EX10.2/exm10_2.sce b/2522/CH10/EX10.2/exm10_2.sce
new file mode 100755
index 000000000..8936f99e5
--- /dev/null
+++ b/2522/CH10/EX10.2/exm10_2.sce
@@ -0,0 +1,36 @@
+// page no 321
+// example no 10.2
+// ADDITION OF PACKED BCD NUMBERS
+clc;
+a=77;
+b=48;
+x=modulo(a,10);
+y=modulo(b,10);
+z=x+y;
+if z>9 then
+ f=z+6;
+
+ printf('After addition BCD1 is: ')
+ disp(dec2bin(f));
+ printf('MSB of this sequence is the carry generated after addition. \n \n')
+else
+ printf('After addition BCD1 is: ')
+ disp(z);
+end
+x=a/10;
+x=floor(x);
+y=b/10;
+y=floor(y);
+z=x+y;
+if z>9 then
+ f=z+6;
+ f=f+1; // this 1 is the carry of BCD1.
+ printf('After addition BCD2 is: ')
+ disp(dec2bin(f));
+ printf('MSB of this sequence is the carry generated after addition.')
+else
+ printf('After addition BCD1 is: ')
+ disp(z);
+end
+printf('\n \n BCD1 : 0101 \n \n');
+printf('BCD2: 0010')
diff --git a/2522/CH10/EX10.2/exm10_2_output.jpg b/2522/CH10/EX10.2/exm10_2_output.jpg
new file mode 100755
index 000000000..5302b5a43
--- /dev/null
+++ b/2522/CH10/EX10.2/exm10_2_output.jpg
Binary files differ
diff --git a/2522/CH10/EX10.3/exm10_3.sce b/2522/CH10/EX10.3/exm10_3.sce
new file mode 100755
index 000000000..62b21380b
--- /dev/null
+++ b/2522/CH10/EX10.3/exm10_3.sce
@@ -0,0 +1,16 @@
+// page no 325
+// example no 10.3
+// EXCHANGE OF DATA
+clc;
+printf('2050H--> 3FH \n \n');
+printf('2051H--> 42H \n \n');
+printf('DE--> 856FH \n');
+printf('D--> 85H E--> 6FH \n \n');
+printf('LHLD 2050H \n'); // loads the HL register pair with data on 2050H & 2051H.
+printf('H--> 42H L--> 3FH \n \n');
+printf('XCHG \n'); // exchange the data of HL register pair with DE register pair.
+printf('D<-->H E<-->L \n');
+printf('D--> 42H E--> 3FH \n H--> 85H L--> 6FH \n \n');
+printf('SHLD 2050H \n'); // stores the 16bit dat in HL register pair on memory location 2051H & 2050H.
+printf('2050H--> 6FH \n');
+printf('2051H--> 85H');
diff --git a/2522/CH10/EX10.3/exm10_3_output.jpg b/2522/CH10/EX10.3/exm10_3_output.jpg
new file mode 100755
index 000000000..84e63695a
--- /dev/null
+++ b/2522/CH10/EX10.3/exm10_3_output.jpg
Binary files differ
diff --git a/2522/CH10/EX10.4/exm10_4.sce b/2522/CH10/EX10.4/exm10_4.sce
new file mode 100755
index 000000000..1e69494c9
--- /dev/null
+++ b/2522/CH10/EX10.4/exm10_4.sce
@@ -0,0 +1,48 @@
+// page no 326
+// examle no 10.4
+// ADDITION OF TWO 16 BIT NUMBERS
+clc;
+printf('B--> 27H C--> 93H \n');
+printf('D--> 31H E--> 82H \n \n');
+b=hex2dec(['27']);
+c=hex2dec(['93']);
+d=hex2dec(['31']);
+e=hex2dec(['82']);
+printf('MOV A,C \n \n');
+a=c;
+printf('ADD E \n');
+a=a+e;
+Z=a-256;
+X=dec2hex(Z);
+printf('Sum =')
+disp(X);
+if a>255 then
+ printf('CY=1 \n \n');
+ CY=1;
+else
+ printf('CY=0 \n');
+ CY=0;
+end
+printf('MOV L,A \n');
+printf('L-->');
+disp(X);
+printf('\n \n MOV A,B \n \n');
+a=b;
+printf('ADC D \n');
+a=a+d+CY; // CY is added because of the previous carry as per the instructions ADC (add with carry)
+T=dec2hex(a);
+printf('Sum =')
+disp(T);
+if a>255 then
+ printf('CY=1 \n \n')
+else
+ printf('CY=0 \n \n')
+end
+printf('MOV H,A \n');
+printf('H-->');
+disp(T);
+printf('\n \n SHLD 2050H \n'); // stores the contents of HL register pair on memory locations 2051H & 2050H.
+printf('2050H--> ');
+disp(X);
+printf('2051H--> ');
+disp(T);
diff --git a/2522/CH10/EX10.4/exm10_4_output.jpg b/2522/CH10/EX10.4/exm10_4_output.jpg
new file mode 100755
index 000000000..c2201e8e9
--- /dev/null
+++ b/2522/CH10/EX10.4/exm10_4_output.jpg
Binary files differ
diff --git a/2522/CH10/EX10.5/exm10_5.sce b/2522/CH10/EX10.5/exm10_5.sce
new file mode 100755
index 000000000..6270eaf3a
--- /dev/null
+++ b/2522/CH10/EX10.5/exm10_5.sce
@@ -0,0 +1,43 @@
+// page no 326
+// examle no 10.5
+// SUBTRACTION OF TWO 16 BIT NUMBERS
+clc;
+printf('B--> 85H C--> 38H \n');
+printf('D--> 62H E--> A5H \n \n');
+b=hex2dec(['85']);
+c=hex2dec(['38']);
+d=hex2dec(['62']);
+e=hex2dec(['A5']);
+printf('MOV A,C \n \n');
+a=c;
+printf('SUB E \n');
+a=a-e;
+Z=a+256;
+X=dec2hex(Z);
+printf('Difference =')
+disp(X);
+if a<0 then
+ printf('Borrow=1 \n \n');
+ B=1;
+else
+ printf('Borrow=0 \n')
+ B=0;
+end
+printf('MOV C,A \n');
+printf('C-->');
+disp(X);
+printf('\n \n MOV A,B \n \n');
+a=b;
+printf('SBB D \n');
+a=a-d-B; // 1 is subtracted because of the previous borrow as per the instructions SBB (subtract with borrow)
+T=dec2hex(a);
+printf('Difference =')
+disp(T);
+if a<0 then
+ printf('Borrow=1 \n \n')
+else
+ printf('Borrow=0 \n \n')
+end
+printf('MOV B,A \n');
+printf('B-->');
+disp(T);
diff --git a/2522/CH10/EX10.5/exm10_5_output.jpg b/2522/CH10/EX10.5/exm10_5_output.jpg
new file mode 100755
index 000000000..577c8a207
--- /dev/null
+++ b/2522/CH10/EX10.5/exm10_5_output.jpg
Binary files differ
diff --git a/2522/CH10/EX10.6/exm10_6.sce b/2522/CH10/EX10.6/exm10_6.sce
new file mode 100755
index 000000000..f6a6f1539
--- /dev/null
+++ b/2522/CH10/EX10.6/exm10_6.sce
@@ -0,0 +1,15 @@
+// page no 327
+// example no 10.6
+// DISPLAY CONTENTS OF STACK
+clc;
+printf('LXI H,0000H \n'); // clears the HL register pair
+printf('H--> 00H L--> 00H \n \n');
+printf('DAD SP \n'); // place the stack pointer content in HL
+printf('H--> higher bytes of stack pointer register \n');
+printf('L--> lower bytes of stack pointer register \n \n');
+printf('MOV A,H \n'); // copies the contents of H in A.
+printf('H--> A \n \n');
+printf('OUT PORT1 \n \n');
+printf('MOV A,L \n'); // copies the contents of L in A.
+printf('L--> A \n \n');
+printf('OUT PORT2');
diff --git a/2522/CH10/EX10.6/exm10_6_output.jpg b/2522/CH10/EX10.6/exm10_6_output.jpg
new file mode 100755
index 000000000..646aa755e
--- /dev/null
+++ b/2522/CH10/EX10.6/exm10_6_output.jpg
Binary files differ
diff --git a/2522/CH10/EX10.7/exm10_7.sce b/2522/CH10/EX10.7/exm10_7.sce
new file mode 100755
index 000000000..9555335fb
--- /dev/null
+++ b/2522/CH10/EX10.7/exm10_7.sce
@@ -0,0 +1,17 @@
+// page no 327
+// example no 10.7
+// SUBROUTINE TO SET THE ZERO FLAG
+clc;
+printf('CHECK: PUSH H \n \n'); // sends the contents of H to the location pointed by the stack pointer.
+printf(' MVI L,FFH \n');
+l=hex2dec(['FF']);
+l=dec2bin(l,8);
+printf(' L--> '); // set all bits in L to logic 1.
+disp(l);
+printf('\n \n PUSH PSW \n \n'); // save flags on top of the stack
+printf(' XTHL \n \n'); // set all bits in the top stack location.
+printf(' POP PSW \n \n'); // now the zero flag is set.
+printf(' JZ NOEROR \n \n');
+printf(' JMP ERROR \n \n');
+printf('NOEROR: POP H \n \n'); // retrives the data from the stack into H if zero flag is set
+printf(' RET');
diff --git a/2522/CH10/EX10.7/exm10_7_output.jpg b/2522/CH10/EX10.7/exm10_7_output.jpg
new file mode 100755
index 000000000..4a9067de0
--- /dev/null
+++ b/2522/CH10/EX10.7/exm10_7_output.jpg
Binary files differ
diff --git a/2522/CH10/EX10.8/exm10_8.sce b/2522/CH10/EX10.8/exm10_8.sce
new file mode 100755
index 000000000..87d5be571
--- /dev/null
+++ b/2522/CH10/EX10.8/exm10_8.sce
@@ -0,0 +1,6 @@
+// page no 328
+// example no 10.8
+// TRANSFER A PROGRAM TO AN ADDRESS IN HL REGISTER
+clc;
+printf('\n \nThe program can be transfered using Jump instruction. \n \n');
+printf('PCHL a 1 byte instruction can also be used in place of Jump instruction \n \n');
diff --git a/2522/CH10/EX10.8/exm10_8_output.jpg b/2522/CH10/EX10.8/exm10_8_output.jpg
new file mode 100755
index 000000000..3b237cbf5
--- /dev/null
+++ b/2522/CH10/EX10.8/exm10_8_output.jpg
Binary files differ