Skip to content

Commit 427f584

Browse files
Correcoes
1 parent a8338d8 commit 427f584

File tree

15 files changed

+922
-676
lines changed

15 files changed

+922
-676
lines changed

Ambiente.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ class Ambiente
22
{
33
// Aqui armazena variaveis de ambiente usadas por todas as etapas da compilação
44

5+
public byte TamanhoStringPilha { get; set; } = 128;
6+
public byte TamanhoStringEstatica { get; set; } = 255;
7+
8+
public List<Realocacao> Realocacoes { get; set; } = new List<Realocacao>();
59
public List<DirectoryInfo> DiretoriosImportacao ;
610
// Todos os modulos carregados
711
public List<Modulo> Modulos { get; set; }

Analise.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ private void nivelRotina(Modulo mod, Rotina rot, List<No> cmds, bool apenasUmCom
488488
else if(trechos.EhIdentificador("goto"))
489489
{
490490
trechos.Proximo();
491-
cmds.Add(new VaPara(trechos.Anterior));
491+
cmds.Add(new VaPara(trechos.Atual));
492+
trechos.Proximo();
492493
}
493494
else if(trechos.EhIdentificador("invoke"))
494495
{
@@ -602,7 +603,7 @@ private Rotina processaSubFunction(Modulo mod, NivelPublicidade publi, bool reto
602603
trechos.ExigeProximo("Esperado o nome da rotina após o 'sub'/'function'");
603604
trechos.ExigeId("Esperado o nome da rotina");
604605
Trecho subTrecho = trechos.Atual;
605-
Rotina rot = new Rotina(subTrecho, mod, publi, retornaValor, TipoVariavel.Int16);
606+
Rotina rot = new Rotina(subTrecho, mod, publi, retornaValor, TipoVariavel.Desconhecido);
606607
trechos.Proximo();
607608
if(trechos.EhTipo(TipoTrecho.AbreParenteses))
608609
{
@@ -846,5 +847,12 @@ public void Compila(Saida saida)
846847
mod.Compila(amb);
847848
CompilaReferencias(mod, amb);
848849
}
850+
851+
amb.Saida.EmiteRotulo("REALOC_TABLE");
852+
foreach (var realoc in amb.Realocacoes)
853+
{
854+
amb.Saida.EmiteItemRealocacao(realoc);
855+
}
856+
amb.Saida.EmiteItemRealocacao(new Realocacao(TipoDeRealocacao.FimLista, 0, "0", 0));
849857
}
850858
}

Distro/Atual/hcbasic.dll

3 KB
Binary file not shown.

Distro/Atual/hcbasic.pdb

800 Bytes
Binary file not shown.

Nos/Acao.cs

Lines changed: 26 additions & 13 deletions
Large diffs are not rendered by default.

Plataformas/8086-DOS/System.OS.hcb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,44 @@ module OS
1010
sub Start2
1111
' Declara ponteiro para os argumentos
1212
dim args as ptrbytearray
13+
' Realoca executavel
14+
Dim realoc as PtrWordArray
15+
Dim ptr as PtrWordArray
16+
Dim tipoRealoc as UInt16
17+
Dim desvio as UInt16
18+
Dim soma as UInt16
19+
#realoc = CodeSegment()
20+
#ptr = CodeSegment()
21+
@realoc = RealocTable()
22+
while realoc <> 0
23+
tipoRealoc = realoc
24+
@realoc ++
25+
@realoc ++
26+
@ptr = realoc
27+
@realoc ++
28+
@realoc ++
29+
desvio = realoc
30+
@realoc ++
31+
@realoc ++
32+
soma = realoc
33+
@realoc ++
34+
@realoc ++
35+
if tipoRealoc == 3 then
36+
ptr = CodeSegment() + soma
37+
desvio = desvio + @ptr
38+
@ptr ++
39+
@ptr ++
40+
ptr = desvio
41+
end
42+
if tipoRealoc == 2 then
43+
@ptr = @ptr + desvio
44+
ptr = StackSegment() + soma
45+
end
46+
if tipoRealoc == 1 then
47+
@ptr = @ptr + desvio
48+
ptr = CodeSegment() + soma
49+
end
50+
end
1351
' Define ponteiro
1452
asm "mov ax, cs"
1553
asm "mov [bp-2], ax"
@@ -34,6 +72,10 @@ module OS
3472
asm "mov ax, ss"
3573
end
3674

75+
public function RealocTable() as uint16
76+
asm "mov ax, REALOC_TABLE"
77+
end
78+
3779
public function ConsoleReadChar() as uint8
3880
asm "mov ah, 1"
3981
asm "int 0x21"

Plataformas/8086-KERNEL/System.OS.hcb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,44 @@ module OS
1010
sub Start2
1111
' Declara ponteiro para os argumentos
1212
dim args as ptrbytearray
13+
' Realoca executavel
14+
Dim realoc as PtrWordArray
15+
Dim ptr as PtrWordArray
16+
Dim tipoRealoc as UInt16
17+
Dim desvio as UInt16
18+
Dim soma as UInt16
19+
#realoc = CodeSegment()
20+
#ptr = CodeSegment()
21+
@realoc = RealocTable()
22+
while realoc <> 0
23+
tipoRealoc = realoc
24+
@realoc ++
25+
@realoc ++
26+
@ptr = realoc
27+
@realoc ++
28+
@realoc ++
29+
desvio = realoc
30+
@realoc ++
31+
@realoc ++
32+
soma = realoc
33+
@realoc ++
34+
@realoc ++
35+
if tipoRealoc == 3 then
36+
ptr = CodeSegment() + soma
37+
desvio = desvio + @ptr
38+
@ptr ++
39+
@ptr ++
40+
ptr = desvio
41+
end
42+
if tipoRealoc == 2 then
43+
@ptr = @ptr + desvio
44+
ptr = StackSegment() + soma
45+
end
46+
if tipoRealoc == 1 then
47+
@ptr = @ptr + desvio
48+
ptr = CodeSegment() + soma
49+
end
50+
end
1351
' Define ponteiro
1452
asm "mov ax, cs"
1553
asm "mov [bp-2], ax"

Plataformas/8086/System.hcb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,49 @@ module String
1212
end
1313
return i
1414
end
15+
16+
public function Concat(dest as ptrbytearray, orig as ptrbytearray) as uint16
17+
dim dest_len as uint16
18+
dim dest_capacity as uint16
19+
dim len as uint16
20+
dim i as uint16
21+
dim tmp as uint8
22+
dest_len = String.Length(dest)
23+
dest_capacity = dest
24+
len = String.Length(orig) + 1
25+
if (len + dest_len + 1) > dest_capacity then return 0
26+
@dest = @dest + 1 + dest_len
27+
@orig++
28+
for i = 1 to len
29+
tmp = orig
30+
dest = tmp
31+
@dest++
32+
@orig++
33+
end
34+
dest = 0
35+
return 1
36+
end
37+
38+
public function Copy(dest as ptrbytearray, orig as ptrbytearray) as uint16
39+
dim dest_capacity as uint16
40+
dim orig_len as uint16
41+
dim i as uint16
42+
dim tmp as uint8
43+
dest_capacity = dest
44+
orig_len = String.Length(orig) + 1
45+
@dest++
46+
@orig++
47+
dest = 0
48+
if dest_capacity < (orig_len + 1) then return 0
49+
for i = 1 to orig_len
50+
tmp = orig
51+
dest = tmp
52+
@orig++
53+
@dest++
54+
end
55+
dest = 0
56+
return 1
57+
end
1558
end
1659

1760
structure Stream

Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
if(args.Count() < 2)
88
{
9-
Console.WriteLine("HCBasic v0.9.5");
9+
Console.WriteLine("HCBasic v0.9.6 - Pré lançamento");
1010
Console.WriteLine("Copyright (c) 2023, Humberto Costa dos Santos Junior");
1111
Console.WriteLine("Uso: hcbasic [arquivo.hcb] [arquivo.asm] [lista de diretorios include] ...");
1212
return 0;

Realocacao.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Realocacao
2+
{
3+
public TipoDeRealocacao Tipo { get; set; } = TipoDeRealocacao.FimLista;
4+
public ushort ValorSoma { get; set; } = 0;
5+
public string Rotulo {get;set;} = "0";
6+
public ushort Desvio { get; set; } = 0;
7+
8+
public Realocacao(TipoDeRealocacao tipo, ushort valorSoma, string rotulo, ushort desvio)
9+
{
10+
Tipo = tipo;
11+
ValorSoma = valorSoma;
12+
Rotulo = rotulo;
13+
Desvio = desvio;
14+
}
15+
}
16+
17+
enum TipoDeRealocacao
18+
{
19+
FimLista = 0,
20+
CodeSegment = 1,
21+
StackSegment = 2,
22+
CodeSegmentStructure = 3
23+
}

0 commit comments

Comments
 (0)