Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Printing number onto an output device is not as easy as it appears. The value st

ID: 3710798 • Letter: P

Question

Printing number onto an output device is not as easy as it appears. The value stored in register is in its binary format which is not printable. In order to print the number, we must convert it into its ASCII format.

Look up the ASCII table, we will find that ASCII values for 0 to 9 is 30h to 39h. Therefore, in order to print the decimal value of 2012, we will need to convert it into 32h, 30h, 31h, and 32h.

The purpose of this lab is to prepare you for the next project. In this lab, you are going to learn the pieces of machine instructions needed to construct the programs to print the value in Binary, Hexadecimal, and then Decimal formats.

Printing the number in Binary format is the easiest of the three. So, we are going to start with this one. We will need to use the following three new instructions:

RCL and CLC (See pages 248 & 614)

ADC (Page 612)

For this lab and project, we will only deal with a single byte value. The algorithm follows:

Shift the number 1 bit to the left and have the left most bit rotated into the carry bit. (Accomplished by RCL)

Add 30h

Repeat this process for each remaining bit.

I.                   In-Class Labs:

Use DEBUG to enter the following code starting at location 0100:

MOV BL, C6

MOV CX, 8

RCL BL,1

Loop [the offset of the previous instruction]

MOV AH, 4C

INT 21

Use Excel to construct the trace table with the following heading to trace the program and record the value of BL, CX, and CARRY FLAG in the following table:

ASM Lab/Project Unit #2: Table II.A)

IP

Machine Code

ASM CODE

BL

CX

Carry Flag

Before execution

0

0

NC

100

MOV BL, FF

Add CLC statement before the Loop statement and still have loop point to “RCL BL, 1”.

MOV BL, C6

MOV CX, 8

RCL BL, 1

CLC

LOOP [the offset of “RCL BL, 1”]

MOV AH, 4C

INT 21

Repeat step 2 in A) above but change the title of the table to “Table II.B)”.

Enter the following program, trace it and fill the table similar to the following:

Mov al,ff

Add al,10 ;This will set the carry flag on

Mov dl,30

ADC dl,10

Int 20

IP

Machine Code

Assembly

AL

DL

Carry Flag

mov al,ff

clc

add al,10

mov dl,30

adc dl,10

int 20

ASM Lab/Project Unit #2: Table II.A)

IP

Machine Code

ASM CODE

BL

CX

Carry Flag

Before execution

0

0

NC

100

MOV BL, FF

Explanation / Answer

Printing number onto an output device is not as easy as it appears. The value stored in register is in its binary format which is not printable. In order to print the number, we must convert it into its ASCII format.

Look up the ASCII table, we will find that ASCII values for 0 to 9 is 30h to 39h. Therefore, in order to print the decimal value of 2012, we will need to convert it into 32h, 30h, 31h, and 32h.

The purpose of this lab is to prepare you for the next project. In this lab, you are going to learn the pieces of machine instructions needed to construct the programs to print the value in Binary, Hexadecimal, and then Decimal formats.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote