UMBC CMSC 211

CSEE | 211 | Current | lectures | news | help


CMSC211 Final Exam Questions Master List

TRUE or FALSE

  1. (TRUE / FALSE) Other languages (such as C and C++) do not compile and link to machine language instructions.
  2. (TRUE / FALSE) Later model Intel processors (such as the Intel Pentium) are not backwards compatible with the 8086/8088.
  3. (TRUE / FALSE) Machine Language and Assembly Language refer to the same language on the IBM PC.
  4. (TRUE / FALSE) The Intel x86 CPU is known as a RISC processor.
  5. (TRUE / FALSE) IBM PC memory is not byte addressable.
  6. (TRUE / FALSE) A CPU register is a special type of high speed memory built into the CPU.
  7. (TRUE / FALSE) The BIOS is a program that is stored on a special non-volatile chip, which starts the IBM PC when powered is turned on.
  8. (TRUE / FALSE) The BIOS can run a IBM PC without a processor installed.
  9. (TRUE / FALSE) The CPU's registers are part of the IBM PCs RAM.
  10. (TRUE / FALSE) The CPU in an IBM PC works with a stream of 1s and 0s called bytes.
  11. (TRUE / FALSE) Hexadecimal numbers are base 15.
  12. (TRUE / FALSE) Binary digits can take on values between 0 and 2 inclusive.
  13. (TRUE / FALSE) The IBM PC uses the "sign magnitude" method of representing negative numbers.
  14. (TRUE / FALSE) The LSB (Least Significant Bit) is the leftmost bit.
  15. (TRUE / FALSE) The MSB (Most Significant Bit) is the leftmost bit.
  16. (TRUE / FALSE) "Endian" is a term used to describe where the LSB (or MSB) is located.
  17. (TRUE / FALSE) The size of a value that a CPU can perform operations on is not limited by the CPU's register size.
  18. (TRUE / FALSE) A Byte is 8 bits on the IBM PC.
  19. (TRUE / FALSE) A Word and 4 Bytes occupy the same amount of memory on the IBM PC.
  20. (TRUE / FALSE) 2s Compliment math is not used in the IBM PC because it slows the CPU's ability to perform calculations efficiently.
  21. (TRUE / FALSE) A 1s Compliment is the reversing of bits in a value (1 becomes 0, and 0 becomes 1), and then add 1 to the LSB.
  22. (TRUE / FALSE) Applying the 2s Complement operation on a value (for example x), will yield -x + 1.
  23. (TRUE / FALSE) Applying the 1s Complement operation on a value (for example x), will yield -x.
  24. (TRUE / FALSE) 2s Compliment math will never result in overflow because 2s math does not carry bit values.
  25. (TRUE / FALSE) When working with an 8 bit register, a carry into the 9th bit will be silently lost by the CPU.
  26. (TRUE / FALSE) Overflow is a term used to indicate a possible sign change.
  27. (TRUE / FALSE) The Zero flag is set to indicate a non zero value.
  28. (TRUE / FALSE) Since the IBM PC uses sign magnitude, -1 is always represented as "1000...000" - the leftmost bit is always set.
  29. (TRUE / FALSE) A value in a register that has its rightmost bit set will always cause the Sign bit to be set
  30. (TRUE / FALSE) An example of overflow is carrying into the 9th bit during an 8-bit operation.
  31. (TRUE / FALSE) When using signed values, the possible values for an 8-bit register are -128 to 127.
  32. (TRUE / FALSE) When using unsigned values, the possible values for a 16 bit-registers are 0 to 255.
  33. (TRUE / FALSE) Regardless of register size, the value -1 is always a stream of 1 bits.
  34. (TRUE / FALSE) The IBM PC uses the extended ASCII character set, which is a 16-bit value per character.
  35. (TRUE / FALSE) Assembly Language source programs (usually with the *.ASM extension), are text files.
  36. (TRUE / FALSE) Object Files (the *.OBJ extension), are compiled (or assembled) and linked programs.
  37. (TRUE / FALSE) EXE files are produced by the assembler, after an ASM file has been linked.
  38. (TRUE / FALSE) Object Files are not machine dependent.
  39. (TRUE / FALSE) An EXE must be created from only one Object File.
  40. (TRUE / FALSE) An ASM file will always have a .STACK and .CODE segment.
  41. (TRUE / FALSE) ASM files have distinguished words, such as MOV and INT, which are called operations or op codes.
  42. (TRUE / FALSE) Loosely speaking, ASM files have distinct areas, including Op Codes, Comments, and Labels.
  43. (TRUE / FALSE) ASM files must always have a function main( ).
  44. (TRUE / FALSE) An EXE written in Assembly Language will not have an entry point (which is called main in C\C++).
  45. (TRUE / FALSE) The .DATA segment holds global data for use in an ASM program.
  46. (TRUE / FALSE) Character strings are represented as some number of Bytes in the .DATA segment, with a NULL terminator.
  47. (TRUE / FALSE) The segment registers include SS, CS, DS, ES, DI, and SI on a 16 bit IBM PC.
  48. (TRUE / FALSE) The index registers are BX, BP, SI, and DI.
  49. (TRUE / FALSE) The general purpose registers include AX, BX, CX, DX, EX, and FX (EX and FX are also known as fastcall registers).
  50. (TRUE / FALSE) AX is also known as the auxiliary register.
  51. (TRUE / FALSE) BX is also known as the based index register.
  52. (TRUE / FALSE) CX is also known as the counter register.
  53. (TRUE / FALSE) DX is also known as the DOS argument register.
  54. (TRUE / FALSE) DI is also known as the duplicate index register.
  55. (TRUE / FALSE) SI is also known as the source index register.
  56. (TRUE / FALSE) BP is also known as the base pointer register.
  57. (TRUE / FALSE) SP is the Special Purpose register, is used to hold debug information, and should never be used in an ASM program.
  58. (TRUE / FALSE) IP is the Instruction Pointer, and is incremented by two (the size of a word) after each instruction is executed.
  59. (TRUE / FALSE) The FLAGS register is known as a bit masked value, where individual bits are significant, and not the value of the register.
  60. (TRUE / FALSE) Bits of the FLAGS register can be manipulated in an ASM program (that is, set or cleared by the programmer).
  61. (TRUE / FALSE) Interrupts (INT instructions) can be hardware or software implemented.
  62. (TRUE / FALSE) The INT instruction can be hardware or software generated.
  63. (TRUE / FALSE) There are no software interrupts on the IBM PC.
  64. (TRUE / FALSE) When an interrupt occurs, control is passed directly to the Operating System, which then looks for the interrupt handler.
  65. (TRUE / FALSE) All interrupts (INTs) are serviced by the interrupt controller.
  66. (TRUE / FALSE) There are separate instructions for signed and unsigned addition on the IBM PC.
  67. (TRUE / FALSE) There are separate instructions for signed and unsigned subtraction on the IBM PC.
  68. (TRUE / FALSE) There are separate instructions for signed and unsigned multiplication on the IBM PC.
  69. (TRUE / FALSE) There are separate instructions for signed and unsigned division on the IBM PC.
  70. (TRUE / FALSE) C/C++ statements x++ and x-- can be implemented in Assembly Language using INC and DEC.
  71. (TRUE / FALSE) Pseudocode ax = ax + 2 can be accomplished with INC AX, 2.
  72. (TRUE / FALSE) When two 8-bit values are multiplied in Assembly Language, the result can be up to 32 bits.
  73. (TRUE / FALSE) When two 16 bit values are multiplied in Assembly Language, the result can be up to 16 bits (with overflow).
  74. (TRUE / FALSE) To perform an operation in Assembly Language that requires two operands, both operands must be in registers.
  75. (TRUE / FALSE) Most two operand operations in Assembly language allow both operands to reside in memory.
  76. (TRUE / FALSE) Operands include memory locations, registers, and immediates (constants).
  77. (TRUE / FALSE) The MOV instruction can only be used to move data from memory to the CPU and from the CPU to memory.
  78. (TRUE / FALSE) When MOVing a value (for example MOV BX, AX), AX is reset to 0 after the MOV.
  79. (TRUE / FALSE) A CMP instruction performs a subtraction on the operands, sets the FLAGS bits, but does not save the result of the subtraction.
  80. (TRUE / FALSE) A CMP instruction only operates on signed values.
  81. (TRUE / FALSE) A CMP instruction only operates on unsigned values.
  82. (TRUE / FALSE) The CMP instruction has forms, one which operates on signed values, the other on unsigned.
  83. (TRUE / FALSE) The AND instruction is a logical AND ("&" in C\C++).
  84. (TRUE / FALSE) The OR instruction is a bitwise OR ("|" in C\C++).
  85. (TRUE / FALSE) The XOR instruction generates the 1s Compliment of the original value.
  86. (TRUE / FALSE) The NOT instruction generates the 2s Compliment of the original value.
  87. (TRUE / FALSE) The CALL instruction is a unconditional far jump.
  88. (TRUE / FALSE) An ASM program should exit exit to DOS (through INT 21h) or use the HALT instruction.
  89. (TRUE / FALSE) LOOP is an instruction based on the AX (or AL) register.
  90. (TRUE / FALSE) The FLAGS register cannot be pushed.
  91. (TRUE / FALSE) Any general purpose register can be PUSHed, including 8-bit and 16-bit values.
  92. (TRUE / FALSE) When PUSHing a value (for example PUSH DX), the value is moved to the stack and DX is reset to 0.
  93. (TRUE / FALSE) A PUSH increments the SS register and a POP decrements it.
  94. (TRUE / FALSE) A PUSH decrements SP by 2, and a POP increments it by 2.
  95. (TRUE / FALSE) The FLAGS register can be PUSHed for manipulation, but values cannot be POPped into the FLAGS register.
  96. (TRUE / FALSE) The REP instruction prefix is usually used with string manipulations.
  97. (TRUE / FALSE) The REP instruction can be used as "repeat while true" and "repeat while not true".
  98. (TRUE / FALSE) To return from a procedure, use the RET instruction.
  99. (TRUE / FALSE) An ASM program cannot turn off interrupts.
  100. (TRUE / FALSE) SAL and SAR are arithmetic shift instructions that preserve the sign of the original value.
  101. (TRUE / FALSE) SHL and SHR are logical bit shifts that set the overflow bit when a bit is carried out and pad with 1.
  102. (TRUE / FALSE) ROL and ROR rotate bits in a register, discarding the rotate out.
  103. (TRUE / FALSE) RCL and RCR rotate bits in a register, but rotates out to the carry bit. The previous carry bit is lost.
  104. (TRUE / FALSE) The shift and rotate instructions can perform more than 1-bit rotates or shifts.
  105. (TRUE / FALSE) Since the shift and rotate instructions can only perform 1-bit rotates or shifts, set up a loop on CX for multiple shifts or rotates.
  106. (TRUE / FALSE) The Intel x86 CPU has specialized instructions for working with strings.
  107. (TRUE / FALSE) String manipulation instructions include CMPS, LODS, MOVS, SCAS, and STOS.
  108. (TRUE / FALSE) The string manipulation instructions requires the strings be NULL terminated.
  109. (TRUE / FALSE) The string manipulation instructions assume DS for the source string, and ES for the destination string.
  110. (TRUE / FALSE) The string manipulation instructions do not allow segment (DS or ES) overrides.
  111. (TRUE / FALSE) The Coprocessor uses the system stack space.
  112. (TRUE / FALSE) The Coprocessor includes instructions to PUSH special values on the FPU stack, such as pi, log2(e), and log2(10).
  113. (TRUE / FALSE) The Coprocessor includes instructions to calculate special values, such as Y log2(X) and Y log2(X+1).
  114. (TRUE / FALSE) Coprocessor instruction mnemonics are too damn long.
  115. (TRUE / FALSE) Labels are translated to addresses at assembly time.
  116. (TRUE / FALSE) A short jump can be in the range -128 to 127 byte displacement.
  117. (TRUE / FALSE) The pseudo code "jump LABEL" is assembled to JMP N, where n is a signed displacement.
  118. (TRUE / FALSE) Conditional jumps have two flavors: signed and unsigned comparisons.
  119. (TRUE / FALSE) All high level conditionals (=, <, >, <=, and >=) have corresponding assembly level op codes.
  120. (TRUE / FALSE) JA and JB are unsigned conditional jumps.
  121. (TRUE / FALSE) JG and JL are unsigned conditional jumps.
  122. (TRUE / FALSE) Procedures or subprograms are invoked using CALL.
  123. (TRUE / FALSE) Procedures in ASM start with the PROC directive and end with the ENDP directive.
  124. (TRUE / FALSE) Main is a reserved name in ASM, and should not be used as a Procedure name.
  125. (TRUE / FALSE) When a Procedure is CALLed, all register values are PUSHed on the STACK for the procedure by the assembler.
  126. (TRUE / FALSE) The STACK starts in low memory and grows towards high memory.
  127. (TRUE / FALSE) When exiting a CALLed Procedure, it is the programmers responsibility to POP in reverse order of any PUSHes.
  128. (TRUE / FALSE) The RETurn address should be PUSHed by the programmer before CALLing a Procedure.
  129. (TRUE / FALSE) The RETurn address that is PUSHed is actually a jump displacement.
  130. (TRUE / FALSE) When using the STACK to pass arguments, Procedures should use SP +/- n.
  131. (TRUE / FALSE) When manipulating the STACK, save SP in BP (MOV BP, SP). Then it is safe to use and change SP.
  132. (TRUE / FALSE) The only way to adjust the STACK is to POP into an unused register.
  133. (TRUE / FALSE) The CPU differentiates between signed and unsigned numbers.
  134. (TRUE / FALSE) GetDec reads an ASCII string and converts it to a value.
  135. (TRUE / FALSE) GetDec is actually a Macro, included in PCMAC.INC.
  136. (TRUE / FALSE) If a value in a registeris AABBh, it is stored in memory as BB AA.
  137. (TRUE / FALSE) If a value in a register is 0011h, it is stored in memory as 00 11.
  138. (TRUE / FALSE) BX is also known as the base index register.
  139. (TRUE / FALSE) The statement MOV AX, [BX + SI + 3] is illegal.
  140. (TRUE / FALSE) The statement MOV AX, [DI + SI] is legal.
  141. (TRUE / FALSE) The statement MOV AX, [DX + DI] is legal.
  142. (TRUE / FALSE) The statement MOV AX, [BP - 2] is illegal.
  143. (TRUE / FALSE) Indexing into arrays in Assembly Language is different than in C/C++.
  144. (TRUE / FALSE) The statement MOV AX, array[5] will move the 5th word in array[] into AX starting from array[0] (array[] is a word array).
  145. (TRUE / FALSE) The statement MOV AX, array[9] will move the 8th word in array[] into AX starting from array[0] (array[] is a word array).
  146. (TRUE / FALSE) The statement MOV AX, array[3] will move a word into AX starting from array[0] + 3 Bytes (array[] is a word array).
  147. (TRUE / FALSE) A word array may also be accessed as individual bytes, in addition to accessing as words.
  148. (TRUE / FALSE) A word array may also be accessed as double words (DWORDS), in addition to accessing as words.
  149. (TRUE / FALSE) A library (such as util.lib) is a collection of object files (*.OBJ).
  150. (TRUE / FALSE) To access a Procedure in a library, declare the Procedure with EXTERN or EXTRN.
  151. (TRUE / FALSE) The assembler resolves EXTERN or EXTRN declarations.
  152. (TRUE / FALSE) The assembler substitutes macros in a program.
  153. (TRUE / FALSE) The Linker resolves EXTERN or EXTRN declarations.
  154. (TRUE / FALSE) The Linker substitutes macros in a program.
  155. (TRUE / FALSE) To open a file in Assembly Language, pass DOS a "$" terminated file name.
  156. (TRUE / FALSE) At the Assembly level, file handles are not available to the programmer.
  157. (TRUE / FALSE) An Assembly program cannot bypass DOS and use INT13h for file I/O.
  158. (TRUE / FALSE) An Assembly program cannot bypass DOS and use INT10h for text mode video I/O.
  159. (TRUE / FALSE) Anything done in a high level language (such as C\C++), can be done with Assembly.
  160. (TRUE / FALSE) Assembly cannot call routines from high level languages.

