diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2018-08-16 11:13:37 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2018-08-16 11:13:37 +0200 |
commit | 26164db8ad8df2e8d8b16df559d918cabdce121e (patch) | |
tree | 1901481f6789109f9e78892003583e1f4886f6a0 /crenshaw | |
parent | 43f86cfdefd629426c0c3bc203ec715d47fb7a15 (diff) | |
download | compilertests-26164db8ad8df2e8d8b16df559d918cabdce121e.tar.gz compilertests-26164db8ad8df2e8d8b16df559d918cabdce121e.tar.bz2 |
some documentation and fixing
Diffstat (limited to 'crenshaw')
-rw-r--r-- | crenshaw/README | 49 | ||||
-rw-r--r-- | crenshaw/main.pas | 2 |
2 files changed, 49 insertions, 2 deletions
diff --git a/crenshaw/README b/crenshaw/README index 56b01f6..b2414fc 100644 --- a/crenshaw/README +++ b/crenshaw/README @@ -1,4 +1,5 @@ debugging +--------- set disassemble-next-line on display $eax @@ -9,10 +10,20 @@ start si run in emulator (also for unit testing) +--------------- -gcc -Wall -std=c99 -o emul emul.c -lunicorn -pthread +Non-ELF, linear layout, start address 0x01000000, +stack starts at 0x01800000 growing downwards. +No segments or protections for now. + +gcc -g -Wall -std=c99 -o emul emul.c -lunicorn -lcapstone -pthread +fpc main.pas +./main < test.prog > test.asm +nasm -o test.bin -f bin test.asm +./emul test.bin links +----- https://en.wikibooks.org/wiki/68000_Assembly https://en.wikipedia.org/wiki/X86_instruction_listings @@ -21,3 +32,39 @@ file:///media/sd/compilertests/doc/Intel 80x86 Assembly Language OpCodes.html#di https://github.com/Rewzilla/asemu.git http://www.unicorn-engine.org/ http://www.capstone-engine.org/ + +findings +-------- + +tutor2: + +the expression and data stacks should be better explained and +linked to the abstract description of the algorithm. + +tutor3, local variables: + +local variables can be addresses after the code, letting +the assembler fill in the dword ptr [X] addresses. The +compiler merely adds [X] references and X: dw 0 labels and +data initializers. + +https://stackoverflow.com/questions/18447627/what-is-pc-relative-addressing-and-how-can-i-use-it-in-masm + +emulate the (PC) relative addressing of the MIPS: + +CALL x +x: + ; Now address "x" is on the stack + POP EDI + ; Now EDI contains address of "x" + ; Now we can do (pseudo-)PC-Relative addressing: + MOV EAX,[EDI+1234] + +but we still have to calculate relative addresses. + +There is no initializer yet, so we can just address the initialized +variable in the expression for now. + +=> there is a tradeoff here, how much do we do in the compiler, how + much in the assember, linker + diff --git a/crenshaw/main.pas b/crenshaw/main.pas index 55189a7..654d547 100644 --- a/crenshaw/main.pas +++ b/crenshaw/main.pas @@ -202,7 +202,7 @@ end; procedure Variables; var i : integer; begin - for i := 0 to nof_names do begin + for i := 0 to nof_names-1 do begin EmitLabel(names[i]); EmitLn('dw 0'); end; |