flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Super Powerful 64 bit OS Header, LOADED!

Author
Thread Post new topic Reply to topic
mbr_tsr



Joined: 03 Apr 2011
Posts: 4903
mbr_tsr
Code:

;64Bit IRQ Demo Updated May 10, 2013

;int BF = AH=0 AL=IRQ# (IRQ# is 0 to F) Execute IRQ dq Hex Quad Word as Code
;int BF = AH=1 AL=IRQ# (Get IRQ) Returns ES:DI Pointer to IRQ (4 hex words)
;int BF = AH=2 AL=IRQ# (Display IRQ) Dump the IRQ To Screen as a HEX String
;int BF = AH=3 AL=IRQ# (Inject IRQ) DS:SI=4 word hex code
;int BF = AH=4 AL=IRQ# Trigger/Set an IRQ (Prints Purpose of IRQ)
;int BF = AH=5 AL=IRQ# Set the Current IRQ (operation phase)
;int BF = AH=6 Get the Current IRQ (operation phase) Returns AL=IRQ#
;int BF = AH=7 AL=IRQ# CX=Count (Add a number to an IRQ) Returns IRQ
;int BF = AH=8 AL=IRQ# CX=Count (Subtract a number to an IRQ) Returns IRQ
;int BF = AH=9 AL=IRQ# (Grab IRQ Number) Returns EBX:ECX
;int BF = AH=A AL=IRQ# (Post IRQ Number) Sets IRQ# To EBX:ECX
;int BF = AH=B AL=IRQ# Set Any 8 Byte IRQ to 00000000
;int BF = AH=C AL=IRQ# BH=Byte# BL=hex (Set IRQ Byte# 1 to 8 as Hex)
;int BF = AH=D AL=IRQ# EDX=Key (Encrypt/Decrypt IRQ)
;int BF = AH=E AL=IRQ# (Show IRQ) Display IRQ as Plain Text

Org 0x0100

jmp StartDemo
CurrentIRQ db 0
IRQ0RR dq 0x9090909090909090   ;IRQ0 = COM#/AUX#/LPT#/USB#/PS2/JOY STICK
IRQ1RR dq 0x9090909090909090   ;IRQ1 = CD/DVD/Floppy/USB/Hard Drive/Disk
IRQ2RR dq 0x9090909090909090   ;IRQ2 = Hardware/Video/Sound/Keyboard/Mouse
IRQ3RR dq 0x9090909090909090   ;IRQ3 = Imagination/Creativity/Spiritual
IRQ4RR dq 0x9090909090909090   ;IRQ4 = Error/Mistake/Invalid Link/Failure
IRQ5RR dq 0x9090909090909090   ;IRQ5 = Win/Amaze/Treasure/AweWow/Fantasy
IRQ6RR dq 0x9090909090909090   ;IRQ6 = Device/Connect/Transfer/Data/OS
IRQ7RR dq 0x9090909090909090   ;IRQ7 = FAT12/FAT32/NTFS/File System/Root
IRQ8RR dq 0x9090909090909090   ;IRQ8 = Math/Logic/Text/Output/Results
IRQ9RR dq 0x9090909090909090   ;IRQ9 = Internet/Client/Server/Packets
TxtIRQ dq "FILENAME"           ;IRQA = FileName
DecIRQ dq 9999999999999999999  ;IRQB = Decimal Max
MaxIRQ dq 0xFFFFFFFFFFFFFFFF   ;IRQC = Hex Max
MinIRQ dq 0x0000000000000000   ;IRQD = Dec/Hex 0
OneIRQ dq 0x0000000000000001   ;IRQE = Dec/Hex 1
ExeIRQ dq 0xB40EB003CD100000   ;IRQF = For Int 0xBF (Execute IRQ as HEX)
StartDemo:

push cs
pop  ds

mov  dx, IntBF
mov  al, 0xBF
call SetV

;Display 64bit IRQ as Hex
mov ah, 0x02
mov al, 0x0F ;IRQ#
int 0xBF

;Execute 64bit IRQ as Code
mov ah, 0x00
mov al, 0x0F ;IRQ#
int 0xBF

mov  ah, 0x4C
int  0x21

IntBF:
cmp ah, 0
je RunIRQ
cmp ah, 1
je GetIRQ
cmp ah, 2
je PrintIRQ
cmp ah, 3
je InjectIrq
cmp ah, 4
je TriggerIrq
cmp ah, 5
je SetIrq
cmp ah, 6
je GetIrq
cmp ah, 7
je AddIrq
cmp ah, 8
je SubIrq
cmp ah, 9
je GrabIrq
cmp ah, 0x0A
je PostIrq
cmp ah, 0x0B
je ResetIrq
cmp ah, 0x0C
je SetIrqByte
cmp ah, 0x0D
je CryptIrq
cmp ah, 0x0E
je ShowIRQ