NUMBER CRUNCHING

(O is Overflow bit, Z is Zero bit)

1. Decimal

Hex

O  Z

Binary (8 bit)

  15

+ 58

     

               

 

2. Decimal

Hex

O  Z

Binary (8 bit)

  92

+ 58

     

               

 

3. Decimal

Hex

O  Z

Binary (8 bit)

 115

+ 92

     

               

 

4. Decimal

Hex

O  Z

Binary (8 bit)

   92

- +58

     

               

 

5. Decimal

Hex

O  Z

Binary (8 bit)

   58

- +92

     

               

 

6.  Decimal

Binary (8 bit)

      15

  AND 58

               

 

7.  Decimal

Binary (8 bit)

      92

   OR 58

               

 

8.  Decimal

Binary (8 bit)

     115

  XOR 92

               

 

9.  Decimal

Binary (8 bit)

 NOT -58

               

 

10. Decimal

Binary (8 bit)

 NEG -92

               

 

MULTIPLE CHOICE

(Indicate ALL that are correct)

The ROM BIOS:

  1. Tests and initializes devices
  2. Can be run without the CPU using the BASIC interpreter
  3. Usually resides in high memory (EMS and XMS areas)
  4. Provides the initial interrupt vector for the Operating System
  5. Starts the machine, then turns control over to the Operating System

