CMSC211 Final Exam Questions
Master List
TRUE or FALSE
- (TRUE / FALSE) Other languages (such as C and C++) do not compile
and link to machine language instructions.
- (TRUE / FALSE) Later model Intel processors
(such as the Intel Pentium) are not backwards compatible with the
8086/8088.
- (TRUE / FALSE) Machine Language and Assembly Language refer to the
same language on the IBM PC.
- (TRUE / FALSE) The Intel x86 CPU is known as a RISC processor.
- (TRUE / FALSE) IBM PC memory is not byte addressable.
- (TRUE / FALSE) A CPU register is a special tyE / FALSE) A CPU register is a special type of high speed memory
built into the CPU.
- (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.
- (TRUE / FALSE) The BIOS can run a IBM PC without a processor installed.
- (TRUE / FALSE) The CPU's registers are part of the IBM PCs RAM.
- (TRUE / FALSE) The CPU in an IBM PC works with a stream of 1s and 0s
called bytes.
- (TRUE / FALSE) Hexadecimal numbers are base 15.
- (TRUE / FALSE) Binary digits can take on values between 0 and 2
inclusive.
- (TRUE / FALSE) The IBM PC uses the "sign magnitude"
method of representing negative numbers.
- (TRUE / FALSE) The LSB (Least Significant Bit) is the leftmost bit.
- (TRUE / FALSE) The MSB (Most Significant Bit) is the leftmost bit.
- (TRUE / FALSE) "Endian" is a term used to describe where
the LSB (or MSB) is located.
- (TRUE / FALSE) The size of a value that a CPU can perform operations
on is not limited by the CPU's register size.
- (TRUE / FALSE) A Byte is 8 bits on the IBM PC.
- (TRUE / FALSE) A Word and 4 Bytes occupy the same amount of memory on
the IBM PC.
- (TRUE / FALSE) 2s Compliment math is not used in the IBM PC because it
slows the CPU's ability to perform calculations efficiently.
- (TRUE / FALSE) A 1s Compliment is the re 1s Compliment is the reversing of bits in a value
(1 becomes 0, and 0 becomes 1), and then add 1 to the LSB.
- (TRUE / FALSE) Applying the 2s Complement operation on a value (for
example x), will yield -x + 1.
- (TRUE / FALSE) Applying the 1s Complement operation on a value (for
example x), will yield -x.
- (TRUE / FALSE) 2s Compliment math will never result in overflow because
2s math does not carry bit values.
- (TRUE / FALSE) When working with an 8 bit register, a carry into the
9th bit will be silently lost by the CPU.
- (TRUE / FALSE) Overflow is a term used to indicate a possible sign
change.
- (TRUE / FALSE) The Zero flag is set to indicate a non zero value.
- (TRUE / FALSE) Since the IBM PC uses sign magnitude, -1 is always
represented as "1000...000"
- the leftmost bit is always set.
- (TRUE / FALSE) A value in a register that has its rightmost bit set
will always cause the Sign bit to be set
- (TRUE / FALSE) An example of overflow is carrying into the 9th
bit during an 8-bit operation.
- (TRUE / FALSE) When using signed values, the possible values for an
8-bit register are -128 to 127.
- (TRUE / FALSE) When using unsigned values, the possible values for a
16 bit-registers are 0 to 255.
- (TRUE / FALSE) Regardless of register size, the value -1 is always athe value -1 is always a
stream of 1 bits.
- (TRUE / FALSE) The IBM PC uses the extended ASCII character set, which
is a 16-bit value per character.
- (TRUE / FALSE) Assembly Language source programs (usually with the
*.ASM extension), are text files.
- (TRUE / FALSE) Object Files (the *.OBJ extension), are compiled
(or assembled) and linked programs.
- (TRUE / FALSE) EXE files are produced by the assembler, after an ASM file has been linked.
- (TRUE / FALSE) Object Files are not machine dependent.
- (TRUE / FALSE) An EXE must be created from only one Object File.
- (TRUE / FALSE) An ASM file will always have a .STACK and
.CODE segment.
- (TRUE / FALSE) ASM files have distinguished words, such as MOV
and INT, which are called operations or op codes.
- (TRUE / FALSE) Loosely speaking, ASM files have distinct areas,
including Op Codes, Comments, and Labels.
- (TRUE / FALSE) ASM files must always have a function main( ).
- (TRUE / FALSE) An EXE written in Assembly Language will not have an
entry point (which is called main in C\C++).
- (TRUE / FALSE) The .DATA segment holds global data for use in
an ASM program.
- (TRUE / FALSE) Character strings are represented as some number of
Bytes in the .DATA segment, with a NULL terminator.
- (TRUE / FALSE) The segment reg/ FALSE) The segment registers include SS, CS, DS, ES, DI,
and SI on a 16 bit IBM PC.
- (TRUE / FALSE) The index registers are BX, BP, SI, and DI.
- (TRUE / FALSE) The general purpose registers include AX, BX, CX, DX,
EX, and FX (EX and FX are also known as fastcall registers).
- (TRUE / FALSE) AX is also known as the auxiliary register.
- (TRUE / FALSE) BX is also known as the based index register.
- (TRUE / FALSE) CX is also known as the counter register.
- (TRUE / FALSE) DX is also known as the DOS argument register.
- (TRUE / FALSE) DI is also known as the duplicate index register.
- (TRUE / FALSE) SI is also known as the source index register.
- (TRUE / FALSE) BP is also known as the base pointer register.
- (TRUE / FALSE) SP is the Special Purpose register, is used to hold
debug information, and should never be used in an ASM program.
- (TRUE / FALSE) IP is the Instruction Pointer, and is incremented by two
(the size of a word) after each instruction is executed.
- (TRUE / FALSE) The FLAGS register is known as a bit masked value, where
individual bits are significant, and not the value of the register.
- (TRUE / FALSE) Bits of the FLAGS register can be manipulated in an
ASM program (that is, set or cleared by the programmer).
- (TRUE / FALSE) Interrupts (INT instructions) can be hardware or
software implemented.software implemented.
- (TRUE / FALSE) The INT instruction can be hardware or software
generated.
- (TRUE / FALSE) There are no software interrupts on the IBM PC.
- (TRUE / FALSE) When an interrupt occurs, control is passed directly to
the Operating System, which then looks for the interrupt handler.
- (TRUE / FALSE) All interrupts (INTs) are serviced by the
interrupt controller.
- (TRUE / FALSE) There are separate instructions for signed and unsigned
addition on the IBM PC.
- (TRUE / FALSE) There are separate instructions for signed and unsigned
subtraction on the IBM PC.
- (TRUE / FALSE) There are separate instructions for signed and unsigned
multiplication on the IBM PC.
- (TRUE / FALSE) There are separate instructions for signed and unsigned
division on the IBM PC.
- (TRUE / FALSE) C/C++ statements x++ and x-- can be implemented in
Asted in
Assembly Language using INC and DEC.
- (TRUE / FALSE) Pseudocode ax = ax + 2 can be accomplished with
INC AX, 2.
- (TRUE / FALSE) When two 8-bit values are multiplied in Assembly
Language, the result can be up to 32 bits.
- (TRUE / FALSE) When two 16 bit values are multiplied in Assembly
Language, the result can be up to 16 bits (with overflow).
- (TRUE / FALSE) To perform an operation in Assembly Language that
requires two operands, both operands must be in registers.
- (TRUE / FALSE) Most two operand operations in Assembly language allow
both operands to reside in memory.
- (TRUE / FALSE) Operands include memory locations, registers, and
immediates (constants).
- (TRUE / FALSE) The MOV instruction can only be used to move
data from memory to the CPU and from the CPU to memory.
- (TRUE / FALSE) When MOVing a value (for example MOV BX, AX),
AX is reset to 0 after the MOV.
- (TRUE / FALSE) A CMP instruction performs a subtraction on the
operands, sets the FLAGS bits, but does not save the result of the
subtraction.
- (TRUE / FALSE) A CMP instruction only operates on signed values.
- (TRUE / FALSE) A CMP instruction only operates on unsigned values.
- (TRUE / FALSE) The CMP instruction has forms, one which operates s, one which operates
on signed values, the other on unsigned.
- (TRUE / FALSE) The AND instruction is a logical AND
("&" in C\C++).
- (TRUE / FALSE) The OR instruction is a bitwise OR
("|" in C\C++).
- (TRUE / FALSE) The XOR instruction generates the 1s Compliment
of the original value.
- (TRUE / FALSE) The NOT instruction generates the 2s Compliment of
the original value.
- (TRUE / FALSE) The CALL instruction is a unconditional far jump.
- (TRUE / FALSE) An ASM program should exit exit to DOS (through INT 21h)
or use the HALT instruction.
- (TRUE / FALSE) LOOP is an instruction based on the AX
(or AL) register.
- (TRUE / FALSE) The FLAGS register cannot be pushed.
- (TRUE / FALSE) Any general purpose register can be PUSHed,
including 8-bit and 16-bit values.
- (TRUE / FALSE) When PUSHing a value (for example PUSH DX),
the value is moved to the stack and DX is reset to 0.
- (TRUE / FALSE) A PUSH increments the SS register and a POP
decrements it.
- (TRUE / FALSE) A PUSH decrements SP by 2, and a POP
increments it by 2.
- (TRUE / FALSE) The FLAGS register can be PUSHed for manipulation,
but values cannot be POPped into thbe POPped into the FLAGS register.
- (TRUE / FALSE) The REP instruction prefix is usually used with
string manipulations.
- (TRUE / FALSE) The REP instruction can be used as "repeat
while true" and "repeat while not true".
- (TRUE / FALSE) To return from a procedure, use the RET instruction.
- (TRUE / FALSE) An ASM program cannot turn off interrupts.
- (TRUE / FALSE) SAL and SAR are arithmetic shift instructions
that preserve the sign of the original value.
- (TRUE / FALSE) SHL and SHR are logical bit shifts that set
the overflow bit when a bit is carried out and pad with 1.
- (TRUE / FALSE) ROL and ROR rotate bits in a register,
discarding the rotate out.
- (TRUE / FALSE) RCL and RCR rotate bits in a register, but
rotates out to the carry bit. The previous carry bit is lost.
- (TRUE / FALSE) The shift and rotate instructions can perform more than
1-bit rotates or shifts.
- (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.
- (TRUE / FALSE) The Intel x86 CPU has specialized instructions for
working with strings.
- (TRUE / FALSE) String manipulation instructions
include CMPS, LODS, MOVSB>LODS, MOVS, SCAS, and
STOS.
- (TRUE / FALSE) The string manipulation instructions requires the strings
be NULL terminated.
- (TRUE / FALSE) The string manipulation instructions assume DS for the
source string, and ES for the destination string.
- (TRUE / FALSE) The string manipulation instructions do not allow segment
(DS or ES) overrides.
- (TRUE / FALSE) The Coprocessor uses the system stack space.
- (TRUE / FALSE) The Coprocessor includes instructions to PUSH
special values on the FPU stack, such as pi, log2(e), and
log2(10).
- (TRUE / FALSE) The Coprocessor includes instructions to calculate
special values, such as Y log2(X) and Y log2(X+1).
- (TRUE / FALSE) Coprocessor instruction mnemonics are too damn long.
- (TRUE / FALSE) Labels are translated to addresses at assembly time.
- (TRUE / FALSE) A short jump can be in the range -128 to 127 byte
displacement.
- (TRUE / FALSE) The pseudo code "jump LABEL" is assembled to
JMP N, where n is a signed displacement.
- (TRUE / FALSE) Conditional jumps have two flavors: signed and unsigned
comparisons.
- (TRUE / FALSE) All high level conditionals (=, <, >, <=, and
>=) have corresponding assembly level op codes.
- (TRUE / FALSE) JA and JB are unsigned conditional jumps.
- (TRUE / FALSE) JG and JL are unsigned conditional jumps.
- (TRUE / FALSE) Procedures or subprograms are invoked using CALL.
- (TRUE / FALSE) Procedures in ASM start with the PROC directive and end
with the ENDP directive.
- (TRUE / FALSE) Main is a reserved name in ASM, and should not be used as
a Procedure name.
- (TRUE / FALSE) When a Procedure is CALLed, all register values
are PUSHed on the STACK for the procedure by the assembler.
- (TRUE / FALSE) The STACK starts in low memory and grows towards high
memory.
- (TRUE / FALSE) When exiting a CALLed Procedure, it is the
programmers responsibility to POP in reverse order of any
PUSHes.
- (TRUE / FALSE) The RETurn address should be PUSHed by the
programmer before CALLing a Procedure.
- (TRUE / FALSE) The RETurn address that is PUSHed is
actually a jump displacement.
- (TRUE / FALSE) When using the STACK to pass arguments, Procedures should
use SP +/- n.
- (TRUE / FALSE) When manipulating the STACK, save SP in BP
(MOV BP, SP). Then it is safe to use and change SP.
- (TRUE / FALSE) The only way to adjust the STACK is to POP into an
unused register.
- (TRUE / FALSE) The CPUI>(TRUE / FALSE) The CPU differentiates between signed and unsigned numbers.
- (TRUE / FALSE) GetDec reads an ASCII string and converts it to a value.
- (TRUE / FALSE) GetDec is actually a Macro, included in PCMAC.INC.
- (TRUE / FALSE) If a value in a registeris AABBh, it is stored in memory
as BB AA.
- (TRUE / FALSE) If a value in a register is 0011h, it is stored in memory
as 00 11.
- (TRUE / FALSE) BX is also known as the base index register.
- (TRUE / FALSE) The statement MOV AX, [BX + SI + 3] is illegal.
- (TRUE / FALSE) The statement MOV AX, [DI + SI] is legal.
- (TRUE / FALSE) The statement MOV AX, [DX + DI] is legal.
- (TRUE / FALSE) The statement MOV AX, [BP - 2] is illegal.
- (TRUE / FALSE) Indexing into arrays in Assembly Language is different
than in C/C++.
- (TRUE / FALSE) The statement MOV AX, array[5] will move the
5thth word in array[] into AX starting from array[0] (array[]
is a word array).
- (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).
- (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).
- (TRUE / FALSE) A word array may also be accessed as individual bytes,
in addition to accessing as words.
- (TRUE / FALSE) A word array may also be accessed as double words (DWORDS),
in addition to accessing as words.
- (TRUE / FALSE) A library (such as util.lib) is a collection of object
files (*.OBJ).
- (TRUE / FALSE) To access a Procedure in a library, declare the Procedure
with EXTERN or EXTRN.
- (TRUE / FALSE) The assembler resolves EXTERN or EXTRN declarations.
- (TRUE / FALSE) The assembler substitutes macros in a program.
- (TRUE / FALSE) The Linker resolves EXTERN or EXTRN declarations.
- (TRUE / FALSE) The Linker substitutes macros in a program.
- (TRUE / FALSE) To open a file in Assembly Language, pass DOS a
"$" terminated file name.
- (TRUE / FALSE) At the Assembly level, file handles are not available
to the programmer.
- (TRUE / FALSE) An Assembly program cannot bypass DOS and use
INT13h for file I/O.
- (TRUE / FALSE) An Assembly program cannot bypass DOS and use
INT10h for text mode video I/O.
- (TRUE / FALSE) Anything done in a high level language (such as C\C++),
can be done with Assembly.
- (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 |
HexHex |
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:
- Tests and initializes devices
- Can be run without the CPU using the BASIC interpreter
- Usually resides in high memory (EMS and XMS areas)
- Provides the initial interrupt vector for the Operating System
- Starts the machine, then turns control over to the Operating System
The Interrupt Vector:
- Is a table of addresses for handlers (procedures)
- Can hold 2048 entries
- Does not have to loaded because it resides in a ROM
- Is deleted by the Operating System after the OS is loaded
8 bit values are in the range:
- unsigned: 0 to 255
- unsigned: 0 to 128
- signed: -128 to 255
- signed: -128 to 127
16 bit values are in the range:
- unsigned: 0 to 65535
- unsigned: 0 to 32767
- signed: -32768 to 32767
- signed: -32768 to 65535
MOV AH, 355h:
- Moves 355h into AH
- Moves 03h into AH and 55h into AL
- Moves 355h into AX
- Will cause a assembler error
- Will assemble, but cause a linker error
In an ASM program, the statement "END FOO":
- Indicates the end of Procedure Foo
- In>
- Indicates the end of Procedure Foo
- Indicates the entry point is Foo
- Is incorrect, "END" should always occur with "MAIN"
- Indicates the end of Procedure Foo and an entry point named Foo
An ASM Program:
- Always has an entry point (called main in C\C++)
- May or may not have a STACK segment
- If a STACK is present, it is the same as the CODE segment
- Should exit by executing the HALT instruction
MOV AX, 5 is of the form:
- MOV register, immediate
- MOV register, memory
- MOV register, register
- MOV memory, register
- MOV memory, immediate
MOV AX, [DI+5] is of the form:
- MOV register, immediate
- MOV register, memory
- MOV register, register
- MOV memory, register
- MOV memory, immediate
MOV AX, CX is of the form:
- MOV register, immediate
- MOV register, memory
- MOV register, register
- MOV memory, register
- MOV memory, immediate
MOV
Label, AX is of the form:
- MOV register, immediate
- MOV register, memory
- MOV register, register
- MOV memory, register
- MOV memory, immediate
MOV [SI], 5 is > memory, immediate
MOV [SI], 5 is of the form:
- MOV register, immediate
- MOV register, memory
- MOV register, register
- MOV memory, register
- MOV memory, immediate
INT21h with BX=4C00h will:
- Returns control to DOS (BH=4Ch) with an exit code of 00h (BL=00h)
- Is not required, but performed as a courtesy to the Operating System
- Will call DOS services, with unpredictable results
- Should no longer be used - issue HALT instead with an exit code
in BX
A CALL when using a small memory model:
- Will cause CS and the current IP to be PUSHed on the stack
- Will cause the current IP to be PUSHed on the stack
- Will cause CS and the return IP to be PUSHed on the stack
- Will cause the return IP to be PUSHed on the stack
An assembled object file (*.obj):
- Never has an entry point (called main in C\C++)
- May have public procedures which can be CALLed
- Is created by the Linker
- May only have 1 procedure per object
file
The Linker:
- Combines object files into an EXE
- Must find an entry point in only one of the object files
- Will create a "MAIN" if no object file have entry points
- Will create an EXE from the object file which containste an EXE from the object file which contains "MAIN',
discarding other object files
8086/8088 IBM PC memory:
- Is segmented
- Uses paragraph (16 byte) boundaries on segments
- Is word addressable
- Uses segments that are 32KB in size
A Program that writes directly to video RAM:
- Can use the SEGMENT directive with 0B800h
- Can use MOV DS, @video to properly set up the memory
- Can access video memory with a segment override, such as 0B00:0001
- Can only access the video memory through DOS services
An 8086/8088 IBM PC address:
- Is 16 bits in size
- Is 20 bits in size
- Is the segment + offset
- Is the segment*16 + offset (called the absolute address)
- 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 ****************
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[ ; 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
;;;;;;;;;;
.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 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 scrnt 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. 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
}
UMBC |
CSEE