• Please review our updated Terms and Rules here

Program to initialize 20x4 LCD screen for 8088

Didja know that on the 386 and up, the decrement-and-jump sequence is marginally faster than LOOP? There's a bunch of stuff like that; e.g. JCXZ is slower on the 386 than TEST, JZ...

Uhm... it's a wash actually. At 32 bits both a DEC and JNZ (near) would fit a single bus read as it's 4 bytes total, but it's 2 clocks + 9+m clocks... loop (near) is 2 bytes and 11+m clocks... at which point I'd go for the one taking less bytes in the hope of that one bus read doing a bit of read-ahead or read-behind. (and it would work better on the 386SX)

I think you're thinking 486 and up, where DEC+JNZ = 4 clocks, while LOOP = 7 clocks. (when followed)... and that's just bizarroland stuff in how the 486 worked.

Generally though I have a rule of thumb, write for the lowest target -- if it's fast enough on the slowest of procs, it's golden on anything faster.
 
Yup, it was the RISC-core 486. I'm beginning to forget my ancient architectures.

The "what do you write for" question cropped up quite a bit. You can look at it from both directions.

A customer with a 4.77 MHz 8088 doesn't have high expectations--he knows what he has isn't fast and will generally adjust to the workload. Any optimizations to code that you can make that favor the 8088 over the 486 and faster will probably not be terribly noticeable--or appreciated.

On the other hand, someone with a faster machine will expect more out of it and task it with a heavier workload. Any optimization that you can do that can take advantage of the 32-bit register set and improved instruction set will make him love you that much more. In addition, the guy's probably got more in his IT budget to buy more stuff from you.

So, you concentrate on the faster machines and let the customers thank you for not forgetting their last-generation hardware. Yeah, I know, it's cold, but that's the way things work in the real world.

I think that the PC world wasted entirely too much time dedicating resources to what amounts to a dead (8088 16-bit real-mode) architecture.

There's no evidence, for example, that shrinking the instruction set to benefit speed has ever hurt any manufacturer. At one time, I was on a project that probably eliminated about 30 percent of the instruction set--esoteric instructions that hardly anyone used. In the final assessment, it was a good thing and few customers made a big deal of it.
 
