I am in an assembly language course and need to do the following:
- Write code that defines symbolic constants for all seven days of the week.
- Create an array variable that uses the symbols as initializers
Here is my code so far:
MON EQU <"Monday", 0>
TUE EQU <"Tuesday", 0>
WED EQU <"Wednesday", 0>
THU EQU <"Thursday", 0>
FRI EQU <"Friday", 0>
SAT EQU <"Saturday", 0>
SUN EQU <"Sunday", 0>
.data
array BYTE MON,TUE,WED,THU,FRI,SAT,SUN
I found this post on StackOverflow that said:
Ok, there are a few ways to declare a string in MASM: First, you can declare the string in the data segment and use the variable throughout your code.
stringName BYTE "Hello, this is a string", 0
To declare a string constant you can use the EQU or TEXTEQU directive. Both are declared before the data segment in the global scope.
constantString EQU <"Hello, string content", 0>
I also found this post on StackOverflow that said the following:
An array of strings is not a continuous block of strings, it is a continuous block of pointers to strings. The strings can be anywhere.
arrayOfWords DWORD OFFSET strBicycle, OFFSET strCanoe, OFFSET strSkateboard, OFFSET strOffside, OFFSET strTennis strBicycle BYTE "BICYCLE",0 strCanoe BYTE "CANOE", 0 strSkateboard BYTE "SKATEBOARD", 0 strOffside BYTE "OFFSIDE", 0 strTennis BYTE "TENNIS", 0
I have tried writing the following code:
.data
array DWORD OFFSET MON,
OFFSET TUE,
OFFSET WED,
OFFSET THU,
OFFSET FRI,
OFFSET SAT,
OFFSET SUN
but this code fails to build with the following error:
1>AddTwo.asm(24): error A2084: constant value too large
Have I created string symbolic constants and an array of strings correctly?