CST 121 TAKEHOME First Name: ________________
2012 November 1
2012 November 8 13 Last Name: ________________
In the spaces below, enter the first TWO letters of your first and last names,
using CAPITALS (UPPER CASE) for the initial letter of each name,
and small (lower case) for the second letters.
.DATA
F DB '___' ; FIRST letter of your first name.
G DB '__' ; second letter of your first name
L DB '___' ; FIRST letter of your last name.
M DB '__' ; second letter of your last name
AX | __ __ __ __
|
---|
BX | __ __ __ __ |
---|
;; Fill in the hexadecimal values that will be in AX and BX,
;; after these four instructions are executed.
.CODE
mov al, F
mov ah, G
mov bl, L
mov bh, M
Now, fill in the blanks below with values that would result from the following code.
Use exactly 4 hex digits for each value. (If an instruction is NOT executed, enter "XXXX" instead.)
| | |
|
| inc ah | ; one byte | ; ___ ___ ___ ___
|
| neg ax | ; one word | ; ___ ___ ___ ___
|
| cbw | | ; ___ ___ ___ ___
|
| push ax | | ; ___ ___ ___ ___
|
| | |
|
| mov ax, bx | | ; ___ ___ ___ ___
|
| add al, 20h | ; 20 hex | ; ___ ___ ___ ___
|
| sub ax, 8192 | ; 8192 decimal | ; ___ ___ ___ ___
|
| push ax | | ; ___ ___ ___ ___
|
| pop bx | | ; ___ ___ ___ ___
|
| sub ax, bx | | ; ___ ___ ___ ___
|
| je GO | | ; ___ ___ ___ ___
|
| mov ax, 0FFFFh | | ; ___ ___ ___ ___
|
GO:
|
| dec ah | ; high byte | ; ___ ___ ___ ___
|
| sub al, 1 | ; low byte | ; ___ ___ ___ ___
|
| | |
|
| mov ax, 6841 | ;; 6841 decimal | ; ___ ___ ___ ___
|
| sub al, 8 | ;; LOW byte | ; ___ ___ ___ ___
|
| dec ah | ;; HIGH byte | ; ___ ___ ___ ___
|
| add ax, 264 | ;; | ; ___ ___ ___ ___
|
| cmp ax, 6841 | ;; | ; ___ ___ ___ ___
|
| je there | | ; ___ ___ ___ ___
|
| inc ax | | ; ___ ___ ___ ___
|
there:
|
| mov ax, 2483 | ; 2483 decimal | ; ___ ___ ___ ___
|
| add ax, 256 | ; 256 DECIMAL | ; ___ ___ ___ ___
|
| mov al, 0 | | ; ___ ___ ___ ___
|
| neg ax | ; | ; ___ ___ ___ ___
|
What does the following code do?
; Explain what this procedure does:
;
; ______________________________________________________________
PAWS PROC
push ax
push bx
pop ax
pop bx
ret
PAWS ENDP
; Explain what this procedure does:
;
; ______________________________________________________________
PUNY PROC
cmp ax, bx
ja CHECKC
mov ax, bx
CHECKC:
cmp ax, cx
ja CHECKD
mov ax, cx
CHECKD:
cmp ax, dx
ja DONE
mov ax, dx
DONE:
ret
PUNY ENDP
; Explain what this procedure does:
;
; ______________________________________________________________
MUMU PROC
add ax, bx
add ax, cx
add ax, dx
shr
shr
ret
MUMU ENDP
Computations to be performed by procs defined in "TAKEHOME.ASM"
Write your code for these function in the file "TAKEHOME.ASM"
and use "calc.asm" to call and test your code.
NOTE: Arguments "X" and "Y" are in registers AX and BX.
(All values are integers.)
Result is returned in register AX.
- CalcA: Return whichever value is greater.
- CalcB: Compute the mean average of the two values.
- Skip the letter "C" in this set of procs.
- CalcD: Compute X 3
(X cubed = X * X * X).
- CalcE: Compute X Y
(X raised to the Y power).
Use a loop to multiply X by itself, Y times.
- CalcF: Compute the sum of all integers from X to Y, inclusive.
(For example, the sum from 10 to 14 is 60, the sum from 2 to 100 is 5049)
- CalcG: Swap the high and low bytes of each value,
and return whichever value is greater.
- CalcH: Swap the high bytes of each value,
and return whichever value is greater.
- CalcI: Return the value 100 if any of the four bytes is identical to
the ASCII value of one of your initials (in UPPER case); otherwise return zero.
- CalcJ: Return the value 100 if any of the four bytes is identical to
the ASCII value of one of your initials (regardless of case); otherwise return zero.
- CalcK: If any two bytes of the four bytes are identical,
then return its value; otherwise return zero.
- CalcL: Add the complement of X to the value of Y.
- CalcM: Compute the number of times that the smaller value can be
subtracted from the larger value.