Run DEBUG and enter the following program (without comments) in, starting at address 0100. Then, put a small positive word-length value, like 5, at data offset 0140 and another small positive word-length value, like 3, at data offset 0142. Execute the program until a breakpoint at the last MOV is reached. The value in memory at offset 0144 is the result. Do NOT execute without setting BOTH memory locations first.
MOV AX,0001 ; Put a 1 in AX
MOV [0144],AX ; Copy what is in AX to memory 0144
MOV DX,[0142] ; Get value at 0142 into DX
CMP DX,+00 ; See if DX is zero
JZ 0122 ; Yes, jump to last MOV instruction
MOV AX,0000 ; Put a 0 in AX
MOV CX,[0140] ; Get value at 0140 into CX
ADD AX,[0144] ; Add value at 0144 to AX
LOOP 0116 ; Decrement CX, if CX is not zero,
; jump back to the ADD
MOV [0144],AX ; Copy what is in AX to memory 0144
DEC DX ; Decrement DX
JMP 010A ; Jump back to CMP instruction
MOV AX,4C00 ; Terminate program and exit
INT 21 ; to DOS
Your task is to figure out what this program does. Look at the result (in 0144) and see how it relates to the data values used (5 and 3). This program performs a simple mathematical operation on the two data values. Try putting a different positive value in 0140 and executing again up to the exit (leave 0140 unchanged). What result do you get this time? Try other small values for 0140, one- or two-digit numbers. Also, try other small values for 0142, one-digit numbers. Note: you must be sure to use positive word-length numbers expressed in hexadecimal.
Hand in several executions of the program captured with different data values - cut from the DOS window and paste into NotePad or a wordprocessor. Be sure to show the Enter actions that change 0140 and 0142 and the Dump that displays 0144 in the parts you capture from the DOS window. Attach an explanation as to what the program does. Also, state why the numbers (in 0140 and 0142) need to be small. Finally, if zero is put into 0140, the program will produce the correct answer, but does so in a very unexpected way; state what is unusual about how this result is produced.
Part BAn assembly language program has been assembled and linked with MASM. The executable program is now in a file named PARTB.EXE in the JLWOLFE\COSC300 folder on the I: drive. Load this program with DEBUG and take a look at the instructions. You should see something like the following (without the comments).
17BA:0000 B8BD17 MOV AX,17BD ; Set up DS to access
17BA:0003 8ED8 MOV DS,AX ; the data area
17BA:0005 B204 MOV DL,04 ; Set loop counter at 4
17BA:0007 BE0400 MOV SI,0004 ; Get offset first data
; string into SI
17BA:000A 8A04 MOV AL,[SI] ; Get a data byte
17BA:000C B400 MOV AH,00 ; Put zero in AH
17BA:000E 83E830 SUB AX,+30 ; Subtract 30h
17BA:0011 03060800 ADD AX,[0008] ; Add second data value
17BA:0015 FECA DEC DL ; Decrement loop count
17BA:0017 80FA00 CMP DL,00 ; See if it is zero
17BA:001A 740F JZ 002B ; Yes, do final actions
17BA:001C B90900 MOV CX,0009 ; Set loop counter to 9
17BA:001F 8BD8 MOV BX,AX ; Copy registers
17BA:0021 03C3 ADD AX,BX ; Add value in BX to AX
17BA:0023 E2FC LOOP 0021 ; Decrement CX, jump to
; 0021 if CX not zero
17BA:0025 A30800 MOV [0008],AX ; Copy AX to second data
17BA:0028 46 INC SI ; Adjust byte pointer
17BA:0029 EBDF JMP 000A ; Do it all again
17BA:002B A30800 MOV [0008],AX ; Copy AX to second data
17BA:002E B8004C MOV AX,4C00 ; End the program and
17BA:0031 CD21 INT 21 ; exit to DOS
Your task is to figure out what this program does. Begin by executing the first two instructions; this will cause the DS register to be set properly so that when you give the Enter and Dump commands and refer to the data area you will be looking at the right place. Next, use the Enter command to put a 4-character digit string into memory beginning at 0004. Here are some sample 4-digit strings, "1234" or "0006" or "9000" Also, use Enter to put a word-length zero at offset 0008. Then, execute down to the last MOV instruction (I recommend setting a breakpoint there) and examine 0008 to see the result the program has produced.
Hand in the following by capturing the information in the DOS window and pasting it into a file that can be printed: An execution up to the MOV at the exit (do NOT use T for this); a dump of the data area showing all values used and generated by the program; use of Enter to change the value 0004 and put zero in 0008; then, do a re-execution and dump of the data area. Also, hand in a statement answering: 1) What does the program do overall? 2) What part of this task is performed by the inner loop (offset 0021-23)? 3) What part is done by the outer loop (offset 000A-29)? These statements must be in terms of the problem being solved, NOT in terms of register and memory actions.