jmp NoIrq

RunIRQ:
push ax
push bx
push cx
push dx
push ds
push es
push bp
push di
push si
push cs
pop es
push cs
pop ds
mov si, IRQ0RR
mov ah, 0
mov cx, 0x0008
mov dx, 0
mul cx
add si, ax
mov di, BuffIRQExe
lodsw
xchg ah, al
mov word [cs:BuffIRQExe+4], ax
lodsw
xchg ah, al
mov word [cs:BuffIRQExe+6], ax
lodsw
xchg ah, al
mov word [cs:BuffIRQExe+0], ax
lodsw
xchg ah, al
mov word [cs:BuffIRQExe+2], ax
BuffIRQExe:
dw 0x9090
dw 0x9090
dw 0x9090
dw 0x9090
pop si
pop di
pop bp
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
jmp NoIrq

GetIRQ:
push ax
push bx
push cx
push dx
push ds
push bp
push si
push cs
pop ds
mov si, IRQ0RR
mov ah, 0
mov cx, 0x0008
mov dx, 0
mul cx
add si, ax
mov di, si
push cs
pop es
pop si
pop bp
pop ds
pop dx
pop cx
pop bx
pop ax
jmp NoIrq

PrintIRQ:
push ax
push bx
push cx
push dx
push ds
push es
push bp
push di
push si
push ax
push bx
mov  bx, 000fh
mov  al, '['
call putc
pop bx
pop ax
push cs
pop es
push cs
pop ds
mov si, IRQ0RR
mov ah, 0
mov cx, 0x0008
mov dx, 0
mul cx
add si, ax
lodsw
mov word [cs:Irq2Hex+6], ax
lodsw
mov word [cs:Irq2Hex+4], ax
lodsw
mov word [cs:Irq2Hex+2], ax
lodsw
mov word [cs:Irq2Hex+0], ax
mov cx, 4h
mov bx, 0
PrintIrqLoop:
mov ax, word [cs:Irq2Hex+BX]
call PrintAX
add bx, 2
loop PrintIrqLoop
push ax
push bx
mov  bx, 000fh
mov  al, ']'
call putc
pop bx
pop ax
pop si
pop di
pop bp
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
jmp NoIrq

InjectIrq:
push ax
push bx
push cx
push dx
push ds
push es
push bp
push di
push si
push cs
pop es
mov di, IRQ0RR
mov ah, 0
mov cx, 0x0008
mov dx, 0
mul cx
add di, ax
lodsw
xchg ah, al
mov word [es:di+6], ax
lodsw
xchg ah, al
mov word [es:di+4], ax
lodsw
xchg ah, al
mov word [es:di+2], ax
lodsw
xchg ah, al
mov word [es:di+0], ax
pop si
pop di
pop bp
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
jmp NoIrq

TriggerIrq:
mov byte [cs:CurrentIRQ], AL
push si
push ds
push cs
pop ds
mov si, TheIrqList
call PointP
call Show
pop ds
pop si
jmp NoIrq

SetIrq:
mov byte [cs:CurrentIRQ], AL
jmp NoIrq

GetIrq:
mov AL, byte [cs:CurrentIRQ]
jmp NoIrq

AddIrq:
cmp cx, 0
je NoIrq
int 0xEA
push ax
mov BP,CX
mov ah, 9
int 0xBF
mov EAX, ECX
CXAdd:
mov ECX, EAX
cmp ECX, 0xFFFFFFFF
jne NotECXMax
mov ECX, 0x00000000
inc EBX
jmp SkewSwish1
NotECXMax:
inc ECX
SkewSwish1:
mov EAX, ECX
mov CX,BP
dec BP
loop CXAdd
mov ECX, EAX
pop ax
mov ah, 0x0A
int 0xBF
int 0xEB
jmp NoIrq

SubIrq:
cmp cx, 0
je NoIrq
int 0xEA
push ax
mov BP,CX
mov ah, 9
int 0xBF
mov EAX, ECX
CXSub:
mov ECX, EAX
cmp ECX, 0x00000000
jne NotEBXMin
mov ECX, 0xFFFFFFFF
dec EBX
jmp SkewSwish2
NotEBXMin:
dec ECX
SkewSwish2:
mov EAX, ECX
mov CX,BP
dec BP
loop CXSub
mov ECX, EAX
pop ax
mov ah, 0x0A
int 0xBF
int 0xEB
jmp NoIrq

