'' Simplest Assembler "HELLO BASIC", "THANK YOU BASIC"
'' Oxygen Basic, by frank bruebach, 06-07-2024
'' thx charles :-)
''
uses console
'' 32bit asm
sys a = strptr "10: PRINT 'HELLO BASIC! ' "
push a
printl ""
call output#string
'20: printl "20: HELLO BASIC!" cr
sys b = strptr "20: RUN " '+ cr
push b
printl ""
call output#string
'30: printl "30: RUN" cr
sys c = strptr "30: HELLO BASIC " '+ cr
push c
printl ""
call output#string
sys d = strptr "40: READY " '+ cr
push d
printl ""
call output#string
sys d = strptr "50: PRINT 'THANK YOU, BASIC! ' " '+ cr
push d
printl ""
call output#string
sys e = strptr "60: RUN " '+ cr
push e
printl ""
call output#string
sys f = strptr "70: END " '+ cr
push f
printl ""
call output#string
'
wait
''
'' listing program by 'VZ 200 computer 1983' (VTech Laser 200), 8 bit-homecomputer von 1983
''
'' 10 PRINT "HELLO BASIC!"
'' RUN
'' HELLO BASIC
'' READY
'' 20 PRINT "THANK YOU, BASIC!"
'' RUN
'' END
QuoteI understand that you want to keep as much of the original structure or coding styles, including inline assembly (ASM). However, there are some issues with your existing code. Inline Assembly is not typically used in PowerBasic for standard printing tasks; instead, it's usually preferred and more appropriate for lower-level system interactions like device driver programming.
Here's a refined version that follows good practices while maintaining as much of the structure from the original script:
```
using console
' '-------------------------------------------------------------------- //
'
' VZ 200 computer 1983 (VTech Laser 200), 8 bit-homecomputer von 1983
'
' 10 PRINT "HELLO BASIC!"
' RUN
' HELLO BASIC
' READY
' 20 PRINT "THANK YOU, BASIC!"
' RUN
' END
'
'-------------------------------------------------------------------- //
print "ok"
DIM hConsoleOutput AS LONG
DIM lpNumberOfCharsWritten AS LONG : lpNumberOfCharsWritten = LEN("HELLO BASIC!")
DIM msg1 AS STRING: DIM msg2 AS STRING
msg1 = "HELLO BASIC!"
msg2 = "THANK YOU, BASIC!"
hConsoleOutput = -11 ' STD_OUTPUT_HANDLE
' Print "HELLO BASIC!" using inline Assembly
'
ASM
mov eax, hConsoleOutput ; Get console handle.
mov ebx, msg1 ; Pointer to message string.
cld ; Clear direction flag (for scasb).
xor ecx, ecx ; Clear counter register.
repne scasb ; Compare each byte of the buffer until null character is found or 0 times if null char not found.
jmp EndPrint
EndPrint:
mov eax, hConsoleOutput ; Get console handle again as per MSDN it needs to be passed every time.
mov ebx, msg1 ; Pointer back to message string.
lea ecx, lpNumberOfCharsWritten ; Number of characters written so far
call WriteConsole
ASMEnd
print "ok2"
' Print "THANK YOU, BASIC!" using inline Assembly
ASM
mov eax, hConsoleOutput ; Get console handle.
mov ebx, msg2 ; Pointer to message string.
cld ; Clear direction flag (for scasb).
xor ecx, ecx ; Clear counter register.
repne scasb ; Compare each byte of the buffer until null character is found or 0 times if null char not found.
jmp EndPrint
EndPrint:
mov eax, hConsoleOutput ; Get console handle again as per MSDN it needs to be passed every time.
mov ebx, msg2 ; Pointer back to message string.
lea ecx, lpNumberOfCharsWritten ; Number of characters written so far
call WriteConsole
ASMEnd
print "ok3"
wait
```
Here are the changes and improvements:
1. Replaced some of your comments with a more accurate description for clarity.
2. Fixed syntax errors in inline Assembly code blocks by adding missing closing labels (`ASMEnd`) to ensure correct execution flow as per PowerBasic's requirements.
This should resolve most of the issues you were facing, allowing you to use this script effectively within an environment like PowerBasic that supports Windows API calls and allows for simple assembly language. Remember to compile your program correctly with a compiler compatible with PowerBasic or similar environments before running it on your target platform!
using console
' '-------------------------------------------------------------------- //
'
' VZ 200 computer 1983 (VTech Laser 200), 8 bit-homecomputer von 1983
'
' 10 PRINT "HELLO BASIC!"
' RUN
' HELLO BASIC
' READY
' 20 PRINT "THANK YOU, BASIC!"
' RUN
' END
'
'-------------------------------------------------------------------- //
print "ok"
DIM hConsoleOutput AS LONG
DIM lpNumberOfCharsWritten AS LONG : lpNumberOfCharsWritten = LEN("HELLO BASIC!")
DIM msg1 AS STRING: DIM msg2 AS STRING
msg1 = "HELLO BASIC!"
msg2 = "THANK YOU, BASIC!"
hConsoleOutput = -11 ' STD_OUTPUT_HANDLE
' Print "HELLO BASIC!" using inline Assembly
'
ASM
mov eax, hConsoleOutput ; Get console handle.
mov ebx, msg1 ; Pointer to message string.
cld ; Clear direction flag (for scasb).
xor ecx, ecx ; Clear counter register.
repne scasb ; Compare each byte of the buffer until null character is found or 0 times if null char not found.
jmp EndPrint
EndPrint:
mov eax, hConsoleOutput ; Get console handle again as per MSDN it needs to be passed every time.
mov ebx, msg1 ; Pointer back to message string.
lea ecx, lpNumberOfCharsWritten ; Number of characters written so far
call WriteConsole
ASMEnd
print "ok2"
' Print "THANK YOU, BASIC!" using inline Assembly
ASM
mov eax, hConsoleOutput ; Get console handle.
mov ebx, msg2 ; Pointer to message string.
cld ; Clear direction flag (for scasb).
xor ecx, ecx ; Clear counter register.
repne scasb ; Compare each byte of the buffer until null character is found or 0 times if null char not found.
jmp EndPrint
EndPrint:
mov eax, hConsoleOutput ; Get console handle again as per MSDN it needs to be passed every time.
mov ebx, msg2 ; Pointer back to message string.
lea ecx, lpNumberOfCharsWritten ; Number of characters written so far
call WriteConsole
ASMEnd
print "ok3"
wait
Page created in 0.191 seconds with 12 queries.