	bits 64
	jmp rcx
	call [rax]
	call qword [rdx]

;Testname=test; Arguments=-fbin -ojmp64.bin; Files=.stdout .stderr jmp64.bin

	bits 64
	jmp rcx
	jmp [rax]
	jmp qword [rax]
	jmp far [rax]
	jmp far dword [rax]
	jmp far qword [rax]
	call rcx
	call [rax]
	call qword [rax]
	call far [rax]
	call far dword [rax]
	call far qword [rax]

Add more 64-bit jump tests

Add more 64-bit jump tests


;;----------------------------------------------------------------------------;;
;;  Align the position of the textbox in the effect of items
;;  Copyright 2014 Benito Palacios (aka pleonex)
;;
;;  Licensed under the Apache License, Version 2.0 (the "License");
;;  you may not use this file except in compliance with the License.
;;  You may obtain a copy of the License at
;;
;;      http://www.apache.org/licenses/LICENSE-2.0
;;
;;  Unless required by applicable law or agreed to in writing, software
;;  distributed under the License is distributed on an "AS IS" BASIS,
;;  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;  See the License for the specific language governing permissions and
;;  limitations under the License.
;;----------------------------------------------------------------------------;;

.thumb
;; Item effect
.org 0x02117D4E
  MOV    R1, #0x60 ; X POS -> Original 0x62

;; Slot color
.org 0x021170DE
  MOV    R1, #0x9E - 4 ; X POS

.thumb
;; Increase the size of the item name textbox
.org 0x02116E90
  MOV     R0, #0x14 + 1     ; Width / 8

;;----------------------------------------------------------------------------;;
;;  Align the position of the textbox in the effect of items
;;  Copyright 2014 Benito Palacios (aka pleonex)
;;
;;  Licensed under the Apache License, Version 2.0 (the "License");
;;  you may not use this file except in compliance with the License.
;;  You may obtain a copy of the License at
;;
;;      http://www.apache.org/licenses/LICENSE-2.0
;;
;;  Unless required by applicable law or agreed to in writing, software
;;  distributed under the License is distributed on an "AS IS" BASIS,
;;  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;  See the License for the specific language governing permissions and
;;  limitations under the License.
;;----------------------------------------------------------------------------;;

.thumb
;; Item effect
.org 0x02117D4E
  MOV    R1, #0x60 ; X POS -> Original 0x62

;; Slot color
.org 0x021170DE
  MOV    R1, #0x9E - 4 ; X POS

.thumb
;; Increase the size of the item name textbox
.org 0x02116E90
  MOV     R0, #0x14 + 2     ; Width / 8

Increase items name textbox size

Increase items name textbox size


global _start

section .data
    align 16
mydword:
    dd  0

%include "header.inc"

    ; 32-bit register move should set higher bits to zero
    mov eax, -1
    mov eax, ss
    and eax, 0xffff0000

    ; 32-bit memory move should preserver higher bits
    mov dword [mydword], 0xdeadbeef
    mov [mydword], ss
    mov ebx, [mydword]
    and ebx, 0xffff0000

%include "footer.inc"

Test for mov [mem], sreg

Test for mov [mem], sreg


.nds
.relativeinclude on
.erroronwarning on

; Makes the entire map visible but greyed out from the start.

.open "ftc/arm9.bin", 02000000h

.org 0x020220C4
  ; Make the game not care if you have the map items and just always draw unvisited tiles.
  mov r1, r8
  nop

.org 0x02024BE8
  ; Makes rooms never be counted as secret rooms, since secret rooms don't show up even if the game thinks you have the map for that area.
  mvn r0, 0h
  bx r14

.close

Add patch to reveal whole map from the start for DoS


; =============================================================================
; Copyright (C) 2015 Manolis Fragkiskos Ragkousis -- see LICENSE.TXT
; =============================================================================

;;; Print routine
;;; I push all the register to the stack.
;;; Set the bios routine for printing in the screen
;;; Move to al the data that bx points
;;; Generate the interrupt.
;;; Pop all registers from the stack
;;; Return to where the pc pointed to before getting in here.
;;; bx contains routine argument

%ifndef PRINT_STRING_16BIT
%define PRINT_STRING_16BIT

print_string:
        pusha
        mov ah, 0x0e

compare:
        cmp byte [bx], 0
        je exit
        jmp print

print:
        mov al, [bx]
        int 0x10
        add bx, 1
        jmp compare

exit:
        popa
        ret
%endif

; =============================================================================
; Copyright (C) 2015 Manolis Fragkiskos Ragkousis -- see LICENSE.TXT
; =============================================================================

;;; Print routine
;;; I push all the register to the stack.
;;; Set the bios routine for printing in the screen
;;; Move to al the data that bx points
;;; Generate the interrupt.
;;; Pop all registers from the stack
;;; Return to where the pc pointed to before getting in here.
;;; bx contains routine argument