GrabIrq:
push ax
push dx
push si
push ds
push cs
pop ds
mov esi, 0
mov si, IRQ0RR
mov ah, 0
mov cx, 0x0008
mov dx, 0
mul cx
add si, ax
lodsd
push eax
lodsd
push eax
pop ebx
pop ecx
pop ds
pop si
pop dx
pop ax
jmp NoIrq

PostIrq:
int 0xEA
push ebx
push ecx
push cs
pop es
mov edi, 0
mov di, IRQ0RR
mov ah, 0
mov cx, 0x0008
mov dx, 0
mul cx
add di, ax
pop eax
pop ebx
stosd
xchg eax, ebx
stosd
int 0xEB
jmp NoIrq

ResetIrq:
push ax
push ebx
push ecx
mov ah, 0x09
int 0xBF
mov EBX, 0
mov ECX, 0
mov ah, 0x0A
int 0xBF
pop ecx
pop ebx
pop ax
jmp NoIrq

SetIrqByte:
push ax
push bx
push cx
push dx
push ds
push es
push bp
push di
push si

push ax
cmp bh, 1
jne BHNot1
mov di, MyHexSerum1
BHNot1:
cmp bh, 2
jne BHNot2
mov di, MyHexSerum2
BHNot2:
cmp bh, 3
jne BHNot3
mov di, MyHexSerum3
BHNot3:
cmp bh, 4
jne BHNot4
mov di, MyHexSerum4
BHNot4:
cmp bh, 5
jne BHNot5
mov di, MyHexSerum5
BHNot5:
cmp bh, 6
jne BHNot6
mov di, MyHexSerum6
BHNot6:
cmp bh, 7
jne BHNot7
mov di, MyHexSerum7
BHNot7:
cmp bh, 8
jne BHNot8
mov di, MyHexSerum8
BHNot8:
push cs
pop es
mov al, bl
stosb
pop ax
push cs
pop ds
mov AH, 0x03
mov si, MyHexSerum1
int 0xBF
pop si
pop di
pop bp
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
jmp NoIrq

CryptIrq:
push ax
push ebx
push ecx
mov ah, 0x09
int 0xBF
xor ebx, edx
xor ecx, edx
mov ah, 0x0A
int 0xBF
pop ecx
pop ebx
pop ax
jmp NoIrq

ShowIRQ:
push ax
push bx
push cx
push dx
push ds
push es
push bp
push di
push si
push cs
pop es
push cs
pop ds
mov si, IRQ0RR
mov ah, 0
mov cx, 0x0008
mov dx, 0
mul cx
add si, ax
lodsw
mov word [cs:Irq2Hex+6], ax
lodsw
mov word [cs:Irq2Hex+4], ax
lodsw
mov word [cs:Irq2Hex+2], ax
lodsw
mov word [cs:Irq2Hex+0], ax
mov cx, 4h
mov bx, 0
ShowIrqLoop:
mov ax, word [cs:Irq2Hex+BX]
call PrintAXTxt
add bx, 2
loop ShowIrqLoop
pop si
pop di
pop bp
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
jmp NoIrq

TheIrqList:
db "IRQ0 = COM#/AUX#/LPT#/USB#/PS2/JOY STICK",0
db "IRQ1 = CD/DVD/Floppy/USB/Hard Drive/Disk",0
db "IRQ2 = Hardware/Video/Sound/Keyboard/Mouse",0
db "IRQ3 = Imagination/Creativity/Spiritual",0
db "IRQ4 = Error/Mistake/Invalid Link/Failure",0
db "IRQ5 = Win/Amaze/Treasure/AweWow/Fantasy",0
db "IRQ6 = Device/Connect/Transfer/Data/OS",0
db "IRQ7 = FAT12/FAT32/NTFS/File System/Root",0
db "IRQ8 = Math/Logic/Text/Output/Results",0
db "IRQ9 = Internet/Client/Server/Packets",0
db "IRQA = TxtIRQ FileName",0
db "IRQB = DecIRQ Decimal Max",0
db "IRQC = MaxIRQ Hex Max",0
db "IRQD = MinIRQ Dec/Hex 0",0
db "IRQE = OneIRQ Dec/Hex 1",0
db "IRQF = ExeIRQ For Int 0xBF (Execute IRQ as HEX)",0

MyHexSerum1 db 0
MyHexSerum2 db 0
MyHexSerum3 db 0
MyHexSerum4 db 0
MyHexSerum5 db 0
MyHexSerum6 db 0
MyHexSerum7 db 0
MyHexSerum8 db 0


NoIrq:
iret

SetV:
pusha
push ds
push es
cli
xor  bx, bx
mov  es, bx
mov  bl, 4
mul  bl
mov  bx, ax
mov  word [es:bx], dx
add  bx, 2
mov  word [es:bx], ds
sti
pop es
pop ds
popa
ret

