Programs
-
Upload
giezel-madurar -
Category
Documents
-
view
3 -
download
0
description
Transcript of Programs
![Page 1: Programs](https://reader035.fdocuments.net/reader035/viewer/2022071806/55cf91a5550346f57b8f40ae/html5/thumbnails/1.jpg)
SAMPLE PROGRAMS
![Page 2: Programs](https://reader035.fdocuments.net/reader035/viewer/2022071806/55cf91a5550346f57b8f40ae/html5/thumbnails/2.jpg)
EXAMPLE 1
Code a program to decrement a 2-byte number at File 26:27h ordered as high:low byte, remembering that decf does not alter the Carry/Borrow flag.
![Page 3: Programs](https://reader035.fdocuments.net/reader035/viewer/2022071806/55cf91a5550346f57b8f40ae/html5/thumbnails/3.jpg)
SOLUTION TO EXAMPLE 1
The task list to implement this job is:
1. IF the least significant byte in File 27h is zero THEN decrement the most significant byte.
2. Always decrement the least significant byte.
![Page 4: Programs](https://reader035.fdocuments.net/reader035/viewer/2022071806/55cf91a5550346f57b8f40ae/html5/thumbnails/4.jpg)
EXAMPLE 2
Some early computers used a bi-quinary code to represent BCD digits. This is a 7-bit code with only two bits set to one for any combination:
![Page 5: Programs](https://reader035.fdocuments.net/reader035/viewer/2022071806/55cf91a5550346f57b8f40ae/html5/thumbnails/5.jpg)
EXAMPLE 2
Bi-quinary coded decimal is a numeral encoding scheme used in many abacuses and in some early computers, including the Colossus. The term bi-quinary indicates that the code comprises both a two-state (bi) and a five-state (quinary) component. The encoding resembles that used by many abaci, with four beads indicating either 0 through 4 or 5 through 9 and another bead indicating which of those ranges.
![Page 6: Programs](https://reader035.fdocuments.net/reader035/viewer/2022071806/55cf91a5550346f57b8f40ae/html5/thumbnails/6.jpg)
EXAMPLE 2
![Page 7: Programs](https://reader035.fdocuments.net/reader035/viewer/2022071806/55cf91a5550346f57b8f40ae/html5/thumbnails/7.jpg)
SOLUTION TO EXAMPLE 2
All we need to do here is to determine when there are more or less than two bits set to one. Based on this approach we have the tasklist:
1. Count the number of ones in the bi-quinary byte.
2. Zero W.
3. IF count is not two THEN make FFh to signal an error.
![Page 8: Programs](https://reader035.fdocuments.net/reader035/viewer/2022071806/55cf91a5550346f57b8f40ae/html5/thumbnails/8.jpg)
SOLUTION 3