Skip to content

Instantly share code, notes, and snippets.

@samhattangady
Created October 9, 2020 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samhattangady/9861ab90835c1703312d02b79d9f5c2f to your computer and use it in GitHub Desktop.
Save samhattangady/9861ab90835c1703312d02b79d9f5c2f to your computer and use it in GitHub Desktop.
Hovalaag Bug?
; The documentation in sample.vasm states that "F=POS(A>>1) is true if and only if A was positive and even before the shift"
; This doesn't seem to be the case in v1.08. Even a negative even number seems to give a true value.
; Solution for problem 6.
get_input:
A=IN1, C=0, B=1
D=A
loop:
F=ZERO(-A)
JMPT out, F=ZERO(A&B)
JMPF update_c
A=A>>1, JMP loop
update_c:
A=A>>1, DEC, JMP loop
out:
A=C
; A=-A ; -> Commenting/uncommenting this line doesn't make a difference. Both give the correct result.
F=POS(A>>1), A=D
JMPT even, W=A
OUT1=W, JMP get_input
even:
OUT2=W, JMP get_input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment