All programs can be done in either Protected mode or Real-address
mode, as I need these to study for an upcoming test from. Thanks
alot, and feel free to comment with an question, comments, or
concerns.
1. Subtracting Three Integers
Using the AddSub program provided below as reference, write a program
that subtracts three 16-bit integers using only registers. Insert a
call DumpRegs statement to display the register values.
TITLE Add and Subtract (AddSub.asm)
;This program adds and subtracts 32-bit integers.
INCLUDE Irvine32.inc
.code
main PROC
mov eax,10000h ;EAX = 10000h
add eax,40000h ;EAX = 50000h
sub eax,20000h ;EAX = 30000h
call DumpRegs ;display registers
exit
main ENDP
END main
2. Data Definitions
Write a program that contains a definition of each data type listed
below. Initialize each variable to a value that is consistent with
its data type.
TYPE USAGE
BYTE 8-bit unsigned integer
SBYTE 8-bit signed integer
WORD 16-bit unsigned integer
SWORD 16-bit signed integer
DWORD 32-bit unsigned integer
SDWORD 32-bit signed integer
FWORD 48-bit integer
QWORD 64-bit integer
TBYTE 80-bit (10 byte) integer
REAL4 32-bit (4 byte) IEEE short real
REAL8 64-bit (8 byte) IEEE long real
REAL10 80-bit (10 byte) IEEE extended real
3. Symbolic Integer Constants
Write a program that defines symbolic constants for all of the days of
the week. Create an array variable that uses the symbols as
initializers.
4. Symbolic Text Constants
Write a program that defines symbolic names for several string
literals (characters between quotes). Use each symbolic name in a
variable definition. |
Clarification of Question by
bildy-ga
on
28 Mar 2003 20:00 PST
This should take less than 30 minutes for someone who knows what they are doing.
I have upped the fee to $10.
Thanks
|
Clarification of Question by
bildy-ga
on
30 Mar 2003 20:51 PST
I have upped the anty to $20, please consider answering this question
as soon as possible !
|
1)
INCLUDE Irvine32.inc ; Proetcted mode initialization
.code
main PROC
mov eax,80000h
call DumpRegs ;display registers
sub eax,40000h
call DumpRegs ;display registers
sub eax,20000h
call DumpRegs ;display registers
sub eax,10000h
call DumpRegs ;display registers
exit
main ENDP
END main
2)
.data
valb BYTE 12h
valsb SBYTE -12h
valw WORD 1234h
valsw SWORD -1234h
valdw DWORD 12345678h
valsdw SDWORD -12345678h
valfw FWORD 123456781234h
valqw QWORD 1234567812345678h
valtb TBYTE 1000000000123456789Ah
valr4 REAL4 -1.0
valr8 REAL8 1.0E-260
valr10 REAL10 1.0E+4000
3)
SUN = 0
MON = 1
TUE = 2
WED = 3
THU = 4
FRI = 5
SAT = 6
DAYS BYTE SUN,MON,TUE,WED,THU,FRI,SAT
4)
string1 TEXTEQU <"Sex ">
string2 TEXTEQU <"Booz ">
.data
prompt1 BYTE string1
prompt2 BYTE string2 |
Request for Answer Clarification by
bildy-ga
on
03 Apr 2003 15:10 PST
Please put all questions into separate programs, so they can be
compiled. A generous tip will be given for working progrqams.
Thanks alot.
|
Clarification of Answer by
studboy-ga
on
03 Apr 2003 16:22 PST
These are *already* working programs:
For example, take 4)
Put
string1 TEXTEQU <"Sex ">
string2 TEXTEQU <"Booz ">
.data
prompt1 BYTE string1
prompt2 BYTE string2
into a file call test.asm
Then do masn test.asm
BTW, where do you get these questions from?
If they are from your TA, this is taken from the questions at the end of the
chapter (#3) from a book--the answers are meant to be snipplets:
http://www.nuvisionmiami.com/books/asm/sampleChapters/chapt_03.pdf
|
Clarification of Answer by
studboy-ga
on
03 Apr 2003 16:22 PST
masm test.asm
|
Clarification of Answer by
studboy-ga
on
03 Apr 2003 16:29 PST
So, just a hint--since he takes the questions from this book, probably
the exam questions are based on this book--he's lazy! So buy the
book--you will ace the exam *for sure*!
|
Clarification of Answer by
studboy-ga
on
03 Apr 2003 16:31 PST
BTW, in case you didn't notice, Irvine32.inc is in chapter 3 of that book.
It basically sets up the mode. Of course you will need it to compile.
|
Request for Answer Clarification by
bildy-ga
on
03 Apr 2003 21:02 PST
This is what i get when i try to compile #4...
Assembling: 4.asm
4.asm(3) : error A2013: .MODEL must precede this directive
4.asm(4) : error A2034: must be in segment block
4.asm(5) : error A2034: must be in segment block
4.asm(5) : error A2088: END directive required at end of file
Press any key to continue . . .
Tool completed successfully
What exactly do I have to put in the compiler to set it up? Give me
the exact syntax for these programs please...
|
Clarification of Answer by
studboy-ga
on
04 Apr 2003 05:30 PST
Hi bildy-ga
I see what version of the assembler you're using now (I'm using a
different version)--try this and let me know if it works:
.386
.MODEL flat, stdcall
string1 TEXTEQU <"Sex ">
string2 TEXTEQU <"Booz ">
.data
prompt1 BYTE string1
prompt2 BYTE string2
.CODE
end
|
Clarification of Answer by
studboy-ga
on
04 Apr 2003 05:41 PST
BTW, just curious, what school/class is this? It seems like the
TA/instructor support for this class is ..... :) I think they should
at least *teach* you how to use MASM the first day of class.
|