Welcome, Guest. Please login or register.

Author Topic: Devpac 3 SECTION directive  (Read 126 times)

Description:

0 Members and 2 Guests are viewing this topic.

Offline AmigaBrunoTopic starter

Devpac 3 SECTION directive
« on: April 05, 2024, 01:29:35 PM »
Back in the 1990s, I bought a copy of Devpac for my Amiga A500, but for some strange reason I never got very far with it. I remember reading a book about 68000 Assembly Language with a light blue and yellow cover, as well as the Amiga Hardware Manual and various magazine articles.

I'm currently using an A1200 with 10Mb RAM with Kickstart 3.0 (V39) and Workbench 3.0. A few days ago, I asked Chat GPT to create an Assembly Language program for the Amiga using Devpac syntax which prints out a message 20 times. This program is listed below. As expected, it generated several errors. I managed to debug all but two of these errors, which were using the syntax 0x to indicate Hexadecimal numbers. I just deleted the 0x, but now I think I should probably type $ to replace these before I can get the program to compile.

There are another two errors which I can't debug, in spite of reading the relevant section of the manual, though. This is the SECTION directive, used three times in this program. It seems to be essential for certain types of data, otherwise different errors are generated, such as "not defined". I solved the problem with the first use of SECTION, by changing it to SECTION TEXT, TEXT but the usage of TEXT before the comma can't be repeated for the other two occurrences of SECTION, otherwise it causes errors. TEXT1, TEXT2, and TEXT3 can't be used without causing errors either. All other names I've tried cause errors as well. Can someone debug this for me? I've pasted the original version below without my corrections of deleting all occurrences of 0x, and inserting a $ in front of a clearly Hexadecimal number. Of course, this program could be easily written in C, but I'm trying to learn more about 68000 Assembly Language.


Amiga Assembler Print Message 20 Times in Devpac with key press required after each time

    SECTION   Text, CODE
   
start:
    ; Initialize system
    move.l #0,-(sp)     ; Clear stack pointer
    move.w #$4e75,sr    ; Clear interrupts
    move.l #$2,A6       ; Set up supervisor stack
    jsr -198(A6)        ; Open graphics library
    move.l d0,GraphicsBase  ; Save graphics library base

    ; Open graphics screen
    move.l #640,d0      ; Screen width
    move.l #200,d1      ; Screen height
    move.l #0,d2        ; Display mode (0 for default)
    move.l #3,d3        ; Bitplanes (3 for 8-bit color)
    jsr -90(A6)         ; Open screen
    move.l d0,Screen   ; Save screen pointer

    ; Get screen bitmap
    move.l Screen.w,d0 ; Get screen pointer
    move.l d0,d1       ; Save screen pointer

    ; Clear screen
    move.l Screen,d0   ; Get screen pointer
    moveq #0,d1
    moveq #128,d2
    move.l d0,d3
    jsr -126(A6)        ; Clear display

    ; Set up font
    move.l d1,d0       ; Get screen pointer
    jsr -132(A6)       ; Open font library
    move.l d0,FontBase ; Save font library base

    ; Set up text color
    move.l #2,d1       ; Text color (2 for yellow)

    ; Loop to print message 20 times
    moveq #0,d0
print_loop:
    move.l #TextPos,d0 ; Text position
    jsr -0x80(A6)      ; Set up text position

    ; Print message
    lea Message(pc),a0 ; Load address of message
    jsr -0xc6(A6)      ; Print text

    ; Wait for a key press
    jsr -0x132(A6)     ; Wait for a key press

    ; Increment loop counter
    addq.l #1,d0
    cmp.l #20,d0       ; Check if printed 20 times
    bne print_loop     ; If not, loop back to print more

    ; Close font library
    move.l FontBase,A6
    jsr -138(A6)       ; Close font library

    ; Close graphics screen
    move.l Screen.w,d0 ; Get screen pointer
    move.l d0,d1       ; Save screen pointer
    move.l d1,d0       ; Get screen pointer
    jsr -96(A6)        ; Close screen

    ; Close graphics library
    move.l GraphicsBase,A6
    jsr -0x102(A6)     ; Close graphics library

    ; Terminate program
    moveq #0,d0
    moveq #0,d1
    move.w #0x4e75,sr ; Return to Workbench

    SECTION   Data, DATA

Message:
    DC.B "Hello, Amiga World!",0

    SECTION   BSS, DATA

Screen:
    DS.L 1
FontBase:
    DS.L 1
GraphicsBase:
    DS.L 1
TextPos:
    DS.L 2
 
« Last Edit: April 05, 2024, 01:34:36 PM by AmigaBruno »