65408 = FF80, so that FF80:0 points to the bottom of your ROM (assuming that it's mapped into FF800-FFFFF.

Suppose you change to an 8K ROM (e.g. 2864). You'd change ROM_SIZE to 8192 and then that segment calculated above would be FE00--and everything magically adjusts. Your code is again at the "bottom" of ROM, which is now FE000.

Oh, yeah. I forgot to convert it to hex. As you said, it's late :p

I actually tested the LCD module, AMC2004A, on a PIC16F690 (in 8-bit mode), and it worked PERFECTLY.

Also, I just tried your suggestion about ROM_SIZE, and it didn't work. I copied and pasted it exactly. The only thing I didn't put in there was "org 0", because NASM doesn't allow two orgs (in the same segment I think). Everything else I copied, and here is the hex listing:

Code:
     1                                  ;              ************************************************
     2                                  ;              *                                              *
     3                                  ;              *  A PROGRAM TO EXPERIMENT WITH MY LCD DISPLAY *
     4                                  ;              *                                              *
     5                                  ;              ************************************************
     6                                  
     7                                  ;*****************************************************************************
     8                                  ;									     *
     9                                  ;                          USING 8-BIT MODE				     *
    10                                  ;									     *
    11                                  ; Lines used for control signals on port 2:                                  *
    12                                  ; B4  B0			        				     *
    13                                  ; RS  EN    Hex  Operation                                                   *
    14                                  ; **  **    ***  *********                                                   *
    15                                  ; 0   1     01h  IR write as an internal operation (display clear, etc.)     *
    16                                  ; 1   1     11h  Write data to DDRAM or CGRAM (DR to DDRAM or CGRAM)         *
    17                                  ;                                                                            *
    18                                  ;*****************************************************************************
    19                                  
    20                                  USE16
    21                                  
    22                                  section		.data
    23                                  ROM_SIZE     	equ     2048         		; size of ROM
    24                                  
    25                                  section		.text
    26                                  
    27                                  Startup:		
    28 00000000 31C0                    		xor	ax,ax
    29 00000002 8ED0                    		mov	ss,ax
    30 00000004 BCFE07                  		mov	sp,2046
    31 00000007 B090                    		mov	al,90h			;This sets the 8255 to operate
    32                                                                                  ;in Mode 0 (basic input output)
    33                                                                                  ;with port 0 as an input and 
    34 00000009 E603                                    out	03h,al                  ;ports 1 and 2 as outputs.  
    35 0000000B 31DB                    		xor	bx,bx
    36                                  
    37 0000000D E80600                  		call	LongDelay
    38 00000010 E80A00                  		call	LCDinit
    39 00000013 E86100                  		call	LCDinit2
    40                                  
    41                                  
    42 00000016 BBFF3F                  LongDelay:	mov	bx,0x3FFF		; Reset the countdown timer.
    43 00000019 4B                      		dec	bx			; Decrement it by 1 each time.  
    44                                  ;		cmp	bx,00h		
    45 0000001A 75FA                    		jnz	$-4			; If the counter hasn't counted
    46                                  						; down to 00h yet, keep going.
    47 0000001C C3                      		ret
    48                                  
    49 0000001D B038                    LCDinit:	mov	al,00111000b		; 8-bit, 2 lines, 5x8 characters
    50 0000001F E601                    		out	01h,al
    51 00000021 B001                    		mov	al,01h			
    52 00000023 E602                    		out	02h,al
    53 00000025 E8EEFF                  		call	LongDelay
    54 00000028 E8EBFF                  		call	LongDelay
    55 0000002B B000                    		mov	al,00h
    56 0000002D E602                    		out	02h,al
    57 0000002F E8E4FF                  		call	LongDelay
    58 00000032 E8E1FF                  		call	LongDelay
    59 00000035 E8DEFF                  		call	LongDelay
    60                                  		
    61 00000038 B00C                    		mov	al,00001100b		; Turn display on, cursor off, and do not blink the character at cursor
    62 0000003A E601                    		out	01h,al
    63 0000003C B001                    		mov	al,01h
    64 0000003E E602                    		out	02h,al
    65 00000040 E8D3FF                  		call	LongDelay
    66 00000043 E8D0FF                  		call	LongDelay
    67 00000046 B000                    		mov	al,00h
    68 00000048 E602                    		out	02h,al
    69 0000004A E8C9FF                  		call	LongDelay
    70 0000004D E8C6FF                  		call	LongDelay
    71 00000050 E8C3FF                  		call	LongDelay
    72                                  		
    73 00000053 B001                    		mov	al,00000001b		; Clear the screen
    74 00000055 E601                    		out	01h,al
    75 00000057 B001                    		mov	al,01h
    76 00000059 E602                    		out	02h,al
    77 0000005B E8B8FF                  		call	LongDelay
    78 0000005E E8B5FF                  		call	LongDelay
    79 00000061 B000                    		mov	al,00h
    80 00000063 E602                    		out	02h,al
    81 00000065 E8AEFF                  		call	LongDelay
    82 00000068 E8ABFF                  		call	LongDelay
    83 0000006B E8A8FF                  		call	LongDelay
    84                                  
    85 0000006E B014                    		mov	al,00010100b		; Set cursor to move and display to shift to the right
    86 00000070 E601                    		out	01h,al
    87 00000072 B001                    		mov	al,01h
    88 00000074 E602                    		out	02h,al
    89 00000076 C3                      		ret
    90                                  
    91                                  LCDinit2: 	
    92                                  
    93 00000077 E89CFF                  		call	LongDelay
    94 0000007A E899FF                  		call	LongDelay
    95 0000007D B000                    		mov	al,00h
    96 0000007F E602                    		out	02h,al
    97 00000081 E892FF                  		call	LongDelay
    98 00000084 E88FFF                  		call	LongDelay
    99 00000087 E88CFF                  		call	LongDelay
   100                                  
   101 0000008A B006                    		mov	al,00000110b		; Increment, and no display shift
   102 0000008C E601                    		out	01h,al
   103 0000008E B001                    		mov	al,01h
   104 00000090 E602                    		out	02h,al
   105 00000092 E881FF                  		call	LongDelay
   106 00000095 E87EFF                  		call	LongDelay
   107 00000098 B000                    		mov	al,00h
   108 0000009A E602                    		out	02h,al
   109 0000009C E877FF                  		call	LongDelay
   110 0000009F E874FF                  		call	LongDelay
   111 000000A2 E871FF                  		call	LongDelay
   112                                  
   113 000000A5 B002                    		mov	al,00000010b		; Return the cursor to home
   114 000000A7 E601                    		out	01h,al
   115 000000A9 B000                    		mov	al,00h
   116 000000AB E602                    		out	02h,al
   117 000000AD E866FF                  		call	LongDelay
   118 000000B0 E863FF                  		call	LongDelay
   119 000000B3 E602                    		out	02h,al
   120 000000B5 E85EFF                  		call	LongDelay
   121 000000B8 E85BFF                  		call	LongDelay
   122 000000BB E858FF                  		call	LongDelay
   123 000000BE F4                      		hlt
   124 000000BF C3                      		ret
   125                                  
   126                                  		org	ROM_SIZE-16
   127 000000C0 EA                      	        db	0eah			; far inter-segment jump
   128 000000C1 0000[0000]              		dw	0000h,Startup
   129 000000C5 80FF                    		dw	10000h-(ROM_SIZE/16)	; target segment

So using that doesn't work in NASM to put my far jump at the power-up location. org doesn't seem to work when I use it, so I just use:
Code:
times   2032- ($-$$) db 0

It doesn't hurt, and I kind of like it anyway lol.

Edit: I forgot to include that I put in an 8 Mhz crystal and it slowed it down a fair amount, and although it runs slower, it still bogues out at the exact same spot as it did when the 14.31818 Mhz crystal was in there. And I now have an 8088-1 capable of 10Mhz in there. Also, after I created the hex listing, I realized that on line 128, I think Startup is supposed to be a comment. I noticed that after I already posted the output here.
 
Last edited:
... I forgot to include that I put in an 8 Mhz crystal and it slowed it down a fair amount, and although it runs slower, it still bogues out at the exact same spot as it did when the 14.31818 Mhz crystal was in there. ...

So that means the EEPROM is fast enough.

You made a lot of progress:
1. You found a method of debugging and located one spot in your code where the problem occurs.
2. It doesn't look like a software problem because your code runs successfully up to that point.
3. It doesn't look like a RAM problem because you only use RAM for the stack and it works up to that point.

Seems to be a problem when your code hits around location 80h in ROM.

Are you sure your EEPROM is working and programmed properly? If you read back your EEPROM with the programmer, does the code look correct, especially around location 80h?
 
See what I said about using $-type addressing? You removed the CMP BX,0 but didn't adjust the jump. So the JNZ goes back to the MOV BX, and your loop never exits! Try adding a label after the MOV and jumping to it instead. (There's a reason why we old geezers say the things we do).