The Interrupt Vector:

  1. Is a table of addresses for handlers (procedures)
  2. Can hold 2048 entries
  3. Does not have to loaded because it resides in a ROM
  4. Is deleted by the Operating System after the OS is loaded

8 bit values are in the range:

  1. unsigned: 0 to 255
  2. unsigned: 0 to 128
  3. signed: -128 to 255
  4. signed: -128 to 127

16 bit values are in the range:

  1. unsigned: 0 to 65535
  2. unsigned: 0 to 32767
  3. signed: -32768 to 32767
  4. signed: -32768 to 65535

MOV AH, 355h:

  1. Moves 355h into AH
  2. Moves 03h into AH and 55h into AL
  3. Moves 355h into AX
  4. Will cause a assembler error
  5. Will assemble, but cause a linker error

In an ASM program, the statement "END FOO":

  1. Indicates the end of Procedure Foo
  2. Indicates the entry point is Foo
  3. Is incorrect, "END" should always occur with "MAIN"
  4. Indicates the end of Procedure Foo and an entry point named Foo

An ASM Program:

  1. Always has an entry point (called main in C\C++)
  2. May or may not have a STACK segment
  3. If a STACK is present, it is the same as the CODE segment
  4. Should exit by executing the HALT instruction

MOV AX, 5 is of the form:

  1. MOV register, immediate
  2. MOV register, memory
  3. MOV register, register
  4. MOV memory, register
  5. MOV memory, immediate

