I have write a assembly program using SPIM simulator. Wondering if someone can guide me on how to start on this. Program will take number from 1 to 365 as input and print month and date.

For example you input: 2
program will say : its January 2

if your input is 364
program will print: its December 30

I don't way to worry about leap year at this point.

ideas???

Recommended Answers

All 12 Replies

I would create a table of accumulated days

DaysTbl[] = { 0, 31, 59, etc. }
Find your day count base in the table. That index is your 0 based month!
The difference is the day count that month!

You could also use a days in each month and a loop count, but I like the accumulation table as it is a lot more robust!

can you please elaborate. if you can provide any code that uses that method that would be great...

appreciate your help.
thanks

Sorry no! You make an appropriate attempt and if you have trouble then we'll review and offer suggestions!
(Website policy!)

how can sample code be against site policy. every site is OK with it.

I have search through my SPIM guide but I don't see anything that resembles what was pointed out earlier. that is using a table.

Read the member rules!

odd db 1,3,5,7,9 ; 8-bit values
num dw 1234,5678,1357,2468 ;16-bit values

what are you talking about WILLIS?????? what did you just write...

I have search through my SPIM guide but I don't see anything that resembles what was pointed out earlier. that is using a table.

odd db 1,3,5,7,9 ; 8-bit values
num dw 1234,5678,1357,2468 ;16-bit values


mov al,odd[ bx ]
mov ax,num[ bx ]

You asked for an example how to access a table. That's what I posted!

thanks for the effort Wildgoose. But I am not following at all. Perhaps this site is not for people who don't know much assembly to begin with.

Listen to the instructor.
Take notes.
Read the text book.

There are registers. They are temporary storage of data values within the processor. In the case of the 80x86 let's assume you're using old assemblers for 16-bit mode. There are four general purpose registers.

AX, BX, CX, DX, each of these have 8-bit registers
AL lower 8-bits AH upper 8-bits
BL, BH
CL, CH
DL, DH

In memory data can be stored as individual data bytes or arrays of data bytes.

In your particular case you should already know all this because the assignment you've been assigned is typically around week 3 or higher!

These were assembly declarations of an array of bytes. The array was labeled 'odd'. The data stored was 1, 3, 5, 7, 9 and was defined as decimal.
odd db 1,3,5,7,9 ; 8-bit values
I could have stated
odd db 01h, 03h, 07h, 09h for 8-bit hex values.
or
odd db 00000001B
db 00000011B
db 00000111B
db 00001001B

But decimal made more sense for this data type.

In this case 16-bit data was stored. Label 'num' dw indicated data word thus 16-bit could also have been WORD
num dw 1234,5678,1357,2468 ;16-bit values

This instructions loads a byte value from the array using an index stored in bx, and stores the loaded result into the al register.
mov al,odd[ bx ]

This one does the same but with a 16-bit data value.
mov ax,num[ bx ]


If you didn't understand the previous posting then you need to catch up to your class. We don't write your homework for you. Those were legitimate samples I gave and if you didn't understand them, then I can't help you with this problem.

Use your book in conjunction with this link and the others nearby.
http://sunsite.rediris.es/pub/mirror/intel/design/Pentium4/manuals/245471.htm

thanks wildgoose. but we using mips.. syntax is completely different.

i was infact able to figure out the crux of the problem.

Ah, you said SPIM, and I the processor MIPS didn't popup to me, so I went with the mainstream 80x86, but of course SPIM is a tool for MIPS.

I primary think GNU with thinking about MIPS as that's the primary toolset I use with MIPS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.