You can still use the TIMES operator and symbolics to do your padding:

times ((ROM_SIZE-16) - ($-$$)) db 0

should do it, don't you think?

(Personally, I hate NASM--it's a crippled assembler trying to invent its own syntax. TASM is at least somewhat better. MASM has bells and whistles, such as automatic forward jump optimization, TYPEDEFs and a whole bunch of other stuff. Still, I do have a copy of NASM. If you post your cleaned-up code and I'll run it under DEBUG and see what your hangup might be.)
 
Chuck, this is almost funny:lol: You made your point about $ addressing, and it is a good one. Also about unnecessary CMP instructions. But it created a problem where there wasn't one. (I know it was just waiting to happen).

Before the changes to make the code look prettier he seemed to be saying that he identified one spot where the problem is happening, and it wasn't in the delay loop.

I agree it will be helpful to see if debug and the real thing behave the same way.
 
See what I said about using $-type addressing? You removed the CMP BX,0 but didn't adjust the jump. So the JNZ goes back to the MOV BX, and your loop never exits! Try adding a label after the MOV and jumping to it instead. (There's a reason why we old geezers say the things we do).

You can still use the TIMES operator and symbolics to do your padding:

times ((ROM_SIZE-16) - ($-$$)) db 0

should do it, don't you think?