MOV AX, [DI+5] is of the form:

  1. MOV register, immediate
  2. MOV register, memory
  3. MOV register, register
  4. MOV memory, register
  5. MOV memory, immediate

MOV AX, CX is of the form:

  1. MOV register, immediate
  2. MOV register, memory
  3. MOV register, register
  4. MOV memory, register
  5. MOV memory, immediate

MOV Label, AX is of the form:

  1. MOV register, immediate
  2. MOV register, memory
  3. MOV register, register
  4. MOV memory, register
  5. MOV memory, immediate

MOV [SI], 5 is of the form:

  1. MOV register, immediate
  2. MOV register, memory
  3. MOV register, register
  4. MOV memory, register
  5. MOV memory, immediate

INT21h with BX=4C00h will:

  1. Returns control to DOS (BH=4Ch) with an exit code of 00h (BL=00h)
  2. Is not required, but performed as a courtesy to the Operating System
  3. Will call DOS services, with unpredictable results
  4. Should no longer be used - issue HALT instead with an exit code in BX

A CALL when using a small memory model:

  1. Will cause CS and the current IP to be PUSHed on the stack
  2. Will cause the current IP to be PUSHed on the stack
  3. Will cause CS and the return IP to be PUSHed on the stack
  4. Will cause the return IP to be PUSHed on the stack

