• Please review our updated Terms and Rules here

8088 assembly programming

scommstech

Experienced Member
Joined
Jul 16, 2007
Messages
69
HI

Can anybody throw some light on this 8088 programming problem
I’m assembling some code to write the pattern AA into memory location
0 to 16 and then read it back. The code will be in an EPROM in the BIOS slot.
This is a diagnostic program to run on power up instead of the BIOS.
I thought that as the routine is only addressing 16 locations the lack of
memory refresh should not be a problem. All done in less than 3MS. And the
8088 itselfwill not have reserved base memory for itself.
I’m using stosb to write the pattern AA into the first 16 memory locations,
and am using mov dl,[si] to read back the AA from each memory location in
turn. I’m then doing a compare of dl and al after each read, as al should still
have AA in it from the previous write operation.
I’ve used EMU8086 to assemble the code and it assembles ok.
The write part runs ok but the first read back shows a different pattern to
AA in the dl register..
I’ve included the code I’m using. If somebody can spot my mistake I’d be
very grateful. Ps its only an amateurs attempt.

START
Code to set up direction and stop interrupts then :--

Mov ax,00 Put 0 in ax
Mov ds,ax Make data segment = 0
Sub di,di make write offset = 0
Mov al,0AAH put pattern in al
Mov cx,0FH set up count for 16
Rep
Stosb write AA into 16 memory locations starting at 00

The above bit appears to run ok It’s the next bit that has problems

Mov cx,0FH reset the counter for 16 (not sure if I need to )
Mov si,0FH set the read offset to the last memory written to
FRED: Mov dl,[si] get the AA from memory – put in dl
Cmp al,dl should still have AA so if good read compare = 0
Jz BILL good compare, go set up for next memory location
Hlt. Stops here if al not same as dl
BILL: Mov dl,0 clear dl for next read
Dec si set read offset to next location down
Dec cx decrement the counter
Cmp cx.0 check if all 16 location done
Jz START yes do all again
Jmp FRED not done yet


The assembler halts at the halt after the jz BILL instruction. Dl contains F4
not AA I don’t know if an EMU8086 assembler has any protected memory
but an assembled program should only be using virtual memory so shouldn’t
actually access memory 00. Maybe I’m wrong.

Anybody got any ideas.
Regards
Scommstech
 
I’m assembling some code to write the pattern AA into memory location
0 to 16 and then read it back.

You know that's where the interrupt table is, right? I wouldn't write junk to that location...

What happens when you try it (albeit in a different/free memory location) on a real 808x?
 
Hi
Yes I know its the int area but the BIOS wont have built it.
This is just a short memory exerciser to tell if the memory is ok.
I have a bad board that fails on refresh and memory. Need to find out
which is bad. If this test runs, then its the refreh that is bad.
Regards
Scommstech
 
Mov cx,0FH reset the counter for 16 (not sure if I need to )
Yes you have to. After the "rep movsb", CX is cleared.
The assembler halts at the halt after the jz BILL instruction. Dl contains F4
not AA I don’t know if an EMU8086 assembler has any protected memory
but an assembled program should only be using virtual memory so shouldn’t
actually access memory 00. Maybe I’m wrong.

Anybody got any ideas.
Regards
Scommstech
Try a different memory location. maybe at adress FFF0h instead of 0000h
 
FFF0 is ROM, not RAM.

I would try this on real hardware with a debugger (NOT in segment 0000 obviously) to see where your code is going wrong.

A cursory glance shows the code is okay so it might be something else...
 
Mov ax,00 Put 0 in ax
Mov ds,ax Make data segment = 0
Sub di,di make write offset = 0
Mov al,0AAH put pattern in al
Mov cx,0FH set up count for 16
Rep
Stosb write AA into 16 memory locations starting at 00

This is how I would have done it:
Code:
	cld		;increase si/di on multi-move
	Sub di,di	;make write offset = 0
	Mov cx,0FH	;set up count for 16
	jmp StoreNext	;store data
pattern:
	db AAh		;Data-pattern
StoreNext:
	Lea si,pattern	;Make source index = data pattern
	Movsb		;write AAh into memory location
	loop StoreNext	;store next byte
 
Last edited:
!!!BUG FOUND!!!

Code:
Rep Stosb
does not write AL to [ES : DI], but moves [DS : SI] to [ES : DI]. So instead of writing 0AAh, you are writing the data at DS : 0AAh through DS : 0B9h to the assigned memory.

No, you're wrong. Please review REP STOS and REP MOVS.

REP MOVS copies data from ds:si to es:di, then increments (or decrements, if direction flag is set) si and di, then decrements the count in cx. If cx=0, it stops.

REP STOS writes the byte in al (STOSB) or the word in ax (STOSW) to es:di, then increments (or decrements, if direction flag is set) si and di, then decrements the count in cx. If cx=0, it stops.

You did not find a bug.
 
No, you're wrong. Please review REP STOS and REP MOVS.

REP MOVS copies data from ds:si to es:di, then increments (or decrements, if direction flag is set) si and di, then decrements the count in cx. If cx=0, it stops.

REP STOS writes the byte in al (STOSB) or the word in ax (STOSW) to es:di, then increments (or decrements, if direction flag is set) si and di, then decrements the count in cx. If cx=0, it stops.

You did not find a bug.

oh... I didn't know about the STOS command... thought it was MOVS... I've edited the post with the piece of code.
 
8088 Assembly Programming.

8088 Assembly Programming.

Thanks for all your replys
I've sorted my routines out now. Most of it was finger troubles
and your tips putting me on the right track.
I'ts encouraging to see the interest and support that was be generated
Thanks for all your help.
By the way the reason for these "micky mouse" routines was that
I had about 7 8088 motherboards that would not boot.
I've now blown Eproms that plug into the BIOS slot and run
various memory tests on power up.
I also made up an I/F card that displays the 20 bit addresses
and hex indicators to read what's on the data bus.
The data displays are triggered by either the read or write strobes
so I could see the data going to or coming from memory.
Worked a treat. All boards now operational.
Regards
Scommstech
 
Thanks for all your replys
I've sorted my routines out now. Most of it was finger troubles
and your tips putting me on the right track.
I'ts encouraging to see the interest and support that was be generated
Thanks for all your help.
By the way the reason for these "micky mouse" routines was that
I had about 7 8088 motherboards that would not boot.
I've now blown Eproms that plug into the BIOS slot and run
various memory tests on power up.
I also made up an I/F card that displays the 20 bit addresses
and hex indicators to read what's on the data bus.
The data displays are triggered by either the read or write strobes
so I could see the data going to or coming from memory.
Worked a treat. All boards now operational.
Regards
Scommstech

It would be interesting if you could upload some pictures/schematics/code.
 
Back
Top