Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Illegal instructions:section. data or wrong parameters
Illegal instructions:section. bss or wrong parameters
Illegal instructions:section. text or wrong parameters
Illegal instructions:section. start or wrong parameters
Wrong parameters :MOV edx, maze
Undefined var:edx

What I have tried:

section .data
    maze db '#########', 10
         db '#     # #', 10
         db '# ### # #', 10
         db '# #   # #', 10
         db '# # ### #', 10
         db '#     # #', 10
         db '#########', 10
         db 'Time left: $'
    mazeWidth equ 9
    mazeHeight equ 7
    playerX db 1
    playerY db 1
    timer dw 30 ; 30 seconds timer

section .bss
    oldTimer dw 1 resb

section .text
    global _start

_start:
    ; Initialize the game
    call drawMaze
    call startTimer

gameLoop:
    ; Check for keyboard input
    call getInput
    ; Update the game state
    call updateGame
    ; Check if the timer has run out
    call checkTimer
    ; Loop back to the start of the game loop
    jmp gameLoop

drawMaze:
    ; Draw the maze to the screen
    mov edx, maze
    call printString
    ret

printString:
    ; Print a null-terminated string pointed to by EDX
    mov eax, 4
    mov ebx, 1
    int 0x80
    ret

getInput:
    ; Get keyboard input and update player position
    ; This is a placeholder for actual input handling
    ; You would need to implement keyboard interrupt handling
    ret

updateGame:
    ; Update the game state, move the player, etc.
    ; This is a placeholder for actual game logic
    ret

checkTimer:
    ; Check if the timer has run out
    mov ax, [timer]
    cmp ax, 0
    je gameOver
    ret

startTimer:
    ; Set up the timer interrupt
    ; This is a placeholder for actual timer setup
    ret

gameOver:
    ; End the game and display game over message
    mov edx, gameOverMsg
    call printString
    ; Exit the game
    mov eax, 1
    int 0x80

gameOverMsg db 'Game Over!', 10, '$'
Posted
Comments
Richard MacCutchan 4-Feb-24 8:04am    
You are either using an incorrect assembler, or not including ceertain required options on the command line. Please provide more information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900