An assembled object file (*.obj):

  1. Never has an entry point (called main in C\C++)
  2. May have public procedures which can be CALLed
  3. Is created by the Linker
  4. May only have 1 procedure per object file

The Linker:

  1. Combines object files into an EXE
  2. Must find an entry point in only one of the object files
  3. Will create a "MAIN" if no object file have entry points
  4. Will create an EXE from the object file which contains "MAIN', discarding other object files

8086/8088 IBM PC memory:

  1. Is segmented
  2. Uses paragraph (16 byte) boundaries on segments
  3. Is word addressable
  4. Uses segments that are 32KB in size

A Program that writes directly to video RAM:

  1. Can use the SEGMENT directive with 0B800h
  2. Can use MOV DS, @video to properly set up the memory
  3. Can access video memory with a segment override, such as 0B00:0001
  4. Can only access the video memory through DOS services

An 8086/8088 IBM PC address:

  1. Is 16 bits in size
  2. Is 20 bits in size
  3. Is the segment + offset
  4. Is the segment*16 + offset (called the absolute address)
  5. Can be accessed using multiple segment/offset combinations

Problems\Short Answers

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SAMPLE CODE 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.model small
.stack 1024

   ;; util.lib is an Additional Global Library
   EXTERN   PutDec: Near

   INCLUDE PCMAC.INC

   displayStr   equ  09h
   CR           equ  0Dh
   LF           equ  0Ah
   TERM         equ  '$'
   NULL         equ  00h
   EXIT_OK      equ  4C00h
   ABBY_NORMAL  equ  4CFFh

