;)
This commit is contained in:
@@ -184,9 +184,9 @@ assemble:
|
||||
.operator_1_memory_access:
|
||||
push rsi
|
||||
mov rsi, .msg_operator_1_memory_access
|
||||
call print.error
|
||||
call print.debug
|
||||
pop rsi
|
||||
jmp halt
|
||||
jmp .unsupported_memory_access
|
||||
|
||||
.operator_1_register:
|
||||
push rsi
|
||||
@@ -254,9 +254,9 @@ assemble:
|
||||
.operator_2_memory_access:
|
||||
push rsi
|
||||
mov rsi, .msg_operator_2_memory_access
|
||||
call print.error
|
||||
call print.debug
|
||||
pop rsi
|
||||
jmp halt
|
||||
jmp .unsupported_memory_access
|
||||
|
||||
.operator_2_register:
|
||||
push rsi
|
||||
@@ -299,9 +299,38 @@ assemble:
|
||||
.operator_2_register_memory_access:
|
||||
push rsi
|
||||
mov rsi, .msg_operator_2_register_memory_access
|
||||
call print.error
|
||||
call print.debug
|
||||
pop rsi
|
||||
jmp halt
|
||||
|
||||
cmp di, 0x1000 ; check if token is addressing to a register
|
||||
jne .unsupported_memory_access ; if not, unsupported :/
|
||||
|
||||
pop rax
|
||||
pop rdi
|
||||
inc rax
|
||||
cmp rax, rdi
|
||||
jge .break
|
||||
push rdi
|
||||
push rax
|
||||
xor edi, edi
|
||||
mov di, [rax * TOKEN_TABLE_ENTRY_SIZE + TOKEN_TABLE_ADDR] ; di = next tte
|
||||
|
||||
; si = `R/M` tte
|
||||
; di = `reg` tte
|
||||
push rsi
|
||||
mov si, di
|
||||
pop rdi
|
||||
mov dl, 00b ; dl = mod bits
|
||||
call get_ModRM
|
||||
; al = Mod R/M byte
|
||||
call .output_byte
|
||||
|
||||
pop rax ; rax = number of tokens processed
|
||||
pop rdi ; rdi = total number of tokens
|
||||
inc rax
|
||||
cmp rax, rdi
|
||||
jge .break
|
||||
jmp .loop
|
||||
|
||||
.operator_2_register_register:
|
||||
push rsi
|
||||
@@ -311,6 +340,9 @@ assemble:
|
||||
|
||||
; si = `R/M` tte
|
||||
; di = `reg` tte
|
||||
push rsi
|
||||
mov si, di
|
||||
pop rdi
|
||||
mov dl, 11b ; dl = mod bits
|
||||
call get_ModRM
|
||||
; al = Mod R/M byte
|
||||
@@ -331,6 +363,11 @@ assemble:
|
||||
call print.error
|
||||
jmp halt
|
||||
|
||||
.unsupported_memory_access:
|
||||
mov rsi, .msg_unsupported_memory_access
|
||||
call print.error
|
||||
jmp halt
|
||||
|
||||
; procedures
|
||||
|
||||
; al = byte to write
|
||||
@@ -343,7 +380,8 @@ assemble:
|
||||
.next_output_byte dd OUTPUT_ADDR ; next empty byte in output
|
||||
; TODO get rid of this sketchy bit of state
|
||||
|
||||
.msg_unexpected_token db "unexpected token while assembling, aborting", 0x0A, 0x00
|
||||
.msg_unexpected_token db "unexpected token, aborting", 0x0A, 0x00
|
||||
.msg_unsupported_memory_access db "unsupported memory access, aborting", 0x0A, 0x00
|
||||
.msg_operator_0 db "operator_0", 0x0A, 0x00
|
||||
.msg_operator_1 db "operator_1", 0x0A, 0x00
|
||||
.msg_operator_1_memory_access db "operator_1_memory_access", 0x0A, 0x00
|
||||
@@ -1677,7 +1715,7 @@ opcodes:
|
||||
db 0x00 ; reserved
|
||||
|
||||
dw 0x0056 ; mov
|
||||
db 0x89
|
||||
db 0x8B
|
||||
db 0x00 ; reserved
|
||||
|
||||
dw 0x004F ; hlt
|
||||
@@ -1695,6 +1733,7 @@ program:
|
||||
db "xor eax, eax", 0x0A
|
||||
db "inc rax ; inline comment", 0x0A
|
||||
db "; one line comment", 0x0A
|
||||
db "mov rdx, [rax]", 0x0A
|
||||
db "mov [rax], rdx", 0x0A
|
||||
db "hlt", 0x0A ; TODO make it so it doesn't need to end with a newline; this
|
||||
; would mean range checking members in operator/operand/com-
|
||||
|
||||
Reference in New Issue
Block a user