%ifndef PRINT_STRING_16BIT
%define PRINT_STRING_16BIT

[bits 16]
print_string:
        pusha
        mov ah, 0x0e

print_loop:
        mov al, [bx]
        cmp al, 0
        je print_exit

        int 0x10
        inc bx
        jmp print_loop

print_exit:
        popa
        ret
%endif

Rewrite the 16bit print routine.

Rewrite the 16bit print routine.

* print/print_string.asm: Rewrite.


list n_IItemRenderer
GETSTATIC net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.instance : Lnet/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer;
ALOAD 1
INVOKEVIRTUAL net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.renderByItem (Lnet/minecraft/item/ItemStack;)V
GOTO LEND #end of if statement

list IItemRenderer
ALOAD 2
INSTANCEOF codechicken/lib/render/IItemRenderer
IFEQ LELSE
ALOAD 2
ALOAD 1
INVOKEINTERFACE codechicken/lib/render/IItemRenderer.renderItem (Lnet/minecraft/item/ItemStack;)V
GOTO LEND
LELSE

list n_IItemRenderer
GETSTATIC net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.field_147719_a : Lnet/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer;
ALOAD 1
INVOKEVIRTUAL net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.func_179022_a (Lnet/minecraft/item/ItemStack;)V
GOTO LEND #end of if statement

list IItemRenderer
ALOAD 2
INSTANCEOF codechicken/lib/render/IItemRenderer
IFEQ LELSE
ALOAD 2
ALOAD 1
INVOKEINTERFACE codechicken/lib/render/IItemRenderer.renderItem (Lnet/minecraft/item/ItemStack;)V
GOTO LEND
LELSE

Fix srg mapping in hook (round 2)

Fix srg mapping in hook (round 2)


.nds
.relativeinclude on
.erroronwarning on

; This patch for the boss randomizer prevents the boss in Gergoth's tower from being loaded in until the player enters the top floor of the tower.
; In order for the patch to work correctly, the boss entity should be at index 1 and the tower floors entity should be at index 0 (reversed from how they are in vanilla).

@Overlay41Start equ 0x02308920
@FreeSpace equ @Overlay41Start + 0x288

.open "ftc/overlay9_0", 0219E3E0h

.org 0x0219F08C ; Near the end of the create function for object 18 (tower floors)
  b @LoadOrUnloadTowerBoss

.close

.open "ftc/overlay9_41", @Overlay41Start

.org @FreeSpace
@LoadOrUnloadTowerBoss:
  ldr r1, =020F70CCh ; Pointer to the current room's entity list
  ldr r1, [r1]
  add r1, r1, 11h ; Add 0x11 (0xC + 0x5) to the start of the entity list to get a pointer to the type byte of the second entity in the list, which is the boss entity.

  ; The last check done before the custom code was checking if r0 is equal to 0. If it is it means the player is on the top floor of the tower, so the boss should be loaded.
  beq @AllowTowerBossToBeLoaded
@DoNotAllowTowerBossToBeLoaded:
  mov r0, 0h ; Set the type of the boss entity to 0, so it's doesn't load any entity in.
  b @FinishLoadingOrUnloadingTowerBoss
@AllowTowerBossToBeLoaded:
  mov r0, 1h ; Set the type of the boss entity to 0, so it works properly as an enemy.
@FinishLoadingOrUnloadingTowerBoss:
  strb r0, [r1] ; Store the type to the entity list.

  ; Replace the code we overwrote to jump here.
  beq 0x0219F0AC ; Return from function if on the top floor.
  b 0x0219F098 ; If not on the top floor, do some other stuff before returning.

.pool

.close

Add patch to fix DoS tower boss in boss rando


.cpu "6502"
.target "flat"
* = $F000

BackgroundColor = $80

VSYNC = $00
VBLANK = $01
WSYNC = $02
COLUBK = $09
TIM64T = $296
INTIM = $284

Start
	SEI
	CLD
	LDX #$FF
	TXS
	LDA #0
ClearMem
	STA 0,X
	DEX
	BNE ClearMem
MainLoop
	LDA #%00000010
	STA VSYNC
	STA WSYNC
	STA WSYNC
	STA WSYNC
	LDA #43
	STA TIM64T
	LDA #0
	STA VSYNC

	INC BackgroundColor
	LDA BackgroundColor
	STA COLUBK

WaitForVBlankEnd
	LDA INTIM
	BNE WaitForVBlankEnd
	STA WSYNC
	STA VBLANK
	LDY #192

ScanLoop
	STA WSYNC
	DEY
	BNE ScanLoop

	LDA #2
	STA WSYNC
	STA VBLANK
	LDY #30
