04-09-2016, 10:02 PM
Hello again all,
I have another newbie programming question.
As you may have seen, I developed an 8080 emulator that uses M1 as a single column array for the program memory. The 8080 instructions are stored as decimal numbers. I have been entering only very short test programs by hand to exercise my emulator so far.
I have the code from my system monitor in my vintage IMSAI system that allows a few activities, such as dump memory from one address to another, enter code byte by byte into memory, and goto a memory location and start executing.
I would like to enter this code into my M1 array for my emulator. I have the code as hexadecimal numbers. So, I tried to create a small program to allow me to enter hex bytes, and store them as decimal numbers. I figured I would be clever and simply change the Base to Hexadecimal for the hex entry, and then change the Base to Decimal to store the number into M1.
Here's the code:
Unfortunately for me, this is not working. The program as written works just fine if I enter normal decimal numbers. However, if I enter 0A, 0B, 0C... it stores away 0. Also, if I try A, B, C, D, E, or F, I get unusual numbers instead of the expected 10, 11, 12, 13, 14, or 15.
This method of changing the Base is not working for me. Am I on the right track, or will I have to enter two-character strings and do the whole conversion myself?
Thanks for listening. Your advice would be very much appreciated.
smp
I have another newbie programming question.
As you may have seen, I developed an 8080 emulator that uses M1 as a single column array for the program memory. The 8080 instructions are stored as decimal numbers. I have been entering only very short test programs by hand to exercise my emulator so far.
I have the code from my system monitor in my vintage IMSAI system that allows a few activities, such as dump memory from one address to another, enter code byte by byte into memory, and goto a memory location and start executing.
I would like to enter this code into my M1 array for my emulator. I have the code as hexadecimal numbers. So, I tried to create a small program to allow me to enter hex bytes, and store them as decimal numbers. I figured I would be clever and simply change the Base to Hexadecimal for the hex entry, and then change the Base to Decimal to store the number into M1.
Here's the code:
Code:
// LoadCode
//
// Load 8080 code into M1
// Input the first location in decimal, then increment from there
// Input the 8080 code as hex bytes, convert to decimal and store
//
LOCAL loc,byte;
//
EXPORT LoadCode()
BEGIN
byte:=0;
loc:=0;
INPUT(loc,"Starting Location","Start=","Enter the starting location in decimal",0);
WHILE (byte>=0) DO
byte:=M1(loc);
3->Base; // set base to hexadecimal
INPUT(byte,"8080 Code","Byte=","Enter a byte as a hex number",0);
2->Base; // set base to decimal
M1(loc):=byte;
loc:=loc+1;
END;
END;
Unfortunately for me, this is not working. The program as written works just fine if I enter normal decimal numbers. However, if I enter 0A, 0B, 0C... it stores away 0. Also, if I try A, B, C, D, E, or F, I get unusual numbers instead of the expected 10, 11, 12, 13, 14, or 15.
This method of changing the Base is not working for me. Am I on the right track, or will I have to enter two-character strings and do the whole conversion myself?
Thanks for listening. Your advice would be very much appreciated.
smp