putc:
mov  ah, 0x0e
mov  bx, 0x0007
int  0x10
ret

PrintAX:
push AX
push BX
push CX
push DX
mov  CX, 2
Prax:
xchg AH, AL
push AX
push CX
MOV  CL,10h
MOV  AH,0
DIV  CL
ADD  AL,30h
ADD  AH,30h
CMP  AL,'9'
JBE  pCA4B
ADD  AL,7
pCA4B:
CMP  AH,'9'
JBE  pCA5B
ADD  AH,7
pCA5B:
mov  CX,AX
mov  al,CL
mov  ah, 0eh
mov  bh, 0
mov  bl, 1
int  10h
mov  al,CH
mov  ah, 0eh
mov  bh, 0
int  10h
pop  CX
pop  AX
loop Prax
pop  DX
pop  CX
pop  BX
pop  AX
ret

PointP:
push AX
push CX
push DX
mov  DL, AL
mov  CX, 64000
cmp  DL, 0
je   cAllOverPc
cCounterLoopc:
cmp  byte [DS:SI], 0
jne  cNotUpCountc
inc  SI
dec  DL
cmp  DL, 0
je   cAllOverPc
cNotUpCountc:
inc SI
loop cCounterLoopc
cAllOverPc:
pop  DX
pop  CX
pop  AX
Int 0xE8
ret

Show:
push ax
push bx
push si
Show1:
lodsb
cmp  al, 0
je   Okay
mov  ah, 0x0E
mov  bh, 0x00
mov  bl, 0x07
int  0x10
jmp  Show1
Okay:
pop  si
pop  bx
pop  ax
ret

PrintAXTxt:
push ax
push bx
mov bx, ax
mov ah, 0x0E
mov al, bh
int 0x10
mov ah, 0x0E
mov al, bl
int 0x10
pop bx
pop ax
ret

Irq2Hex:
dw 0x9090
dw 0x9090
dw 0x9090
dw 0x9090

    


Last edited by mbr_tsr on 11 May 2013, 00:14; edited 2 times in total
Post 07 Jul 2012, 03:51
View user's profile Send private message Reply with quote
mbr_tsr



Joined: 03 Apr 2011
Posts: 4903
mbr_tsr
in TheCode1 there are two nul byes, it works, yet sorry, replace them with 9090, so you don't execute zeros as code, plus if there is a demand, i can add and subtract CX from a dq word, and i know lots of little tricks with them, using butterfly decoding.
Post 07 Jul 2012, 23:36
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
there are easier ways to implement S.M.C.. that said, there are pipeline issues that render such Immediate SMC impossible to execute correctly (edit: in general). atleast half of Mathis (the "ORB" collection) is a collection of SMC Templates so my code is quite mature in the field of SMC.
Post 08 Jul 2012, 04:13
View user's profile Send private message Visit poster's website Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
you can push the data onto the stack and call (r/e)sp. either put a "ret length+3" instruction at the end of the code that is stored on the stack or add the length to the stack pointer. using the stack in such a way helps to block the procesor from caching the modified code into the Execution Unit pipeline.

if you want to execute an indeterminate Interrupt Vector (such as "int al")

Code:
and  eax, 0xFF
shl  eax, 8
add  eax, 0x08C300CD;the CD is the int opcode, the 00 is room for al. the C3 is the ret instruction.
push 0;zero extend for the "ret"
push eax
call esp    
Post 08 Jul 2012, 04:43
View user's profile Send private message Visit poster's website Reply with quote
mbr_tsr



Joined: 03 Apr 2011
Posts: 4903
mbr_tsr
that is only 32 bit, this is 64, that is twice the size of eax, and with my technique, even a 486 can run on 64 bit, using dq, so you can make a whole OS using all 64 bit, endless functions to swap, filter, process, compare, and convert them, like i did in my ConeHead OS, and try to inc a double quad hex word in Fasm, you can't, unless you do the butterfly effect, once that is mastered, then everything comes like magic.
Post 23 Jul 2012, 02:10
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
first of all; you've severely changed the content of your first post.

second; it's not a 64-bit OS. it's just a collection of extended arithmetic functions using absurd levels of complexity.
Post 24 Jul 2012, 03:22
View user's profile Send private message Visit poster's website Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
mbr_tsr wrote:
that is only 32 bit, this is 64, that is twice the size of eax

Technically, the data that was pushed onto the stack is 8 bytes. so yes it does execute a qword in memory as code.
mbr_tsr wrote:
, and with my technique, even a 486
the 486 is a native 32bit processor.
Post 24 Jul 2012, 11:51
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.