OverScanWait
	STA WSYNC
	DEY
	BNE OverScanWait
	JMP MainLoop

// Special memory locations. Tells the 6502 where to go.
* = $FFFC
.word Start
.word Start

Add basic background cycler example that is confirmed to work with 6502.Net.


	bits	64
	mov	rdx,[rax]
	mov	eax,[byte rsp+0x01]
	mov	eax,[byte rsp-0x01]
	mov	eax,[byte rsp+0xFF]
	mov	eax,[byte rsp-0xFF]
	mov	eax,[rsp+0x08]
	mov	eax,[rsp-0x01]
	mov	eax,[rsp+0xFF]
	mov	eax,[rsp-0xFF]
	mov	rax,[rsp+56]
	mov	[rsi],dl
	mov	byte [rsi],'-'
	mov	[rsi],al
	mov	byte [rsi],' '

Test of some addressing modes in 64-bit mode.


	;; Known problematic floating-point numbers and their proper
	;; encoding...

		dd 1.1e10
		dd 0x5023e9ac	; Should be...

		dd 50.40e9
		dd 0x513bc130	; Should be...

		dq 1.4e23
		dq 0x44bda56a4b0835c0

		dq 50.48e21
		dq 0x44a5610d7502feae

		dt 1.2e28
		dq 0x9b18ab5df7180b6c
		dw 0x405c

		dt 50.46e25
		dq 0xd0b29a67e95dcb60
		dw 0x4057

Add test for problematic floats

Add test for problematic floats


	bits 64
;	extern foo
	mov rax,[foo]
	mov rax,[123456789abcdef0h]
	mov rbx,[foo]
	mov rax,[dword foo]
	mov rbx,[dword foo]
	mov rax,[qword foo]
	mov rax,[rel foo]
	mov rbx,[rel foo]
	mov rax,[rel dword foo]
	mov rax,[rel qword foo]

	mov rax,[es:foo]
	mov rax,[es:123456789abcdef0h]
	mov rbx,[es:foo]
	mov rax,[dword es:foo]
	mov rbx,[dword es:foo]
	mov rax,[qword es:foo]
	mov rax,[rel es:foo]
	mov rbx,[rel es:foo]
	mov rax,[rel dword es:foo]
	mov rax,[rel qword es:foo]

	mov rax,[fs:foo]
	mov rax,[fs:123456789abcdef0h]
	mov rbx,[fs:foo]
	mov rax,[dword fs:foo]
	mov rbx,[dword fs:foo]
	mov rax,[qword fs:foo]
	mov rax,[rel fs:foo]
	mov rbx,[rel fs:foo]
	mov rax,[rel dword fs:foo]
	mov rax,[rel qword fs:foo]

	section .data
foo	equ $

Add test cases for IP-relative addressing


; Copyright 2011 Google Inc.
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;

.286
.MODEL TINY, C

.CODE

PUBLIC end_dos_stub

begin_dos_stub PROC
  ; Fold the code and data segments, as our data is in this function.
  ; Note that begin_dos_stub is implicitly the start of the data segment.
  push cs
  pop ds

  ; Compute  the distance to the string through this subtraction instead
  ; of e.g. a lea instruction to avoid the need for relocation entries
  mov dx, message - begin_dos_stub
  ; Print the message to the console
  mov ah, 09h
  int 21h

  ; Terminate the program
  mov ah, 00h
  int 21h

  message DB 'This is a Windows program, you cannot run it in DOS.\r\n$'

  ; Expose the end of the DOS stub as a function to make it easy to
  ; calculate its length.
  end_dos_stub LABEL PROC

begin_dos_stub ENDP

END

; Copyright 2012 Google Inc.
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;

.386
.MODEL TINY, C

.CODE

PUBLIC end_dos_stub

begin_dos_stub PROC
  ; Fold the code and data segments, as our data is in this function.
  ; Note that begin_dos_stub is implicitly the start of the data segment.
  push cs
  pop ds

  ; Compute  the distance to the string through this subtraction instead
  ; of e.g. a lea instruction to avoid the need for relocation entries
  mov dx, message - begin_dos_stub
  ; Print the message to the console
  mov ah, 09h
  int 21h

  ; Terminate the program
  mov ah, 00h
  int 21h

  message DB 'This is a Windows program, you cannot run it in DOS.\r\n$'

  ; Expose the end of the DOS stub as a function to make it easy to
  ; calculate its length.
  end_dos_stub LABEL PROC

begin_dos_stub ENDP

END

Switch dos stub processor spec to 386.

Switch dos stub processor spec to 386.

286 support is removed from the MASM that ships with VS2010.

BUG=
TEST=

Review URL: https://codereview.appspot.com/6223063

git-svn-id: db59699583a60be9a535cd09cdc9132301867226@834 15e8cca8-e42c-11de-a347-f34a4f72eb7d