Minor cleanup.

It turns out that the binary_number relation is used in such a way that it needs to be able to backtrack to preprend leading zeros to the list of bits it constructs to automatically build bitfields of a given width (with the collect//2 DCG.)
This commit is contained in:
Simon Forman 2019-05-01 21:55:46 -07:00
parent d488db6abd
commit fe795704a6
1 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/*
/*
Copyright © 2018 Simon Forman
@ -284,10 +284,10 @@ high_half_word(I, HighHalf) :- HighHalf is I >> 16 /\ 0xFFFF.
low_half_word( I, LowHalf) :- LowHalf is I /\ 0xFFFF.
compile_program(Program, Binary) :-
phrase(pass0(Program, AST), [], _),
phrase((AST), IR),
phrase(linker(IR), ASM),
phrase(asm(ASM), Binary).
phrase(pass0(Program, IR), [], _),
phrase((IR), ASM),
phrase(linker(ASM), EnumeratedASM),
phrase(asm(EnumeratedASM), Binary).
% Linker
@ -555,8 +555,8 @@ canonical_binary_number([1|Bits], Number):-
canonical_binary_number(Bits1, Number1),
Number is Number1 + 2 ^ Pow.
binary_number([0|Bits], Number) :- binary_number(Bits, Number).
binary_number( Bits , Number) :- canonical_binary_number(Bits, Number).
binary_number([0|Bits], Number) :- binary_number(Bits, Number).
% Helper code to write the list of bits as a binary file.