Practice Final Exam for CS-220 1. We wish to write a DISPLAY_IF macro that will display a character on the screen of a PC if a certain condition on two values is satisfied. The first value is specified in the macro's first argument, the condition in the second argument, the second value in the third argument, and the character to be displayed in the fourth argument. For example, the invocation: DISPLAY_IF AX, G, BX, 'Z' should display a 'Z' at the current cursor location on the screen if the contents of AX are greater (G) than the contents of BX. The invocation: DISPLAY_IF DL, E, 0, 30h should display a zero (30h = ASCII code for a zero) if DL contains a 0 (i.e. if DL is Equal to 0). (A) Complete the macro definition: DISPLAY_IF MACRO OP1, OP2, CONDITION, ASC ;Your code goes here ENDM (B) Expand the following invocation of the macro: DISPLAY_IF SI, X, LE, AL 2. The two-module ADDX program whose listings are given on the "Sample Programs" Web page is assembled and linked into a single executable. Prior to execution of the push a instruction, the registers are as shown below: AX=2D88 BX=0000 CX=0052 DX=0000 SP=0010 BP=0000 SI=0000 DI=0000 DS=2D88 ES=2D77 SS=2D87 CS=2D89 IP=0005 NV UP EI PL NZ NA PO NC (A) What is the physical address (5-digit hex number) of the variable b? (B) What is the physical address of the push ax instruction? (C) The following tables represent the stack and the data segments immediately before the instruction pop bp (in the ADDXSUB module) is executed. Fill in both tables with the values that would be stored at that moment. (In the stack table, each entry is a word, while in the data table, each entry is a byte.) STACK SEGMENT DATA SEGMENT offset contents offset contents ---------------- --------------- 0 0 ---------------- --------------- 2 1 ---------------- --------------- 4 2 ---------------- --------------- 6 3 ---------------- --------------- 8 4 ---------------- --------------- A 5 ---------------- --------------- C ---------------- E ---------------- 3. The following assembly language program has been assembled and loaded into the simple computer we discussed during the last week of class. Machine Language Assembly Language ------------------------------------------- Address Contents ------------------------------------------- 0A ORG 10 ------ -------- X DW 20 ------ -------- Y DW 15 ------ -------- ORG 0 ------ -------- LDA X ------ -------- MBA ------ -------- SUB ------ -------- BBB: JN AAA ------ -------- SUB ------ -------- JMP BBB ------ -------- AAA: HLT ------ -------- END Fill the blanks in the Address and Contents columns with the values they would have after the program is translated to machine language. The addresses should be expressed as two-digit hex numbers, and the contents as 3-digit hex numbers. (Each DW declaration allocates one "word" of memory on this machine, which, you will recall, is a single 12-bit long number. All addresses are to be expressed as "word" addresses. Each instruction is also one "word" long.) What will be the value stored in the ACC register when the program stops execution? IN ORDER TO PREPARE FOR THE REST OF THE REAL EXAM, YOU SHOULD CAREFULLY REVIEW THE LAST SET OF NOTES FROM THE WEB PAGES--"Week 15: Microprogramed vs. Hardwired Control Units--How Computers Really Work." MAKE SURE YOU UNDERSTAND HOW THE VARIOUS TABLES WERE OBTAINED AND HOW THE CIRCUITS WORK. OF PARTICULAR IMPORTANCE IS THE ORGANIZATION OF THE HARDWIRED INSTRUCTION DECODER AND CONTROL MATRIX.