(Personally, I hate NASM--it's a crippled assembler trying to invent its own syntax. TASM is at least somewhat better. MASM has bells and whistles, such as automatic forward jump optimization, TYPEDEFs and a whole bunch of other stuff. Still, I do have a copy of NASM. If you post your cleaned-up code and I'll run it under DEBUG and see what your hangup might be.)

Sorry Chuck. I realized that after I posted the code and corrected it, but I forgot to post the better code. The reason I took the jmp out in the first place was because I was calling LongDelay and then the code went to another routine directly below it called Delay. I wondered that maybe the stack was messing up because it was expecting a ret from LongDelay, but was getting it from Delay instead. If that is no concern, then I will put it back to jmp. I was just trying things to see if they made a difference. Since you guys suggest against using $, I'll put it back. I guess maybe it is not throwing the stack off. But I did adjust it when I was using $. I changed it to -1 instead. Thanks again for your advice.

Forgot to include that I didn't take the eeprom out of the programmer until I did correct the $ thing :) Still, I would like to see what you guys think about calling LongDelay, but getting the ret from Delay.
 
Last edited:
It certainly sounds strange. I'm not exactly sure the point in your program you are talking about, but it might be the point where your address goes to 0080h in your ROM. That is on line 88 of your code, right after the out 02h, al. If the ROM for some reason is not responding fast enough to the change in the A7 address bit, it could be cycling back to address 0000h in ROM.

You might look at A7 with your scope and see if it is changing as the program cycles back and seems to reset. It could be a wiring problem or a problem with the latch or the EPROM.

Also you might have too slow an EPROM. It looks like from your video you are using a 28C16A-25. I figure you have less than 219nS from RD to the data being stable for a clock speed of 4.71MHz. Your chip has a 250nS access time from address to output and a 120nS time from OE to output according to one data sheet I looked at. So it may or may not be fast enough. You might try a faster one like 28C16A-20 or slow down your CPU clock speed. You can go down as low as 2MHz.

Last night, I hooked up my oscilloscope to A7. I saw it go high once. After that, I never saw it go high ever again, even after multiple turning on and off of the power and reset button.

I even replaced the 373 latch that latches A7, and it still had the same problem, and I checked all my wires. They're all snug in the breadboard.
 
Are you certain that your RAM is okay? One way to check is to avoid using it completely--just stick the return address in a register and jump to it at the routine exit.

Please do post your latest source. I'll assemble it and try to see what's going on.

BTW, what is the XOR BX,BX at line 35 (just before the call to LongDelay) supposed to accomplish? It seems superfluous to me.
 
Last night, I hooked up my oscilloscope to A7. I saw it go high once. After that, I never saw it go high ever again, even after multiple turning on and off of the power and reset button.

I even replaced the 373 latch that latches A7, and it still had the same problem, and I checked all my wires. They're all snug in the breadboard.

A7 should go high at startup, accessing FFFF0h. When you jump to FF800h, it should go low until you get to FF880h. Accessing RAM might also change A7.

So you should at least see it go high when you reset. Without a storage scope you might have trouble seeing anything.

I believe you have already done something like this, but to verify the reset is working insert a HLT at location 0 of your program. Verify that it halts when you reset.

To verify that the EEPROM and addressing is working without worrying about software issues, just do a series of NOP instructions up to and past the 80h location and then a HLT. If it halts, then it got past that location. If not, then you have some problem with the EEPROM or addressing.

Again you should read back your EEPROM with the programmer and verify that it is programmed properly.
 
I rewrote my code to bypass address 80h. Here it is:

