Okay, I picked up CPU again after a long hiatus, and now everything's these brand new high speed things, and I am confused. I'm working on simply understanding it, and so far, no go. I wrote a program here to write a value from port0 to the RAM, and constantly loop (slowly) between every value of RAM, read it, and output it ... and of course reset itself if it goes past the RAM. Here's what I've got, and it seems that RAM is outputting 0's every time, that is, storing nothing.
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>jmp start;
alloc rwrite,0; // The RAM Write address
alloc temp,0; // Counter
alloc read,0; // Read address
start:
cpuid 1;
mov es,eax; // Stores 65536 or whatever that number
// into ES, so when I do ES:0, it will start in Ram slot 0
check:
add #temp,1;
cmp #temp,200;
jge counter; // Every time temp reaches 200, we increment read
mov port1,es:#read; // As far as I know
// This is the most effective way to read from an address
// But it could be wrong. I should use DS somewhere...
mov port2,ds:#read; // I tried this, also doesn't work correctly
mov port3,#rwrite; // Just for debugging, shows where the RAM's writing
cmp port0,es:#rwrite; // If it's the same number as the previous
je check; // Don't continue
// As a note, this way of 'reading' works, as does this comparison
// But reading values other than this one returns 0
add #rwrite,1; // Increment RAM address
mov es:#rwrite,port0; // Write value to it
jmp check;
counter: // Increments read, resets temp, and resets read if it's
//higher than the RAM address
mov #temp,0;
add #read,1;
cmp #read,#rwrite;
jl check;
mov #read,0;
jmp check;</div>
Right, well, commented for your pleasure.
So as you can see, I probably am reading and writing completely wrong, so if somone could walk me through that process, that would be awesome. Also, if I wanted to hook up a console screen and a RAM into one, how would I do that? As far as I know, I would set them both in an address BUS, with the size of Console at 2048, but then would I set the RAM's offset to 2048? And then would I just write to es:0 for the screen, and es:2048+ for the RAM?


LinkBack URL
About LinkBacks

re;overflow:auto'>jmp start;



Reply With Quote








Bookmarks