Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Error 161: Code generation error
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 9th March 03:19
ruud.baltissen@abp.nl
External User
 
Posts: 1
Default Error 161: Code generation error



Hallo allemaal,


Can someone explain what this "Error 161: Code generation error" is,
please?

The part causing the error is ML. I need the ML because I only have a
30 uSec window where all checking etc. has to be done. But it seems
that I'm limited in the use of ML because the moment I cross a certain
border, the error ocures. It is not the ML itself because it disappears
the moment I take a piece of code out of the program.

Here is the actual code. Look for the part marked with #####, move this
line one up and the error occures.

Thanks for any help or info !!!

var
bLPTstat, bLPTstatN, bControl : byte;
wIeeeLptaddr, wIeeeLptctrl, wIeeeLptstat,
wTrackBuffer, wTrackSize : word;


begin

repeat
asm
@1:
mov SI, wTrackBuffer { SI points to track data }
mov CX, wTrackSize
mov BH, 0 { no $FF found yet }

@4:
mov DX, wIeeeLPTstat
in AL, DX { read status register }
test AL, $40 { motor on? }
jne @99 { no, -> }

mov BL, bLPTstat
and BL, $30 { filter old step status }
mov AH, AL
and AH, $30 { filter new step status }
cmp BL, AH { compare }
jne @99 { not equal, -> }

test AL, $08 { SOE active? }
je @99 { no, -> }

mov bLPTstat, AL { save status }

cli { disable interrupts }

test AL, $80 { write or read mode? }
jne @20 { write mode, -> }

{** Read mode **}
mov DX, wIeeeLPTctrl
mov AL, bControl
and AL, $DF { LPT := output }
out DX, AL
mov bControl, AL

mov AL, [SI] { load byte from buffer }
dec DX
dec DX { DX points to LPTaddr }
out DX, AL { output byte }

inc DX
inc DX { DX points to LPTctrl }

cmp AL, $FF { possible [SYNC mark ? }
je @6 { yes, -> }

mov BH, 0 { no, delete reminder }
jmp @10

@6:
cmp BH, 0 { first $FF ? }
je @8 { yes, -> }


mov AL, bControl
and AL, $FB { SYNC signal on }
out DX, AL
mov bControl, AL
out DX, AL { keep same timing as... }
out DX, AL { ... with no SYNC signal }

jp @30

@8:
inc BH


{** Disable SYNC signal, even when not needed **}
@10:
(*
mov AL, bControl
or AL, 4 { SYNC signal off }
out DX, AL
mov bControl, AL

mov AL, bControl
###### *)
xor AL, 1 { Byte Ready on }
out DX, AL
xor AL, 1 { Byte Ready off }
out DX, AL

jp @30

@20:
mov DX, wIeeeLPTctrl
mov AL, bControl
or AL, $20 { LPT := input }
out DX, AL
mov bControl, AL

dec DX
dec DX { DX points to LPTaddr }
in AL, DX
mov [SI], AL

inc DX
inc DX { DX points to LPTctrl }
mov AL, bControl
xor AL, 1 { Byte Ready on }
out DX, AL
xor AL, 1 { Byte Ready off }
out DX, AL

@30:

{** delay for cycle time **}
in AL, DX

inc SI
loop @4 { next byte on track }

jp @1 { go to start of track }

@99:
sti { enable interrupts }
mov bLPTstat, AL { save status }
end;
until (bLPTstat <> bLPTstatN);

end.


--
___
/ __|__
/ / |_/ Groetjes, Ruud
\ \__|_\
\___| URL: Ruud.C64.org
  Reply With Quote


  sponsored links


2 9th March 03:19
hubblebubble
External User
 
Posts: 1
Default Error 161: Code generation error



Hi,

Well I don't know about the error but might it be something to do with
correctly aligning everything on word boundaries?


  Reply With Quote
3 9th March 03:19
klaus jorgensen
External User
 
Posts: 1
Default Error 161: Code generation error


Your asm block is too long. All conditional jumps are short, so the
destination has to be within 128 bytes from the jump opcode. The code
causing error 161 is the 'jne' after '@4'. Use a 'je' to jump to the
next piece of code, and a near jump to get to @99. Another solution
could be to put some of your asm code in a subroutine.

/klaus
  Reply With Quote
4 9th March 03:19
robert riebisch
External User
 
Posts: 1
Default Error 161: Code generation error


Ruud.Baltissen@abp.nl schrieb:


LOOP has a 128 bytes jump range limit. see, e.g.,
http://www.emu8086.com/assembly_language_tutorial_assembler_reference/asm_tutorial_07.html

--
Robert Riebisch
Bitte NUR in der Newsgroup antworten!
Please reply to the Newsgroup ONLY!
  Reply With Quote
5 9th March 03:19
ruud.baltissen@abp.nl
External User
 
Posts: 1
Default Error 161: Code generation error


Hallo Klaus, Robert,


8 bits. It seems that I have to study 8086 ML again

Many thanks for your help !!!

--
___
/ __|__
/ / |_/ Groetjes, Ruud
\ \__|_\
\___| URL: Ruud.C64.org
  Reply With Quote
6 9th March 03:19
klaus jorgensen
External User
 
Posts: 1
Default Error 161: Code generation error


As Robert points out; the LOOP has a problem with the asm size too. To
avoid several errors with short jumps, you could rearrange it by moving
the @20 code segment to the top or buttom of your asm section and use
near jumps to access it.

One more thing; there are a couple of 'jp' opcodes in your program
(preceeding @8, @20 and @99). Are you sure they shouldn't be 'jmp's?


/klaus
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666