Code:
     1                                  ;              ************************************************
     2                                  ;              *                                              *
     3                                  ;              *  A PROGRAM TO EXPERIMENT WITH MY LCD DISPLAY *
     4                                  ;              *                                              *
     5                                  ;              ************************************************
     6                                  
     7                                  ;*****************************************************************************
     8                                  ;									     *
     9                                  ;                          USING 8-BIT MODE				     *
    10                                  ;									     *
    11                                  ; Lines used for control signals on port 2:                                  *
    12                                  ; B4  B0			        				     *
    13                                  ; RS  EN    Hex  Operation                                                   *
    14                                  ; **  **    ***  *********                                                   *
    15                                  ; 0   1     01h  IR write as an internal operation (display clear, etc.)     *
    16                                  ; 1   1     11h  Write data to DDRAM or CGRAM (DR to DDRAM or CGRAM)         *
    17                                  ;                                                                            *
    18                                  ;*****************************************************************************
    19                                  
    20                                  USE16
    21                                  section		.data
    22                                  ROM_SIZE	equ	2048			; size of ROM
    23                                  
    24                                  section		.text
    25 00000000 00<rept>                		times	10h db 0
    26                                  
    27                                  Startup:		
    28 00000010 31C0                    		xor	ax,ax
    29 00000012 8ED0                    		mov	ss,ax
    30 00000014 BC0004                  		mov	sp,1024
    31 00000017 B090                    		mov	al,90h			;This sets the 8255 to operate
    32                                                                                  ;in Mode 0 (basic input output)
    33                                                                                  ;with port 0 as an input and 
    34 00000019 E603                                    out	03h,al                  ;ports 1 and 2 as outputs.  
    35 0000001B 31DB                    		xor	bx,bx
    36                                  
    37 0000001D E80600                  		call	LongDelay
    38 00000020 E80A00                  		call	LCDinit
    39 00000023 E86900                  		call	LCDinit2
    40                                  
    41                                  
    42 00000026 BBFF3F                  LongDelay:	mov	bx,0x3FFF		; Reset the countdown timer.
    43 00000029 4B                      Delay:		dec	bx			; Decrement it by 1 each time.  
    44 0000002A 75FD                    		jnz	Delay			; If the counter hasn't counted
    45                                  						; down to 00h yet, keep going.
    46 0000002C C3                      		ret
    47                                  
    48 0000002D B038                    LCDinit:	mov	al,00111000b		; 8-bit, 2 lines, 5x8 characters
    49 0000002F E601                    		out	01h,al
    50 00000031 B001                    		mov	al,01h			
    51 00000033 E602                    		out	02h,al
    52 00000035 E8EEFF                  		call	LongDelay
    53 00000038 E8EBFF                  		call	LongDelay
    54 0000003B B000                    		mov	al,00h
    55 0000003D E602                    		out	02h,al
    56 0000003F E8E4FF                  		call	LongDelay
    57 00000042 E8E1FF                  		call	LongDelay
    58 00000045 E8DEFF                  		call	LongDelay
    59                                  		
    60 00000048 B00C                    		mov	al,00001100b		; Turn display on, cursor off, and do not blink the character at cursor
    61 0000004A E601                    		out	01h,al
    62 0000004C B001                    		mov	al,01h
    63 0000004E E602                    		out	02h,al
    64 00000050 E8D3FF                  		call	LongDelay
    65 00000053 E8D0FF                  		call	LongDelay
    66 00000056 B000                    		mov	al,00h
    67 00000058 E602                    		out	02h,al
    68 0000005A E8C9FF                  		call	LongDelay
    69 0000005D E8C6FF                  		call	LongDelay
    70 00000060 E8C3FF                  		call	LongDelay
    71                                  		
    72 00000063 B001                    		mov	al,00000001b		; Clear the screen
    73 00000065 E601                    		out	01h,al
    74 00000067 B001                    		mov	al,01h
    75 00000069 E602                    		out	02h,al
    76 0000006B E8B8FF                  		call	LongDelay
    77 0000006E E8B5FF                  		call	LongDelay
    78 00000071 B000                    		mov	al,00h
    79 00000073 E602                    		out	02h,al
    80 00000075 E8AEFF                  		call	LongDelay
    81 00000078 E8ABFF                  		call	LongDelay
    82 0000007B E8A8FF                  		call	LongDelay
    83                                  
    84 0000007E C3                      		ret
    85 0000007F 00<rept>                		times	10h db 0
    86                                  
    87                                  
    88                                  LCDinit2: 	
    89                                  
    90 0000008F B014                    		mov	al,00010100b		; Set cursor to move and display to shift to the right
    91 00000091 E601                    		out	01h,al
    92 00000093 B001                    		mov	al,01h
    93 00000095 E602                    		out	02h,al
    94                                  
    95 00000097 E88CFF                  		call	LongDelay
    96 0000009A E889FF                  		call	LongDelay
    97 0000009D B000                    		mov	al,00h
    98 0000009F E602                    		out	02h,al
    99 000000A1 E882FF                  		call	LongDelay
   100 000000A4 E87FFF                  		call	LongDelay
   101 000000A7 E87CFF                  		call	LongDelay
   102                                  
   103 000000AA B006                    		mov	al,00000110b		; Increment, and no display shift
   104 000000AC E601                    		out	01h,al
   105 000000AE B001                    		mov	al,01h
   106 000000B0 E602                    		out	02h,al
   107 000000B2 E871FF                  		call	LongDelay
   108 000000B5 E86EFF                  		call	LongDelay
   109 000000B8 B000                    		mov	al,00h
   110 000000BA E602                    		out	02h,al
   111 000000BC E867FF                  		call	LongDelay
   112 000000BF E864FF                  		call	LongDelay
   113 000000C2 E861FF                  		call	LongDelay
   114                                  
   115 000000C5 B002                    		mov	al,00000010b		; Return the cursor to home
   116 000000C7 E601                    		out	01h,al
   117 000000C9 B000                    		mov	al,00h
   118 000000CB E602                    		out	02h,al
   119 000000CD E856FF                  		call	LongDelay
   120 000000D0 E853FF                  		call	LongDelay
   121 000000D3 E602                    		out	02h,al
   122 000000D5 E84EFF                  		call	LongDelay
   123 000000D8 E84BFF                  		call	LongDelay
   124 000000DB E848FF                  		call	LongDelay
   125 000000DE F4                      		hlt
   126 000000DF C3                      		ret
   127                                  
   128 000000E0 00<rept>                		times	((ROM_SIZE-16) - ($-$$)) db 0
   129 000007F0 EA                      		DB      0EAh 
   130 000007F1 0000                    		dw	0000h
   131 000007F3 80FF                    		dw	10000h-(ROM_SIZE/16)	; target segment
   132 000007F5 00<rept>                		times   11 db 0

