
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
||
|
> Maybe a stupid question but do you know why the -P513 fault happens or is this something only DIE HARD can tell us about? I don't think DIE HARD is involved. But we do have, thanks to Dietmar, on the left hand side under HTML-ROM-Listing a fully commented listing of the operating system, which contains the erroneous function. The comment there says that the false output is caused by an error in the division function of the very code: ; --------------------------------------------------------------------------- ; Zahl als ASCII-String dezimal kodiert auf RS232 ausgeben ; die Zahl -32768 wird nicht richtig ausgegeben, was an einem ; Bug in der Divisionsroutine des Betriebssystems liegt ; ; wert=2035 ' entsprechende Logik in BASIC ; merker=0 ' programmiert ; for i=0 to 4 ; w=peekw($1dd7+2*i) ' Word aus Tabelle holen ; if wert>=w then ; print chr$(48+wert\w); ; merker=1 ; elseif merker=1 then ; print "0"; ; end if ; wert=wert MOD w ; next i ; ; input : $d0:$d1 = Zahl (Word) ; output: - ; used : a,x,$11,$54-$59,$d0-$d1,$d9-$da,$dd-$df ; ; called from $0b6f,$18dc,$1b38,$1b54 ; --------------------------------------------------------------------------- 0ce8 : 3fda clr $da ; Merker zur Unterdrueckung von fuehrenden 0cea b6d0 lda $d0 ; Nullen loeschen 0cec bad1 ora $d1 ; 0cee 2604 bne $0cf4 ; falls die zu uebertragende Zahl null 0cf0 ae30 ldx #'0' ; ist, einfach 0cf2 2083 bra $0c77 ; "0" ueber RS232 senden 0cf4 : 3dd0 tst $d0 ; ist die Zahl negativ? 0cf6 2a12 bpl $0d0a ; falls nein, springe 0cf8 ae2d ldx #'-' ; 0cfa cd0c77 jsr $0c77 ; falls doch, "-" ausgeben 0cfd bed0 ldx $d0 ; und die Zahl invertieren 0cff b6d1 lda $d1 ; 0d01 53 comx ; 0d02 40 nega ; But the last few quoted comments make me curious. In English they mean "if negative, print "-" and invert the number" (invert meaning to switch the sign). Yet for a -32768 stored in two bytes as a 2's complement, there is no way to invert it, since there is no positive 32768 which can be represented in two bytes in 2's complement. As we all know two bytes in 2's complement have a range from -32768 (0x8000) to 32767 (0x7ffff). I have not analysed it any further, but that's where I would start. HTH Bye Achim |
| Antwort schreiben |