.DATA
   strNewLine   db  CR, LF, NULL
   strResult    db  'The result is ', TERM

.CODE
;; **************************************
_MAIN_		 PROC

   mov dx, @data
   mov ds, dx

   mov dx, offset strNewLine
   CALL PrintString

   mov ax, 0
   mov cx, 10h
   CALCULATE:
      add ax, cx
   LOOP CALCULATE

   mov dx, offset strResult
   CALL PrintString

   CALL PutDec

   cmp cx, -1
   je  BAD_RESULT

   mov ax, EXIT_OK
   int 21h

   BAD_RESULT:
   mov ax, ABBY_NORMAL
   int 21h

_MAIN_		 ENDP
;; **************************************
PrintString  PROC     uses ax dx

   ;; Assumes DX is loaded with String to Print
   mov ah, displayStr
   int 21h

   ret
PrintString  ENDP
;; **************************************
END _MAIN_

Sample Code 1: What is the Output?

 

Sample Code 1: What is the return code?

 

Sample Code 1: Does this program use any of its stack space?

 

Sample Code 1: Why is _MAIN_ the enrty point?

 

Sample Code 1: What is "@data"

 

Sample Code 1: Does the Linker or Assembler use the EXTERN declaration?

 

Sample Code 1: What is PutDec and how is it used?

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SAMPLE CODE 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.model small
.stack 1024

   ;; util.lib is an Additional Global Library
   EXTERN   PutDec: Near

   INCLUDE PCMAC.INC

     elements     equ     26
     CR           equ     0Ah
     LF           equ     0Dh

.data
     Array        DB     'AbcdEFGhiJklMNOPqrStuvWxYz'
     CharToPrint  DB     ?

.code
;************************************************
WalkTheArray PROC uses ax bx cx dx ds

   mov dx, @data
   mov ds, dx

   _PutCh CR, LF            ; Cosmetics

   mov cx, elements         ; Set up for loop
   mov bx, 0                ; Start with element 0

   PrintLoop:
      mov al, Array[bx]     ; move character into al
      inc bx                ; increment for next element

      cmp al, 'A'           ; Is the character below/less than an "A"?
      jb NextChar

      cmp al, 'Z'           ; Is the character above/greater than a "Z"?
      ja NextChar

      mov CharToPrint, al   ; Save off the Character
      CALL PrintChar

   NextChar:
   Loop PrintLoop           ; Back to the top as required

   _PutCh CR, LF            ; Cosmetics

   mov ax, 4C00h
   int 21h

WalkTheArray ENDP
;************************************************
PrintChar PROC uses ax dx

     _PutCh CharToPrint, ' '  ; Basic printing

     ret