It never reaches LCDinit2. Just keeps looping. I ordered some wire-wrap sockets a few days ago, so when I get them, I'll move it to the wire-wraps and see if that helps. I wonder if it's the breadboard.
 
A7 should go high at startup, accessing FFFF0h. When you jump to FF800h, it should go low until you get to FF880h. Accessing RAM might also change A7.

So you should at least see it go high when you reset. Without a storage scope you might have trouble seeing anything.

I believe you have already done something like this, but to verify the reset is working insert a HLT at location 0 of your program. Verify that it halts when you reset.

To verify that the EEPROM and addressing is working without worrying about software issues, just do a series of NOP instructions up to and past the 80h location and then a HLT. If it halts, then it got past that location. If not, then you have some problem with the EEPROM or addressing.

Again you should read back your EEPROM with the programmer and verify that it is programmed properly.

Sorry, I didn't see your post until after I posted my previous message. I was getting a timeout error when I was accessing this site for a while until now. I read back the code from the ROM, and it was identical to the hex output of my assembler.

Chuck, about bx:
I just did that to see if anything would change. I knew it wasn't necessary. Just wanted to see if it behaved differently, since it's behaving strange anyway. Not surprisingly, nothing changed.
 
I rewrote my code to bypass address 80h. Here it is:

Code:
...
    19                                  
    20                                  USE16
    21                                  section		.data
    22                                  ROM_SIZE	equ	2048			; size of ROM
    23                                  
    24                                  section		.text
    25 00000000 00<rept>                		times	10h db 0
    26                                  
    27                                  Startup:		
    28 00000010 31C0                    		xor	ax,ax
    29 00000012 8ED0                    		mov	ss,ax
    30 00000014 BC0004                  		mov	sp,1024
...

It never reaches LCDinit2. Just keeps looping. I ordered some wire-wrap sockets a few days ago, so when I get them, I'll move it to the wire-wraps and see if that helps. I wonder if it's the breadboard.

What's with the 10h zero bytes at the beginning? Looks like a typo.:confused:
 
Okay, the first file attached below, "test.asm" runs under DEBUG with no hangs. Of course, the OUT instructions don't do anything because I don't have the hardware.

