I assume that your Windows 98 is now installed on the 40GB hdd? And the 40GB is the master hdd?
Yes, you can and should do as you suggest. You can start afresh, install 98 first, then install XP which will itself create a dual boot between 98 and XP for you.
You should set 8GB hdd as the master, preferably leave the 40GB hdd disconnected for the time being. Boot up with 98 floppy, format the 8GB hdd, and install 98 on it.
Then reconnect xp hdd as slave and install XP there.
You will need to format the 40GB hdd. If you want to access the 40GB hdd from within 98, you must use FAT32. But XP cannot format a partition larger than 32GB with FAT32 (but formatting it with NTFS is no problem).
If you want to retain a 40GB partition, you should format it in the newly installed windows 98, or format it from DOS with a 98 boot floppy (the former should be quicker) first, before trying to install XP. Note however that a FAT32 partition larger than 32GB can get a bit slow (this is because the File Allocation Table in FAT32 gets too large).
You may want to consider whether to divide the 40GB into perhaps 2 or more partitions. If so, you can do the partitioning and formatting within XP Setup itself.
When you install XP, if you start the instalation from within Windows 98, remember to select install new copy (advanced) from drop down list), and tick the option for specifying the location where XP is installed. Computer will restart and go into XP Setup, which will give you the choice of where to install XP.
After installation of XP, when you restart, you will get a choice of OS to choose from.
This method will only work if you install 98 first, then install XP. Remember the computer will be booting from the old 8GB hdd, which may be pretty old.
Another option is to install both 98 and XP on the same 40GB hdd, by creating partitions on it using fdisk, then install 98 to C first. C can be very small, 3 GB is probably OK if you're not going to install many programs. After that, install XP to D and you will still have a dual boot, but using the 40GB as the boot disk (which should last a bit longer). Use 8GB as you like.
If you need further help, post back.