tebe Posted February 19, 2014 Share Posted February 19, 2014 (edited) ok... can someone explain why this not work? .macro calc clc lda :1 adc :1+1 adc :1+2 adc :1+81 lsr lsr sta offset1+1 clc lda :1+1 adc :1+2 adc :1+3 adc :1+82 lsr lsr sta offset2+1 offset1 lda nibble0x offset2 ora nibblex0 sta :1-80 .endm ... :10 calc (buffer+#) adc (buffer+#)+1 ??? -> illegal addressing mode :10 calc # -> 0,1,2,3,4,5,6,7,8,9 :10 calc buffer+# -> buffer, buffer, buffer, buffer, buffer ... :10 calc buffer # -> parameter :1 buffer , parameter :2 only # is calculated, other expressions not Edited February 19, 2014 by tebe Quote Link to comment Share on other sites More sharing options...
tebe Posted February 19, 2014 Share Posted February 19, 2014 (edited) .var i, j, n .word word NOT byte Output ====== i = 20 j = 50 n = 120 Edited February 19, 2014 by tebe Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted February 19, 2014 Author Share Posted February 19, 2014 Because printf.obx assumes words... Quote Link to comment Share on other sites More sharing options...
Gury Posted February 27, 2014 Share Posted February 27, 2014 Yes, thanks for info. I wanted to use byte declaration so fixed example excerpt code looks like this: .var j .byteMain mva #40 j mva j $c0 jsr printf dta c'%',$9b,0 dta a($c0) I included this fix in new version of Effectus too. Quote Link to comment Share on other sites More sharing options...
phaeron Posted March 5, 2014 Share Posted March 5, 2014 There seems to be an issue with .ifndef and certain label patterns: org $2000 FOO = 0 .ifndef FOO FOO = 1 .endif .if FOO=1 .proc bar rts .endp .else bar rts .endif bar rts if.s (14) ERROR: Label BAR declared twice (BANK=0) Quote Link to comment Share on other sites More sharing options...
tebe Posted March 6, 2014 Share Posted March 6, 2014 There seems to be an issue with .ifndef and certain label patterns: org $2000 FOO = 0 .ifndef FOO FOO = 1 .endif .if FOO=1 .proc bar rts .endp .else bar rts .endif mads 09.03.2014 - fixed mads_0903.zip Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted April 1, 2014 Author Share Posted April 1, 2014 (edited) Ran into this the other day: .if .not build = hardware.MYIDE2 jsr ResetDrive ; reset drive, and get response bcc got_hdd jsr printf .byte 'No HDD',155,0 jmp jext_off got_hdd .endif If "BUILD" = hardware.SIDE, the entire block is skipped. Replacing the expression with the following fixed it: .if .not [build = hardware.MYIDE2]Now, operator precedence is described as follows: first [] (brackets) + - ~ < > (unary) * / % & << >> (binary) + - | ^ (binary) = == <> != < > <= >= (binary) ! (unary) && (binary) last || (binary) And it's stated that .not is equivalent to !. So why was .not (presumably) evaluated (negating "build") before the equality operator (which apparently has a higher precedence) when no brackets were present? Apologies if I've misunderstood. It's obviously safer and wise to remove ambiguity by employing brackets at all times anyway. Edited April 1, 2014 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted May 12, 2014 Author Share Posted May 12, 2014 When a compilation error occurs which results in a bad macro call, could we get a report of the line number where the macro call is located, rather than the line number in the macro definition? 1 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted May 14, 2014 Author Share Posted May 14, 2014 (edited) Related to the above, but more debilitating: why does this cause an error? NextBank .macro ; fill remainder of 8KB ROM bank with $FF and add cart header .align $BFF0,$FF sta $D500 ; reset to bank 0 jmp CartReset .byte 0,0,0,0 CartReset .word CartStart ; CartStart .byte 0 .byte 0 ; bit 0 = disk boot, bit 2 = cart start (otherwise init only) .word CartInit; CartInit org $A000 ; reset origin - CAUSES ASSEMBLY ERROR (CAN'T FILL FROM HIGHER ($C000) TO LOWER MEMORY LOCATION ($A000)) nmb ; bump assembler's bank counter .endm opt h- opt f+ org $A000 lmb #0 ; bank 0 ljsr :Bank1 NextBank ; pad bank and add cart header Bank1 ljsr :Bank2 NextBank Bank2 rts NextBank MADS generates "CAN'T FILL FROM HIGHER ($C000) TO LOWER MEMORY LOCATION ($A000)", pointing (again) to ORG $A000 in the macro definition, without reference to the location of the macro call which generated the error.Now, the macro simply pads the current bank with $FF and a cart header block. It then resets the origin to $A000, and bumps the bank counter. So why the fill error? If I remove OPT F+, the error goes away, but then any .DS statments or (more disastrously and impossible to correct) structure instances throw the origin out of whack, resulting in .ALIGN getting confused and producing ROM banks which are nowhere near 8KB in size. I HOPE OPT F+ (when I eventually get the compiler to produce a binary) results in memory skipped by .DS or a structure block producing $FF bytes.Is there a way to reset the origin to $A000 at the start of a bank without using ORG, which seems to be what's upsetting the compiler? Or am I approaching this the wrong way? NOTE: The above is example code which reproduces the issue. I will refrain from posting all 20,698 lines of the actual project. Edited May 14, 2014 by flashjazzcat Quote Link to comment Share on other sites More sharing options...
+JAC! Posted May 14, 2014 Share Posted May 14, 2014 Try:OPT F-ORG ...OPT F+ 1 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted May 14, 2014 Author Share Posted May 14, 2014 Try: OPT F- ORG ... OPT F+ Thanks Peter! That gets rid of the ORG error. All that was throwing things off after that were structs with undefined contents. The compiler puts out warnings about these, but they only become an issue when F+ is turned on. The compiler bumps the address but doesn't output anything. So with those fixed (as they should be), everything appears to line up. Thank you again. Quote Link to comment Share on other sites More sharing options...
+JAC! Posted May 20, 2014 Share Posted May 20, 2014 (edited) @tebe I'm about to update the English documentation. I found that http://mads.atari8.info/mads.html has some HTML validation errors which cause exception in the display & search tools. Could you add DOCTYPE and fix the major ones? (see http://validator.w3.org) org.xml.sax.SAXParseException; lineNumber: 2444; columnNumber: 3; The element type "p" must be terminated by the matching end-tag "</p>". at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257){code} at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347) at org.eclipse.help.internal.dynamic.DocumentReader.read(DocumentReader.java:56) at org.eclipse.help.internal.dynamic.XMLProcessor.process(XMLProcessor.java:49 Edited May 20, 2014 by JAC! Quote Link to comment Share on other sites More sharing options...
Gury Posted June 13, 2014 Share Posted June 13, 2014 (edited) Here is an example of random number generator. But, I can't figure it out why on Altirra it always shows the same number. If I run the same program on Atari800Win Plus, it works just fine. Can anyone tell me what is going on? org $3200 STORE1 equ $CB ; Temporary 8-bit variable STORE2 equ $CC ; Temporary 8-bit variable RANDOM equ $D20A .var i_eff_ .byte ; ; Rand - Random routine ; ; Parameters: ; .byte a (8-bit value): A value between 0 and 255 ; ; Result: ; STORE1 (8-bit value): Random number between 0 and 255 ; Rand .proc (.byte a) .reg sta STORE2 Loop lda RANDOM sta STORE1 #if .byte STORE1>STORE2 jmp Loop #end ; jmp Loop ;skip rts .endp MAIN jsr printf dta c'Random number generator demonstration',$9b,0 jsr printf dta c' ',$9b,0 jsr printf dta c'Selected number between 0 and 3',$9b,0 Rand #3 mva STORE1 i_eff_ mva i_eff_ $c0 jsr printf dta c'%',$9b,0 dta a($c0) jsr printf dta c' ',$9b,0 jsr printf dta c'End of program',$9b,0 jmp * .link 'printf.obx' run Main Here is the binary rand.xex Greetings Edited June 13, 2014 by Gury Quote Link to comment Share on other sites More sharing options...
MaPa Posted June 13, 2014 Share Posted June 13, 2014 (edited) It's because you run the program directly from "windows" and emulator starts every time from the same starting state and is cycle exact. So your program will read always the same "random" number from $D20A at the same time (cycle count) from emulation start and the random number is not random but defined sequence of numbers derived from polynomial counters or whatever. If you copy it onto .atr image and run from DOS then you will see that it generates different numbers because you will run it at different time offset from emulation start. Edited June 13, 2014 by MaPa Quote Link to comment Share on other sites More sharing options...
Gury Posted June 13, 2014 Share Posted June 13, 2014 That's the speed. Thank you MaPa, this answers my problem. I did put the program on ATR image and now it works as it is supposed to. Many thanks! Quote Link to comment Share on other sites More sharing options...
Gury Posted June 17, 2014 Share Posted June 17, 2014 There is alternative solution to putting program into ATR image. Just do some user key input before any random generation routine and it works perfectly, tested! (no need for ATR image). But the fact is Atari800Win does it the way I want and Altirra does not (talking about random number generation solution). Quote Link to comment Share on other sites More sharing options...
phaeron Posted June 19, 2014 Share Posted June 19, 2014 Keep in mind that similar effects can occur on real hardware. The random number sequence is restarted whenever POKEY is placed into initialization mode, which happens at a deterministic point during boot. Programs started off of disk or otherwise over the SIO bus won't notice this because the transfer takes a variable amount of time, but a cartridge boot definitely can, as can a disk or program boot emulated by a mega-cartridge. 2 Quote Link to comment Share on other sites More sharing options...
Gury Posted June 19, 2014 Share Posted June 19, 2014 Thank you for the explanation, that describes the issue! Altirra emulates real hardware superbly. Quote Link to comment Share on other sites More sharing options...
Gury Posted June 29, 2014 Share Posted June 29, 2014 Is it possible to declare .proc routine to another memory location in MADS, for example to declare it to vvblkd vectors? And assume that .proc is not predeclared to some address yet? Quote Link to comment Share on other sites More sharing options...
Gury Posted July 2, 2014 Share Posted July 2, 2014 I answered my question to myself Probably the question was not put correctly and was not understood completely. a .proc can be pointed by vectors in a way: mwa #SCROL vvblkd where SCROL is a proc and vvblkd is a vector address! 1 Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted July 2, 2014 Share Posted July 2, 2014 is there a trick to get "real" random numbers with Altirra & Eclipse without booting from ATR? I woud need a variable loop at the beginning so when accessing random 53770 I do not get always the same number right at the beginning? Quote Link to comment Share on other sites More sharing options...
MaPa Posted July 2, 2014 Share Posted July 2, 2014 Sure.. as Gury wrote, put a user input at the start of program like waiting for a key or joystick move/trigger. You have to put extra code (like 2 instructions ) at the start and remember to delete it before release of the product. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted July 2, 2014 Share Posted July 2, 2014 ah. ok... sometimes simple things are complicated... will do with shift pressed Quote Link to comment Share on other sites More sharing options...
Gury Posted July 8, 2014 Share Posted July 8, 2014 I have a problem showing % sign with the use of dta, for example dta c'The numbers % are:',0 This will not work, because it waits for number argument. I tried many ways around I know of, but didn't find a solution. The example with putline works (in Mads repository), but I want to use % sign the first way. Any solutions? Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted July 8, 2014 Author Share Posted July 8, 2014 Using the supplied printf? You can't display the percentage symbol unless you modify the printf routine. It should perhaps check for two consecutive "%" characters and output a single percentage symbol. Try these amendments: ?prt lda (?strv),Y beq ?ext iny sty ?off cmp #'%' beq ?spc cmp #'@' beq _float cmp #'#' beq _string ?output ; new label jsr putchr ?nxt ldy ?off bne ?prt ?ext lda ?vecv+1 pha lda ?vecv pha rts _float jmp float _string jmp string ?spc iny ; new code starts here lda (?strv),Y cmp #'%' bne ?notdouble inc ?off ; bump index to skip second char bne ?output ; char is in A, so print it ?notdouble ; new code ends here jsr _word lda (?dtav),Y sta fr0 iny lda (?dtav),Y sta fr0+1 jsr IFP jsr FASC Note this is completely untested. You'd also have to add similar checks pertaining to the other formatting characters ("#" and "@"). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.