Now, let's assume that your RAM isn't working. I've attached a second file test2.asm that doesn't use RAM at all--it passes the return addresses in SI. Note the macro definition.


If it runs, you know what your problem is.
 

Attachments

  • test.zip
    2 KB · Views: 1
What's with the 10h zero bytes at the beginning? Looks like a typo.:confused:

Ah crap. I had copied the file to another one so that I could keep track of all my changes. I copied the code from the wrong file. Originally, I was going to put a jump at the beginning of ROM, so that if the program is crashing and then going back to the beginning of ROM, it would, instead of continuously looping, encounter a jump I planned to put there, but I decided against it. At the power-up location, I was going to set CS to an even 16 byte address in front of the jump at the beginning, to prevent it from constantly looping. I defined bytes to 0 to go past address 80h, and before that, I was going to set CS to the jump at the beginning of ROM to jump to an address past where it hangs, but it seems that whenever A7 is part of an address, the program crashes, so I don't think it would have even mattered.

I seem to be clumsy about posting my code, which makes it more difficult for you guys. Sorry about that...
 
Disregard my last code post. I went ahead and wrote it out the way I thought of anyway, but it didn't change the outcome. Same looping voodoo. Here's the code I meant to post:

Code:
     1                                  ;              ************************************************
     2                                  ;              *                                              *
     3                                  ;              *  A PROGRAM TO EXPERIMENT WITH MY LCD DISPLAY *
     4                                  ;              *                                              *
     5                                  ;              ************************************************
     6                                  
     7                                  ;*****************************************************************************
     8                                  ;									     *
     9                                  ;                          USING 8-BIT MODE				     *
    10                                  ;									     *
    11                                  ; Lines used for control signals on port 2:                                  *
    12                                  ; B4  B0			        				     *
    13                                  ; RS  EN    Hex  Operation                                                   *
    14                                  ; **  **    ***  *********                                                   *
    15                                  ; 0   1     01h  IR write as an internal operation (display clear, etc.)     *
    16                                  ; 1   1     11h  Write data to DDRAM or CGRAM (DR to DDRAM or CGRAM)         *
    17                                  ;                                                                            *
    18                                  ;*****************************************************************************
    19                                  
    20                                  USE16
    21                                  section		.data
    22                                  ROM_SIZE	equ	2048			; size of ROM
    23                                  
    24                                  section		.text
    25 00000000 EB21                    		jmp	Anotherway
    26 00000002 00<rept>                		times	0xE db 0
    27                                  
    28                                  Startup:		
    29 00000010 31C0                    		xor	ax,ax
    30 00000012 8ED0                    		mov	ss,ax
    31 00000014 BC0004                  		mov	sp,1024
    32 00000017 B090                    		mov	al,90h			;This sets the 8255 to operate
    33                                                                                  ;in Mode 0 (basic input output)
    34                                                                                  ;with port 0 as an input and 
    35 00000019 E603                                    out	03h,al                  ;ports 1 and 2 as outputs.  
    36 0000001B 31DB                    		xor	bx,bx
    37                                  
    38 0000001D E80600                  		call	LongDelay
    39 00000020 E80A00                  		call	LCDinit
    40                                  Anotherway:
    41 00000023 E86A00                  		call	LCDinit2
    42                                  
    43                                  
    44 00000026 BBFF3F                  LongDelay:	mov	bx,0x3FFF		; Reset the countdown timer.
    45 00000029 4B                      Delay:		dec	bx			; Decrement it by 1 each time.  
    46 0000002A 75FD                    		jnz	Delay			; If the counter hasn't counted
    47                                  						; down to 00h yet, keep going.
    48 0000002C C3                      		ret
    49                                  
    50 0000002D B038                    LCDinit:	mov	al,00111000b		; 8-bit, 2 lines, 5x8 characters
    51 0000002F E601                    		out	01h,al
    52 00000031 B001                    		mov	al,01h			
    53 00000033 E602                    		out	02h,al
    54 00000035 E8EEFF                  		call	LongDelay
    55 00000038 E8EBFF                  		call	LongDelay
    56 0000003B B000                    		mov	al,00h
    57 0000003D E602                    		out	02h,al
    58 0000003F E8E4FF                  		call	LongDelay
    59 00000042 E8E1FF                  		call	LongDelay
    60 00000045 E8DEFF                  		call	LongDelay
    61                                  		
    62 00000048 B00C                    		mov	al,00001100b		; Turn display on, cursor off, and do not blink the character at cursor
    63 0000004A E601                    		out	01h,al
    64 0000004C B001                    		mov	al,01h
    65 0000004E E602                    		out	02h,al
    66 00000050 E8D3FF                  		call	LongDelay
    67 00000053 E8D0FF                  		call	LongDelay
    68 00000056 B000                    		mov	al,00h
    69 00000058 E602                    		out	02h,al
    70 0000005A E8C9FF                  		call	LongDelay
    71 0000005D E8C6FF                  		call	LongDelay
    72 00000060 E8C3FF                  		call	LongDelay
    73                                  		
    74 00000063 B001                    		mov	al,00000001b		; Clear the screen
    75 00000065 E601                    		out	01h,al
    76 00000067 B001                    		mov	al,01h
    77 00000069 E602                    		out	02h,al
    78 0000006B E8B8FF                  		call	LongDelay
    79 0000006E E8B5FF                  		call	LongDelay
    80 00000071 B000                    		mov	al,00h
    81 00000073 E602                    		out	02h,al
    82                                  
    83 00000075 E9                      		DB      0E9h 
    84 00000076 0000                    		dw	0000h
    85 00000078 80FF                    		dw	10000h-(ROM_SIZE/16)	; target segment
    86                                  
    87 0000007A C3                      		ret
    88 0000007B 00<rept>                		times	0x15 db 0
    89                                  
    90                                  
    91                                  LCDinit2: 	
    92                                  
    93 00000090 E893FF                  		call	LongDelay
    94 00000093 E890FF                  		call	LongDelay
    95 00000096 E88DFF                  		call	LongDelay
    96 00000099 B014                    		mov	al,00010100b		; Set cursor to move and display to shift to the right
    97 0000009B E601                    		out	01h,al
    98 0000009D B001                    		mov	al,01h
    99 0000009F E602                    		out	02h,al
   100                                  
   101 000000A1 E882FF                  		call	LongDelay
   102 000000A4 E87FFF                  		call	LongDelay
   103 000000A7 B000                    		mov	al,00h
   104 000000A9 E602                    		out	02h,al
   105 000000AB E878FF                  		call	LongDelay
   106 000000AE E875FF                  		call	LongDelay
   107 000000B1 E872FF                  		call	LongDelay
   108                                  
   109 000000B4 B006                    		mov	al,00000110b		; Increment, and no display shift
   110 000000B6 E601                    		out	01h,al
   111 000000B8 B001                    		mov	al,01h
   112 000000BA E602                    		out	02h,al
   113 000000BC E867FF                  		call	LongDelay
   114 000000BF E864FF                  		call	LongDelay
   115 000000C2 B000                    		mov	al,00h
   116 000000C4 E602                    		out	02h,al
   117 000000C6 E85DFF                  		call	LongDelay
   118 000000C9 E85AFF                  		call	LongDelay
   119 000000CC E857FF                  		call	LongDelay
   120                                  
   121 000000CF B002                    		mov	al,00000010b		; Return the cursor to home
   122 000000D1 E601                    		out	01h,al
   123 000000D3 B000                    		mov	al,00h
   124 000000D5 E602                    		out	02h,al
   125 000000D7 E84CFF                  		call	LongDelay
   126 000000DA E849FF                  		call	LongDelay
   127 000000DD E602                    		out	02h,al
   128 000000DF E844FF                  		call	LongDelay
   129 000000E2 E841FF                  		call	LongDelay
   130 000000E5 E83EFF                  		call	LongDelay
   131 000000E8 F4                      		hlt
   132 000000E9 C3                      		ret
   133                                  
   134 000000EA 00<rept>                		times	((ROM_SIZE-16) - ($-$$)) db 0
   135 000007F0 EA                      		DB      0EAh 
   136 000007F1 [1000]                  		dw	Startup
   137 000007F3 80FF                    		dw	10000h-(ROM_SIZE/16)	; target segment
   138 000007F5 00<rept>                		times   11 db 0

I'm going to study and use your code now Chuck. Thanks
 
Back
Top