PrintChar ENDP
;************************************************
END WalkTheArray

Sample Code 2: What is the Output?

 

Sample Code 2: Are the character compares (ja/jb NextChar) signed or unsigned? What should they be?

 

Sample Code 2: Write the C\C++ pseudocode for the program.

 

Sample Code 2: What is PrintChar, and what happens when it is called?

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SAMPLE CODE 3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.model small
.stack 1024

   ;; util.lib is an Additional Global Library
   EXTERN   PutDec: Near

   INCLUDE PCMAC.INC

     elements     equ     5
     CR           equ     0Ah
     LF           equ     0Dh

.data
     Array        DW  0001, 0002, 0003, 0004, 0005   

.code
;************************************************
WalkTheArray PROC uses ax bx cx dx ds

   mov dx, @data
   mov ds, dx

   _PutCh CR, LF

   mov cx, elements         ; Set up for loop
   mov bx, 0                ; Start with element 0

   PrintLoop:
     mov ax, Array[bx]      ; move character into al
     inc bx

	CALL PutDec
      _PutCh ' ' 
 
   Loop PrintLoop           ; Back to the top as required

   mov ax, 4C00h
   int 21h
WalkTheArray ENDP
;************************************************
END WalkTheArray

Sample Code 3: What is the Output?

 

Sample Code 3: What is _PutCh, and how is it used?

 

Sample Code 3: Does the Assembler or Linker use _PutCh?

 

Sample Code 3: Will this program terminate? Why or why not?

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.data
     Array        DW  0001h, 0002h, 0003h, 0004h, 0005h
                  DB 'A', 'B', 'C', 'D', 'E', 'F'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

From the above fragment, how is the data stored in memory (don't convert the ASCII characters)?

                       

                       

 

Short Programs

(Assume the use of GetDec, PutDec, GetFP, PutFP, and macros as required. Values will not bow out registers.)

Write a program to calculate the sum of the first N integers (0 + 1 + ... + N), and print the result to the screen.

Write a program to verify a specified file exist. Print the results to the screen.

Write a program to calculates the 4th power of an integer (x4), and print the result to the screen.

Write a program to calculates the 4th power of float(x4), and print the result to the screen.

Write a program to count the number of characters in a file, and print the result to the screen.

Write a program to convert an integer value from farenheit to celcius, using integer math (disgarding any remainder). Print the result to the screen. Assume a Procedure FtoC, that accepts the farenheit value in CX, and returns the converted value in AX.

Write a program that calculates x = 2 * x - 1 using shifts or rotates. Print the result to the screen.

Write a program that prints and array of doubles. The array is declared in the .DATA segment, with 5 elements. Use 32 bit registers. Assume a Procedure PrintDouble that prints a value located in EAX.

Write a program that CALLs a Procedure PrintReturn. PrintReturn should print the IP address on the stack.

Write a program that CALLs a Procedure PrintStack. Before CALLing PrintStack, PUSH 3 values on the stack. In PrintStack, print the values in order of the PUSHes to the screen.

Write a macro that accepts an exit code, and exits to DOS with that exit code.

Write a macro that sets up the DS and ES data segments for use in a program.

Write the ASM procedure that is equivalent to the following. Assume signed values:

switch (AX) {
   case 2:
      // Something
      break;
   case 4:
      // Something Else
      break;
   case 8:
      // Something Different
      break;
   default:
      // Default
}

Write the ASM procedure that is equivalent to the following. Assume signed values:

if(AX == 5) {
   // Something
} else if(AX == 10) {
   // Something Else
} else if(AX < 25) {
   // Something Different
} else {
   // Default
}

Write the ASM procedure that is equivalent to the following. Assume signed values:

if(AX > 100 && BX > 100) {
   // Something
} else if(AX < 100 && BX < 100) {
   // Something Else
} else {
   // Something Different
}

Write the ASM procedure that is equivalent to the following. Assume signed values:

if(AX > 100 || BX > 100) {
   // Something
} else if(AX < 50 || BX < 50) {
   // Something Else
} else {
   // Something Different
}


CSEE | 211 | Current | lectures | news | help