Add Leading 0 before addresses
This commit is contained in:
parent
413105e4be
commit
3af69db95a
73
out/elm.js
73
out/elm.js
@ -5715,6 +5715,60 @@ var $elm$html$Html$Events$onClick = function (msg) {
|
|||||||
var $elm$virtual_dom$VirtualDom$text = _VirtualDom_text;
|
var $elm$virtual_dom$VirtualDom$text = _VirtualDom_text;
|
||||||
var $elm$html$Html$text = $elm$virtual_dom$VirtualDom$text;
|
var $elm$html$Html$text = $elm$virtual_dom$VirtualDom$text;
|
||||||
var $elm$html$Html$Attributes$type_ = $elm$html$Html$Attributes$stringProperty('type');
|
var $elm$html$Html$Attributes$type_ = $elm$html$Html$Attributes$stringProperty('type');
|
||||||
|
var $elm$core$String$fromList = _String_fromList;
|
||||||
|
var $author$project$Main$addLeadingZero = F2(
|
||||||
|
function (number, length) {
|
||||||
|
var num_str = $elm$core$String$fromInt(number);
|
||||||
|
return (number < 10) ? _Utils_ap(
|
||||||
|
$elm$core$String$fromList(
|
||||||
|
A2(
|
||||||
|
$elm$core$List$repeat,
|
||||||
|
length - 1,
|
||||||
|
_Utils_chr('0'))),
|
||||||
|
num_str) : ((number < 100) ? _Utils_ap(
|
||||||
|
$elm$core$String$fromList(
|
||||||
|
A2(
|
||||||
|
$elm$core$List$repeat,
|
||||||
|
length - 2,
|
||||||
|
_Utils_chr('0'))),
|
||||||
|
num_str) : ((number < 1000) ? _Utils_ap(
|
||||||
|
$elm$core$String$fromList(
|
||||||
|
A2(
|
||||||
|
$elm$core$List$repeat,
|
||||||
|
length - 3,
|
||||||
|
_Utils_chr('0'))),
|
||||||
|
num_str) : ((number < 10000) ? _Utils_ap(
|
||||||
|
$elm$core$String$fromList(
|
||||||
|
A2(
|
||||||
|
$elm$core$List$repeat,
|
||||||
|
length - 4,
|
||||||
|
_Utils_chr('0'))),
|
||||||
|
num_str) : ((number < 100000) ? _Utils_ap(
|
||||||
|
$elm$core$String$fromList(
|
||||||
|
A2(
|
||||||
|
$elm$core$List$repeat,
|
||||||
|
length - 5,
|
||||||
|
_Utils_chr('0'))),
|
||||||
|
num_str) : ((number < 1000000) ? _Utils_ap(
|
||||||
|
$elm$core$String$fromList(
|
||||||
|
A2(
|
||||||
|
$elm$core$List$repeat,
|
||||||
|
length - 6,
|
||||||
|
_Utils_chr('0'))),
|
||||||
|
num_str) : ((number < 10000000) ? _Utils_ap(
|
||||||
|
$elm$core$String$fromList(
|
||||||
|
A2(
|
||||||
|
$elm$core$List$repeat,
|
||||||
|
length - 7,
|
||||||
|
_Utils_chr('0'))),
|
||||||
|
num_str) : ((number < 100000000) ? _Utils_ap(
|
||||||
|
$elm$core$String$fromList(
|
||||||
|
A2(
|
||||||
|
$elm$core$List$repeat,
|
||||||
|
length - 8,
|
||||||
|
_Utils_chr('0'))),
|
||||||
|
num_str) : num_str)))))));
|
||||||
|
});
|
||||||
var $elm$html$Html$span = _VirtualDom_node('span');
|
var $elm$html$Html$span = _VirtualDom_node('span');
|
||||||
var $author$project$Main$viewAddressBus = function (model) {
|
var $author$project$Main$viewAddressBus = function (model) {
|
||||||
return A2(
|
return A2(
|
||||||
@ -5741,7 +5795,7 @@ var $author$project$Main$viewAddressBus = function (model) {
|
|||||||
_List_fromArray(
|
_List_fromArray(
|
||||||
[
|
[
|
||||||
$elm$html$Html$text(
|
$elm$html$Html$text(
|
||||||
$elm$core$String$fromInt(model.pc.addressBus))
|
A2($author$project$Main$addLeadingZero, model.pc.addressBus, 3))
|
||||||
]))
|
]))
|
||||||
]));
|
]));
|
||||||
};
|
};
|
||||||
@ -5914,7 +5968,7 @@ var $author$project$Main$viewCuUCodeContent = function (model) {
|
|||||||
_List_fromArray(
|
_List_fromArray(
|
||||||
[
|
[
|
||||||
$elm$html$Html$text(
|
$elm$html$Html$text(
|
||||||
$elm$core$String$fromInt(id))
|
A2($author$project$Main$addLeadingZero, id, 3))
|
||||||
])),
|
])),
|
||||||
A2(
|
A2(
|
||||||
$elm$html$Html$td,
|
$elm$html$Html$td,
|
||||||
@ -5942,7 +5996,7 @@ var $author$project$Main$viewCuUCodeContent = function (model) {
|
|||||||
_List_fromArray(
|
_List_fromArray(
|
||||||
[
|
[
|
||||||
$elm$html$Html$text(
|
$elm$html$Html$text(
|
||||||
$elm$core$String$fromInt(id))
|
A2($author$project$Main$addLeadingZero, id, 3))
|
||||||
])),
|
])),
|
||||||
A2(
|
A2(
|
||||||
$elm$html$Html$td,
|
$elm$html$Html$td,
|
||||||
@ -6178,10 +6232,16 @@ var $author$project$Main$viewDataBus = function (model) {
|
|||||||
_List_fromArray(
|
_List_fromArray(
|
||||||
[
|
[
|
||||||
$elm$html$Html$text(
|
$elm$html$Html$text(
|
||||||
$elm$core$String$fromInt(model.pc.dataBus))
|
A2($author$project$Main$addLeadingZero, model.pc.dataBus, 8))
|
||||||
]))
|
]))
|
||||||
]));
|
]));
|
||||||
};
|
};
|
||||||
|
var $author$project$Main$viewInstrEntry = function (i) {
|
||||||
|
var instruction = (i / 100000) | 0;
|
||||||
|
var address = i - (instruction * 100000);
|
||||||
|
return $elm$html$Html$text(
|
||||||
|
A2($author$project$Main$addLeadingZero, instruction, 3) + (' ' + A2($author$project$Main$addLeadingZero, address, 5)));
|
||||||
|
};
|
||||||
var $author$project$Main$viewRamContent = function (model) {
|
var $author$project$Main$viewRamContent = function (model) {
|
||||||
var ram2table = function (entry) {
|
var ram2table = function (entry) {
|
||||||
var val = entry.b;
|
var val = entry.b;
|
||||||
@ -6209,7 +6269,7 @@ var $author$project$Main$viewRamContent = function (model) {
|
|||||||
_List_fromArray(
|
_List_fromArray(
|
||||||
[
|
[
|
||||||
$elm$html$Html$text(
|
$elm$html$Html$text(
|
||||||
$elm$core$String$fromInt(id))
|
A2($author$project$Main$addLeadingZero, id, 3))
|
||||||
])),
|
])),
|
||||||
A2(
|
A2(
|
||||||
$elm$html$Html$td,
|
$elm$html$Html$td,
|
||||||
@ -6219,8 +6279,7 @@ var $author$project$Main$viewRamContent = function (model) {
|
|||||||
]),
|
]),
|
||||||
_List_fromArray(
|
_List_fromArray(
|
||||||
[
|
[
|
||||||
$elm$html$Html$text(
|
$author$project$Main$viewInstrEntry(val)
|
||||||
$elm$core$String$fromInt(val))
|
|
||||||
]))
|
]))
|
||||||
]));
|
]));
|
||||||
};
|
};
|
||||||
|
47
src/Main.elm
47
src/Main.elm
@ -10,6 +10,7 @@ import Html.Events exposing (onClick)
|
|||||||
import Html.Lazy exposing (lazy)
|
import Html.Lazy exposing (lazy)
|
||||||
import Tuple
|
import Tuple
|
||||||
import Array exposing (get)
|
import Array exposing (get)
|
||||||
|
import Html exposing (address)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -370,8 +371,8 @@ viewRamContent model =
|
|||||||
in
|
in
|
||||||
Html.tr
|
Html.tr
|
||||||
[ classList [ ( "current", id == model.pc.addressBus ) ] ]
|
[ classList [ ( "current", id == model.pc.addressBus ) ] ]
|
||||||
[ Html.td [ class "num" ] [ text (String.fromInt id) ]
|
[ Html.td [ class "num" ] [ text (addLeadingZero id 3) ]
|
||||||
, Html.td [ class "num " ] [ text (String.fromInt val) ]
|
, Html.td [ class "num " ] [ viewInstrEntry val ]
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
Html.tbody [] (List.map ram2table indexedRam)
|
Html.tbody [] (List.map ram2table indexedRam)
|
||||||
@ -465,13 +466,13 @@ viewCuUCodeContent model =
|
|||||||
in
|
in
|
||||||
Html.tr
|
Html.tr
|
||||||
[ classList [ ( "current", id == model.pc.uCounter ) ] ]
|
[ classList [ ( "current", id == model.pc.uCounter ) ] ]
|
||||||
[ Html.td [ class "num" ] [ text (String.fromInt id) ]
|
[ Html.td [ class "num" ] [ text (addLeadingZero id 3) ]
|
||||||
, Html.td [] [ text codeDescription ]
|
, Html.td [] [ text codeDescription ]
|
||||||
]
|
]
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
Html.tr [ class "empty" ]
|
Html.tr [ class "empty" ]
|
||||||
[ Html.td [ class "num" ] [ text (String.fromInt id) ]
|
[ Html.td [ class "num" ] [ text (addLeadingZero id 3) ]
|
||||||
, Html.td [] [ text "Empty" ]
|
, Html.td [] [ text "Empty" ]
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
@ -500,7 +501,7 @@ viewDataBus : Model -> Html Msg
|
|||||||
viewDataBus model =
|
viewDataBus model =
|
||||||
div [ class "databus" ]
|
div [ class "databus" ]
|
||||||
[ Html.span [ class "label" ] [ text "Databus" ]
|
[ Html.span [ class "label" ] [ text "Databus" ]
|
||||||
, Html.span [] [ text (String.fromInt model.pc.dataBus) ]
|
, Html.span [] [ text (addLeadingZero model.pc.dataBus 8) ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -508,10 +509,21 @@ viewAddressBus : Model -> Html Msg
|
|||||||
viewAddressBus model =
|
viewAddressBus model =
|
||||||
div [ class "addressbus" ]
|
div [ class "addressbus" ]
|
||||||
[ Html.span [ class "label" ] [ text "Addressbus" ]
|
[ Html.span [ class "label" ] [ text "Addressbus" ]
|
||||||
, Html.span [] [ text (String.fromInt model.pc.addressBus) ]
|
, Html.span [] [ text (addLeadingZero model.pc.addressBus 3) ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
viewInstrEntry : Int -> Html Msg
|
||||||
|
viewInstrEntry i =
|
||||||
|
let
|
||||||
|
instruction = i // 100000
|
||||||
|
address = i - instruction*100000
|
||||||
|
in
|
||||||
|
text ( (addLeadingZero instruction 3) ++ " " ++ (addLeadingZero address 5) )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- END VIEWERS
|
-- END VIEWERS
|
||||||
-- ACTIONS
|
-- ACTIONS
|
||||||
@ -640,6 +652,29 @@ changeAt pos newVal list =
|
|||||||
List.append before (newVal :: after)
|
List.append before (newVal :: after)
|
||||||
|
|
||||||
|
|
||||||
|
addLeadingZero : Int -> Int -> String
|
||||||
|
addLeadingZero number length =
|
||||||
|
let
|
||||||
|
num_str = String.fromInt number
|
||||||
|
in
|
||||||
|
if number < 10 then
|
||||||
|
(String.fromList (List.repeat (length - 1) '0') ) ++ num_str
|
||||||
|
else if number < 100 then
|
||||||
|
(String.fromList (List.repeat (length - 2) '0') ) ++ num_str
|
||||||
|
else if number < 1000 then
|
||||||
|
(String.fromList (List.repeat (length - 3) '0') ) ++ num_str
|
||||||
|
else if number < 10000 then
|
||||||
|
(String.fromList (List.repeat (length - 4) '0') ) ++ num_str
|
||||||
|
else if number < 100000 then
|
||||||
|
(String.fromList (List.repeat (length - 5) '0') ) ++ num_str
|
||||||
|
else if number < 1000000 then
|
||||||
|
(String.fromList (List.repeat (length - 6) '0') ) ++ num_str
|
||||||
|
else if number < 10000000 then
|
||||||
|
(String.fromList (List.repeat (length - 7) '0') ) ++ num_str
|
||||||
|
else if number < 100000000 then
|
||||||
|
(String.fromList (List.repeat (length - 8) '0') ) ++ num_str
|
||||||
|
else
|
||||||
|
num_str
|
||||||
|
|
||||||
-- END HELPERS
|
-- END HELPERS
|
||||||
-- GENERAL
|
-- GENERAL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user