; ---- Start Code for Ultrabasic
; ---- Gabriel Fernandez
; ---- You are not allowed to use this code without permission
[BITS 32]
[section .text]
GLOBAL _WdosxStart
_WdosxStart:

Align 4

MOV AX, DS
MOV ES, AX

; LOAD THE COMMAND LINE AND THE EXE PATH

mov ebx, exepath
mov edx, 0

DEC ESI
Mov eax, [edi]
add edi, 4
CNextChar1:
  inc edx
  mov cl, [eax]
  mov [ebx], cl
  inc ebx
  inc eax
  cmp cl, 0
JNE CNextChar1

DEC edx
mov [exepathlen], edx

mov ebx, commandline
mov edx, 0

CMP ESI, 0
JE Skipcommand
NextCommand:
  DEC ESI
  Mov eax, [edi]
  add edi, 4
CNextChar2:
    inc edx
    mov cl, [eax]
    mov [ebx], cl
    inc ebx
    inc eax
    cmp cl, 0
    JNE CNextChar2
  CMP esi, 0
JNE NextCommand

DEC EDX
Skipcommand:
mov [commandlen], edx

; -----------------------------------

mov eax, 0500h
int 10h

mov ah, 1
mov ch, 20h
int 10h

mov ebx, 0
mov ah, 3
int 10h
; mov dx, 0101h
mov [textx], dl
mov [texty], dh
mov [cursorshape], cx