zenassem Posted October 21, 2004 Share Posted October 21, 2004 I have been working through the book "Atari Roots", and have been progressing ok. Of course I had to jump foward and try assembling one of the graphic display examples, and ran into my first problem. This code sample is giving me an error in mac/65. But I don't understand why. A CUSTOMIZED SCREEN DISPLAY 10 ; 20 ;HELLO SCREEN 30 ; 40 *=$3000 50 JMP INIT 60 ; 70 SDMCTL=$022F 80 ; 90 SDLSTL=$0230 0100 SDLSTH=$0231 0110 ; 0120 COLOR0=$02C4; OS COLOR REGISTERS 0130 COLOR1=$02C5 0140 COLOR2=$02C6 0150 COLOR3=$02C7 0160 COLOR4=$02C8 0170 ; 0180 ;DISPLAY LIST DATA 0190 ; 0200 START 0210 ; 0220 LINE1 .SBYTE " PRESENTING " 0230 LINE2 .SBYTE " the big program " 0240 LINE3 .SBYTE " By (your name) " 0250 ; 0260 LINE4 .SBYTE " PLEASE STAND BY " 0270 ; 0280 ;DISPLAY LIST 0290 ; 0300 HLIST 0310 .BYTE $70,$70,$70; 3 BLANK LINES 0320 .BYTE $70, $70, $70, $70,$70; MORE BLANK LINES 0330 .BYTE $46; LSM, ANTIC MODE 6 (BASIC MODE 2) 0340 .WORD LINE1; (TEXT LINE: "PRESENTING...") 0350 .BYTE $70,$70,$70,$70,$47; LMS, ANTIC MODE 7 0360 .WORD LINE2; (TEXT LINE: "THE BIG PROGRAM") 0370 .BYTE $70,$42; (LMS, ANTIC MODE 2 [GR.0]) 0380 .WORD LINE3;(TEXT LINE: "By [Your Name]") 0390 .BYTE $70,$70,$70,$70,$46;LMS, ANTIC MODE 6 0400 .WORD LINE4; (TEXT LINE: "PLEASE STAND BY") 0410 .BYTE $70,$70,$70,$70,$70; 5 BLANK LINES 0420 .BYTE $41; JVB INSTRUCTION 0430 .WORD HLIST; TO JUMP BACK TO START OF LIST 0440 ; 0450 ;RUN PROGRAM 0460 ; 0470 INIT NOP; SWITCHING COLOR REGISTERS FOR NICELY COLORED DISPLAY 0480 LDA COLOR3 0490 STA COLOR1 0500 LDA COLOR4 0510 STA COLOR2 0520 ; NOW WE'LL RUN THE PROGRAM 0530 LDA #0 0540 STA SDMCTL; TURN ANTIC OFF FOR A MOMENT ... 0550 LDA #HLIST&; WHILE WE STORE OUR NEW LIST'S ADDRESS 0560 STA SDLSTL; IN THE OS DISPLAY POINTER. 0570 LDA # HLIST/256; NOW FOR THE HIGH BYTE. 0580 STA SDLSTH; NOW ANTIC WILL KNOW OUR NEW ADDRESS 0590 LDA #$22 0600 STA SDMCTL; ... SO WE'LL TURN ANTIC BACK ON NOW 0610 ; 0620 FINI 0630 RTS 0550 is the line that is causing the problem. I figure that the "&" is a typo, but removing it doesn't solve the problem. also I suspect that line 0570 should read "LDA #HLIST/256" without the space. I would appreciate it greatly if someone could tell me if the listing is wrong, and what I can do to fix it. Should line 0550 be loading an immediate value "#" of HLIST into the accumalator???? Thanks Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted October 21, 2004 Share Posted October 21, 2004 255 should follow the & symbol, effectively an AND of the lower half of the address. Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted October 21, 2004 Share Posted October 21, 2004 For 'of' read 'to make' Quote Link to comment Share on other sites More sharing options...
zenassem Posted October 21, 2004 Author Share Posted October 21, 2004 Thanks, I should have been able to figure that out even though it is a few chapters ahead of where I am. I have always had difficulty with understanding related items such as bitmasking, one's & two's compliment operations. Am i correct in saying that to get the lower byte the program uses: HLIST/256 and performs an "AND" operation with 255 (as a mask) to get the upper byte HLIST&255? Embarassing as it is, I tried replacing the "&" with * 256 More embarassing is: I find myself thinking in C or Basic when I am working with 6502 assembly. So when I see an "&" I automatically think I am referencing a pointer or "adress of". Lastly, Is this typo in the actual printed text or is this just a mistake in the online atariarchives version? I have noticed other typos here and there. Is there a way to submit corrections to www.atariarchives.org to fix things like this? Thanks, for alll of your help. It's greatly apprecited. I will try the code later today. ~zen Quote Link to comment Share on other sites More sharing options...
zenassem Posted October 21, 2004 Author Share Posted October 21, 2004 also I don't understand, for 'of' read 'to make' could you clarify for a NOOB? Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted October 22, 2004 Share Posted October 22, 2004 also I don't understand, for 'of' read 'to make' could you clarify for a NOOB? No problem, "effectively an AND of the lower half of the address" should have read: "effectively an AND to make the lower half of the address" Say I want to set the Display List to point to (hex) address $7F20 The AND makes the lower half of the address by masking only the lower 8 bits of this address, i.e. $20 as 256 is 2^8, dividing this address by 256 gives us the value $7F So we can poke address $230 with the (lo) value $20 and address $231 with the (hi) value $7F, e.g. SDLSTL=$230 SDLSTH=$231 my_dlist = $7F20 LDA #my_dlist*255 LDX #my_dlist/256 STA SDLSTL STX SDLSTH Alternatively many assemblers let you use '<' for lo and '>' for hi: LDA # LDX #>my_dlist STA SDLSTL STX SDLSTH Hope that helps :wink: Quote Link to comment Share on other sites More sharing options...
zenassem Posted October 23, 2004 Author Share Posted October 23, 2004 Thank you Wrathchild! (btw, Does your ScrnName have anything to do with the Iron Maiden song of the same?) You have a knack for explaining these things -- Better than some of the explanations I have seen in published books. Have you written any Tutorials? I also appreciate the alternative examples. ~zen Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted October 23, 2004 Share Posted October 23, 2004 Certainly does Dave Murray is one of the main reasons why I still strive to play the guitar (after about 20 years now)! As for tutorials, not really, but I help out where I can From what I can remember of my early experiences of learning 6502, the main thing was to keep experimenting and work through the crashes! Set yourself small targets and then build from there. Later I found that disassembling or working out how a game does something that you like helped see how other programmers did things diferently, i.e. their 'style'. An example of that was 'Elite', which showed me for the first time the use of the 'BIT' command to effectively ignore a the next two bytes of code, here's an example: loc_0_9019: CMP #$3B BEQ loc_0_902B CMP #$3A BEQ loc_0_9028 CMP #$3D BNE loc_0_9030 LDX #3 .BYTE $2C loc_0_9028: LDX #2 .BYTE $2C loc_0_902B: LDX #1 JMP ChangeView Good luck in your projects! Quote Link to comment Share on other sites More sharing options...
Spacewreck Posted May 21, 2018 Share Posted May 21, 2018 Hi folks. I know this is an incredibly old thread, but I am also going through the Atari Roots book and have a question about the code listed above. In particular, I'm confused about the .word directives right in the middle of the DL. Can someone please explain why that's there and what it does? It seems like it would totally mess up the display list. Thanks in advance!! Quote Link to comment Share on other sites More sharing options...
Bill Lange Posted June 26, 2018 Share Posted June 26, 2018 Hi folks. I know this is an incredibly old thread, but I am also going through the Atari Roots book and have a question about the code listed above. In particular, I'm confused about the .word directives right in the middle of the DL. Can someone please explain why that's there and what it does? It seems like it would totally mess up the display list. Thanks in advance!! 0350 .BYTE $70,$70,$70,$70,$47; LMS, ANTIC MODE 7 0360 .WORD LINE2; (TEXT LINE: "THE BIG PROGRAM") In line 350, the last byte, $47, is actually two nibbles. The "4" means LOAD MEMORY SCAN. The "7" means ANTIC MODE 7. The LOAD MEMORY SCAN is a 3-byte command. So typically, the $47 would be followed by a two byte address such as $47,$20, $7C ... with the data to be displayed beginning at address $7C20 ($20, $7C). In this case, line 360, says to look at the two byte address (a two byte .WORD instead of a one byte .BYTE) LINE2 to find the data to be displayed. It is just using a label instead explicit memory address to find the data to display. If you had pre-stored the data for the text string beginning at memory address $7C20, you could have deleted line 360 and just used 350 .BYTE $70,$70,$70,$70,$47,$20,$7C The LOAD MEMORY SCAN just needs to know where the data to be displayed is. You can provide the address in different ways. Bill 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.